Opera 12.15 Source Code
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

winman.cpp 35KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4; c-file-style:"stroustrup" -*-
  2. *
  3. * Copyright (C) 1995-2011 Opera Software ASA. All rights reserved.
  4. *
  5. * This file is part of the Opera web browser.
  6. * It may not be distributed under any circumstances.
  7. */
  8. #include "core/pch.h"
  9. // FIXME: clean up these includes!
  10. #include "modules/dochand/winman.h"
  11. #include "modules/display/cursor.h"
  12. #include "modules/display/prn_dev.h"
  13. #include "modules/display/vis_dev.h"
  14. #include "modules/doc/frm_doc.h"
  15. #include "modules/dom/domutils.h"
  16. #include "modules/dochand/fdelm.h"
  17. #include "modules/dochand/global_history.h"
  18. #include "modules/dochand/win.h"
  19. #include "modules/dochand/windowlistener.h"
  20. #include "modules/ecmascript_utils/esthread.h"
  21. #include "modules/encodings/detector/charsetdetector.h"
  22. #ifdef GADGET_SUPPORT
  23. #include "modules/gadgets/OpGadget.h"
  24. #endif // GADGET_SUPPORT
  25. #include "modules/hardcore/mem/mem_man.h"
  26. #include "modules/hardcore/mh/messages.h"
  27. #include "modules/hardcore/unicode/unicode.h"
  28. #include "modules/locale/locale-enum.h"
  29. #include "modules/locale/oplanguagemanager.h"
  30. #include "modules/logdoc/htm_elm.h"
  31. #include "modules/logdoc/htm_ldoc.h"
  32. #include "modules/olddebug/timing.h"
  33. #include "modules/pi/OpWindow.h"
  34. #include "modules/security_manager/include/security_manager.h"
  35. #include "modules/inputmanager/inputaction.h"
  36. #include "modules/inputmanager/inputmanager.h"
  37. #include "modules/display/prn_info.h"
  38. #include "modules/url/url_man.h"
  39. #include "modules/url/protocols/comm.h"
  40. #include "modules/util/gen_str.h"
  41. #include "modules/util/filefun.h"
  42. #ifdef USE_OP_THREAD_TOOLS
  43. # include "modules/pi/OpThreadTools.h"
  44. #endif
  45. #include "modules/util/timecache.h"
  46. #include "modules/prefs/prefsmanager/collections/pc_display.h"
  47. #include "modules/prefs/prefsmanager/collections/pc_doc.h"
  48. #include "modules/prefs/prefsmanager/collections/pc_js.h"
  49. #include "modules/prefs/prefsmanager/collections/pc_network.h"
  50. #include "modules/dom/domenvironment.h"
  51. #ifdef QUICK
  52. # include "adjunct/quick/Application.h"
  53. # include "adjunct/quick/managers/KioskManager.h"
  54. # include "adjunct/quick/dialogs/DownloadDialog.h"
  55. # include "adjunct/quick/hotlist/HotlistManager.h"
  56. #endif // QUICK
  57. #include "modules/windowcommander/src/WindowCommander.h"
  58. #include "modules/windowcommander/src/WindowCommanderManager.h"
  59. #include "modules/windowcommander/OpWindowCommanderManager.h"
  60. #ifdef _PLUGIN_SUPPORT_
  61. # include "modules/ns4plugins/opns4pluginhandler.h"
  62. #endif // _PLUGIN_SUPPORT_
  63. #ifdef LINK_SUPPORT
  64. #include "modules/logdoc/link.h"
  65. #endif // LINK_SUPPORT
  66. #ifdef WEBSERVER_SUPPORT
  67. #include "modules/webserver/webserver-api.h"
  68. #include "modules/webserver/webserver_resources.h"
  69. #endif //WEBSERVER_SUPPORT
  70. #ifdef SCOPE_WINDOW_MANAGER_SUPPORT
  71. # include "modules/scope/scope_window_listener.h"
  72. #endif // SCOPE_WINDOW_MANAGER_SUPPORT
  73. #ifdef ABOUT_HTML_DIALOGS
  74. # include "modules/about/ophtmldialogs.h"
  75. #endif // ABOUT_HTML_DIALOGS
  76. #ifdef USE_OP_CLIPBOARD
  77. # include "modules/dragdrop/clipboard_manager.h"
  78. #endif // USE_OP_CLIPBOARD
  79. void WindowManager::ConstructL()
  80. {
  81. g_pcdoc->RegisterListenerL(this);
  82. g_pcdisplay->RegisterListenerL(this);
  83. LEAVE_IF_ERROR(g_main_message_handler->SetCallBack(this, MSG_OPEN_URL_IN_NEW_WINDOW, 0));
  84. LEAVE_IF_ERROR(g_main_message_handler->SetCallBack(this, MSG_ES_CLOSE_WINDOW, 0));
  85. }
  86. WindowManager::WindowManager()
  87. : idcounter(0),
  88. m_documents_having_blink(0),
  89. m_privacy_mode_context_id(0),
  90. m_number_of_windows_in_privacy_mode(0)
  91. #ifdef WEB_TURBO_MODE
  92. , m_turbo_mode_context_id(0)
  93. #endif // WEB_TURBO_MODE
  94. #ifdef AB_ERROR_SEARCH_FORM
  95. , m_last_typed_user_text(NULL)
  96. #endif //AB_ERROR_SEARCH_FORM
  97. {
  98. curr_clicked_window = NULL;
  99. current_popup_message[0] = 0;
  100. current_popup_message_statusline_only = FALSE;
  101. }
  102. WindowManager::~WindowManager()
  103. {
  104. g_pcdoc->UnregisterListener(this);
  105. g_pcdisplay->UnregisterListener(this);
  106. OP_ASSERT(m_number_of_windows_in_privacy_mode == 0 && m_privacy_mode_context_id == 0);
  107. Clear();
  108. g_main_message_handler->UnsetCallBacks(this);
  109. }
  110. void WindowManager::Clear()
  111. {
  112. Window* w = FirstWindow();
  113. while (w)
  114. {
  115. Window* ws = w->Suc();
  116. #ifdef QUICK
  117. if(g_application) //g_application is the only uiwindowlistener
  118. #endif // QUICK
  119. {
  120. g_windowCommanderManager->GetUiWindowListener()->CloseUiWindow(w->GetWindowCommander());
  121. }
  122. w = ws;
  123. }
  124. #ifdef WEB_TURBO_MODE
  125. if( m_turbo_mode_context_id )
  126. {
  127. urlManager->RemoveContext(m_turbo_mode_context_id, FALSE);
  128. m_turbo_mode_context_id = 0;
  129. }
  130. #endif // WEB_TURBO_MODE
  131. }
  132. void WindowManager::SetMaxWindowHistory(int len)
  133. {
  134. for (Window* w = FirstWindow(); w; w = w->Suc())
  135. w->SetMaxHistory(len);
  136. }
  137. Window* WindowManager::GetNamedWindow(Window* from_window, const uni_char* window_name, int &sub_win_id, BOOL open_new_window)
  138. {
  139. if (!window_name)
  140. {
  141. sub_win_id = -1;
  142. if (from_window)
  143. return from_window;
  144. else if (open_new_window)
  145. {
  146. BOOL3 open_in_new_window = YES;
  147. BOOL3 open_in_background = MAYBE;
  148. return GetAWindow(TRUE, open_in_new_window, open_in_background);
  149. }
  150. return NULL;
  151. }
  152. for (Window* w = FirstWindow(); w; w = w->Suc())
  153. {
  154. if (w->Name() && !uni_strcmp(w->Name(), window_name))
  155. return w;
  156. FramesDocument* doc = w->GetCurrentDoc();
  157. if (doc)
  158. {
  159. const uni_char* name = window_name;
  160. doc->FindTarget(name, sub_win_id);
  161. if (!name)
  162. return w;
  163. }
  164. }
  165. if (window_name)
  166. {
  167. const uni_char* host = from_window->GetCurrentURL().GetAttribute(URL::KUniHostName, TRUE).CStr();
  168. if (!g_pcdoc->GetIntegerPref(PrefsCollectionDoc::IgnoreTarget, host) &&
  169. !g_pcdoc->GetIntegerPref(PrefsCollectionDoc::SingleWindowBrowsing, host) ||
  170. from_window->GetType() == WIN_TYPE_BRAND_VIEW)
  171. {
  172. if (open_new_window)
  173. {
  174. sub_win_id = -1;
  175. BOOL3 open_in_new_window = YES;
  176. BOOL3 open_in_background = MAYBE;
  177. Window* window = GetAWindow(TRUE, open_in_new_window, open_in_background);
  178. if (window)
  179. {
  180. window->SetName(window_name);
  181. window->SetOpener(from_window, -1, FALSE);
  182. }
  183. return window;
  184. }
  185. else
  186. return NULL;
  187. }
  188. }
  189. return from_window;
  190. }
  191. void WindowManager::UpdateVisitedLinks(const URL& url, Window* exclude_window)
  192. {
  193. #ifndef DONT_UPDATE_VISITED_LINKS
  194. for (Window* w = FirstWindow(); w; w = w->Suc())
  195. if (w != exclude_window)
  196. w->UpdateVisitedLinks(url);
  197. #endif // DONT_UPDATE_VISITED_LINKS
  198. }
  199. Window* WindowManager::OpenURLNewWindow(const char* url_name, BOOL check_if_expired, BOOL3 open_in_new_window, EnteredByUser entered_by_user)
  200. {
  201. BOOL3 open_in_background = MAYBE;
  202. Window* window;
  203. window = GetAWindow(TRUE, open_in_new_window, open_in_background);
  204. if (window)
  205. if (window->OpenURL(url_name, check_if_expired, TRUE, FALSE, FALSE, entered_by_user == WasEnteredByUser) == OpStatus::ERR_NO_MEMORY)
  206. return NULL;
  207. return window;
  208. }
  209. Window* WindowManager::OpenURLNewWindow(const uni_char* url_name, BOOL check_if_expired, BOOL3 open_in_new_window, EnteredByUser entered_by_user)
  210. {
  211. BOOL3 open_in_background = MAYBE;
  212. Window* window;
  213. window = GetAWindow(TRUE, open_in_new_window, open_in_background);
  214. if (window)
  215. {
  216. if (window->OpenURL(url_name, check_if_expired, TRUE, FALSE, FALSE, (open_in_background==YES),entered_by_user) == OpStatus::ERR_NO_MEMORY)
  217. return NULL;
  218. }
  219. return window;
  220. }
  221. BOOL WindowManager::CheckTargetSecurity(FramesDocument *source_doc, FramesDocument *target_doc)
  222. {
  223. BOOL permitted;
  224. DOM_Runtime *source_runtime = DOM_Utils::GetDOM_Runtime(source_doc->GetESRuntime());
  225. DOM_Runtime *target_runtime = DOM_Utils::GetDOM_Runtime(target_doc->GetESRuntime());
  226. if (source_runtime)
  227. {
  228. if (target_runtime)
  229. OpSecurityManager::CheckSecurity(OpSecurityManager::DOM_STANDARD, source_runtime, target_runtime, permitted);
  230. else
  231. OpSecurityManager::CheckSecurity(OpSecurityManager::DOM_STANDARD, OpSecurityContext(source_runtime), OpSecurityContext(target_doc->GetSecurityContext()), permitted);
  232. }
  233. else
  234. {
  235. OpSecurityManager::CheckSecurity(OpSecurityManager::DOM_STANDARD, source_doc->GetSecurityContext(), target_doc->GetSecurityContext(), permitted);
  236. }
  237. return permitted;
  238. }
  239. OP_STATUS WindowManager::OpenURLNamedWindow(URL url, Window* load_window, FramesDocument* doc, int sub_win_id, const uni_char* window_name, BOOL user_initiated, BOOL open_in_other_window, BOOL open_in_background, BOOL delay_open, BOOL open_in_page, ES_Thread *thread, BOOL plugin_unrequested_popup)
  240. {
  241. OP_ASSERT(doc);
  242. Window* window = load_window;
  243. FramesDocument* top_doc = doc ? doc->GetTopDocument() : NULL;
  244. FramesDocument* frame_doc = (sub_win_id == -1) ? doc : top_doc->GetSubDocWithId(sub_win_id);
  245. DocumentReferrer origin_url;
  246. if (frame_doc)
  247. origin_url = DocumentReferrer(frame_doc);
  248. BOOL check_origin = FALSE;
  249. if (thread)
  250. {
  251. ES_ThreadInfo info = thread->GetOriginInfo();
  252. if (info.is_user_requested)
  253. {
  254. open_in_other_window = open_in_other_window || info.open_in_new_window;
  255. open_in_background = open_in_background || info.open_in_background;
  256. if (open_in_other_window)
  257. thread->SetOpenInNewWindow();
  258. if (open_in_background)
  259. thread->SetOpenInBackground();
  260. }
  261. else
  262. open_in_background = FALSE;
  263. }
  264. if (url.Type() == URL_JAVASCRIPT && (window && window->IsMailOrNewsfeedWindow() || origin_url.url.GetAttribute(URL::KSuppressScriptAndEmbeds, TRUE) == MIME_EMail_ScriptEmbed_Restrictions))
  265. /* Don't load javascript URLs clicked in mail or news feed views. */
  266. return OpStatus::OK;
  267. #ifdef GADGET_SUPPORT
  268. if ((sub_win_id == -1 || window_name) && window && window->GetGadget() && // For gadgets ...
  269. url.Type() != URL_JAVASCRIPT && // ... handle javascript normally ...
  270. url.Type() != URL_MAILTO && url.Type() != URL_TEL) // ... as well as mailto/tel.
  271. { // Everything else is handled specially.
  272. // Store these in so that we can reset them if not handled here
  273. int old_sub_win_id = sub_win_id;
  274. const uni_char* old_window_name = window_name;
  275. if (frame_doc)
  276. frame_doc->FindTarget(window_name, sub_win_id);
  277. BOOL is_internal_link = origin_url.url.SameServer(url);
  278. // this combination is true only if target is top, or target is a parent which is top frame:
  279. BOOL target_is_top = (!window_name && sub_win_id == -1);
  280. BOOL target_is_sub_window = sub_win_id >= 0;
  281. if ((is_internal_link && !window->GetGadget()->IsExtension()) && ((!target_is_top && !target_is_sub_window) || open_in_other_window || open_in_background))
  282. return OpStatus::OK; // Ignore internal links which try to open new window (but allow it in extensions).
  283. if ((!is_internal_link && target_is_top) || sub_win_id == -2 || (target_is_top && url.Type() == URL_DATA))
  284. {
  285. load_window->GetGadget()->OpenURLInNewWindow(url);
  286. return OpStatus::OK;
  287. }
  288. sub_win_id = old_sub_win_id;
  289. window_name = old_window_name;
  290. }
  291. #endif // GADGET_SUPPORT
  292. if (load_window->GetOutputAssociatedWindow())
  293. {
  294. window = load_window->GetOutputAssociatedWindow();
  295. sub_win_id = -1;
  296. }
  297. else
  298. {
  299. if (open_in_other_window && !DocumentManager::IsSpecialURL(url)) // types that will open a window anyway and will not use a window opened here for anything
  300. {
  301. if (thread || plugin_unrequested_popup)
  302. {
  303. OP_STATUS status = DOM_Environment::OpenURLWithTarget(url, origin_url, NULL, doc, thread, user_initiated, plugin_unrequested_popup);
  304. if (status == OpStatus::ERR_NO_MEMORY || status == OpStatus::OK)
  305. return status;
  306. }
  307. if (delay_open)
  308. window = NULL;
  309. else
  310. {
  311. BOOL3 open_in_new_window = YES;
  312. BOOL3 open_in_background_window = open_in_background ? YES : MAYBE;
  313. Window* new_window = g_windowManager->GetAWindow(TRUE, open_in_new_window, open_in_background_window, 0, 0, FALSE, MAYBE, MAYBE, NULL, NULL, open_in_page, load_window);
  314. if (new_window)
  315. {
  316. window = new_window;
  317. sub_win_id = -1;
  318. }
  319. }
  320. }
  321. else if (origin_url.url.GetAttribute(URL::KType) == URL_ATTACHMENT && origin_url.url.GetAttribute(URL::KSuppressScriptAndEmbeds, TRUE) == MIME_EMail_ScriptEmbed_Restrictions && url.GetAttribute(URL::KType) != URL_ATTACHMENT)
  322. // Links opened from attachment URLs (files which have been MIME decoded
  323. // and hence has a URL on the form attachment:<something>) should
  324. // always open in top frame, unless it's another attachment you try opening.
  325. // This only affect mail/newsfeeds and similar, not MHTML that hasn't got the
  326. // suppress flag set.
  327. {
  328. sub_win_id = -1;
  329. }
  330. else if (window_name && !DocumentManager::IsSpecialURL(url)) // some types are not meaningful to open in named windows and will only leave us with an empty window
  331. {
  332. if (frame_doc)
  333. frame_doc->FindTarget(window_name, sub_win_id);
  334. // this combination is true only if target is top, or target is a parent which is top frame:
  335. BOOL target_is_top = (!window_name && sub_win_id == -1);
  336. if (window_name)
  337. window = GetNamedWindow(load_window, window_name, sub_win_id, !delay_open);
  338. else if (sub_win_id == -2 && delay_open)
  339. {
  340. if (!g_pcdoc->GetIntegerPref(PrefsCollectionDoc::IgnoreTarget)
  341. && !g_pcdoc->GetIntegerPref(PrefsCollectionDoc::SingleWindowBrowsing))
  342. window = NULL;
  343. else
  344. sub_win_id = -1;
  345. }
  346. if (window)
  347. check_origin = !target_is_top; // if target is _top we don't need to check origin
  348. else if (load_window->GetType() == WIN_TYPE_NORMAL)
  349. {
  350. OP_STATUS status = DOM_Environment::OpenURLWithTarget(url, origin_url, window_name, doc, thread, user_initiated, plugin_unrequested_popup);
  351. if (status == OpStatus::ERR_NO_MEMORY || status == OpStatus::OK)
  352. return status;
  353. }
  354. }
  355. }
  356. // If we're loading inside MHTML and target the dummy <object>, retarget it to the real document.
  357. if (sub_win_id != -1)
  358. {
  359. if (FramesDocument* target_doc = top_doc->GetSubDocWithId(sub_win_id))
  360. {
  361. if (target_doc->GetURL().Type() == URL_ATTACHMENT)
  362. {
  363. if (FramesDocument* target_parent = target_doc->GetParentDoc())
  364. {
  365. URL target_parent_url = target_parent->GetURL();
  366. if (target_parent_url.Type() != URL_ATTACHMENT &&
  367. target_parent->IsGeneratedByOpera())
  368. {
  369. sub_win_id = target_parent->GetSubWinId();
  370. }
  371. }
  372. }
  373. }
  374. }
  375. // Check to see if the target is legal, we don't want to allow just any page
  376. // to alter just any other page.
  377. if (check_origin)
  378. {
  379. FramesDocument *current_doc = window->GetCurrentDoc();
  380. FramesDocElm *fdelm = current_doc ? current_doc->GetFrmDocElm(sub_win_id) : NULL;
  381. if (fdelm)
  382. current_doc = fdelm->GetCurrentDoc();
  383. /* Implementation of "allowed to navigate" check as described in HTML5:
  384. http://dev.w3.org/html5/spec/Overview.html#allowed-to-navigate */
  385. BOOL allow = !current_doc || WindowManager::CheckTargetSecurity(doc, current_doc);
  386. if (!allow)
  387. if (FramesDocument *parent_doc = current_doc->GetParentDoc())
  388. do
  389. if (WindowManager::CheckTargetSecurity(doc, parent_doc))
  390. {
  391. allow = TRUE;
  392. break;
  393. }
  394. while ((parent_doc = parent_doc->GetParentDoc()) != NULL);
  395. else if (FramesDocument *opener_doc = window->GetOpener(FALSE))
  396. if (WindowManager::CheckTargetSecurity(doc, opener_doc))
  397. allow = TRUE;
  398. if (!allow)
  399. {
  400. // the origin checks failed so we don't allow opening in the named window
  401. if (url.Type() == URL_JAVASCRIPT)
  402. {
  403. window = load_window;
  404. sub_win_id = frame_doc ? frame_doc->GetSubWinId() : -1;
  405. open_in_other_window = TRUE;
  406. }
  407. else
  408. {
  409. OP_STATUS status = DOM_Environment::OpenURLWithTarget(url, origin_url, window_name, doc, thread);
  410. if (status == OpStatus::ERR_NO_MEMORY || status == OpStatus::OK)
  411. return status;
  412. BOOL3 open_in_new_window = YES;
  413. BOOL3 open_in_background_window = open_in_background ? YES : MAYBE;
  414. # if defined MSWIN
  415. PopupDestination popup_destination = (enum PopupDestination) g_pcjs->GetIntegerPref(PrefsCollectionJS::TargetDestination, current_doc ? current_doc->GetURL().GetServerName() : NULL);
  416. /* Qt will activate a new popup window at once so unfortunately we
  417. can not let a background image open its popup windows in the
  418. background as well because some pages will open more than one
  419. popup window. (espen 2001-10-03) */
  420. switch (popup_destination)
  421. {
  422. case POPUP_WIN_IGNORE:
  423. case POPUP_WIN_BACKGROUND:
  424. open_in_background_window = YES;
  425. break;
  426. }
  427. # endif // MSWIN
  428. Window* new_window = g_windowManager->GetAWindow(TRUE, open_in_new_window, open_in_background_window, 0, 0, FALSE, MAYBE, MAYBE, NULL, NULL, FALSE, load_window);
  429. if (new_window)
  430. {
  431. window = new_window;
  432. sub_win_id = -1;
  433. }
  434. }
  435. }
  436. }
  437. // clicking on links in mail window should always open new window
  438. if (window && !window->IsMailOrNewsfeedWindow())
  439. {
  440. DocumentManager* doc_man = window->GetDocManagerById(sub_win_id);
  441. FramesDocument* frm_doc = doc_man ? doc_man->GetCurrentDoc() : NULL;
  442. if (doc_man)
  443. doc_man->StoreRequestThreadInfo(thread);
  444. if (url.Type() == URL_JAVASCRIPT && frm_doc)
  445. {
  446. DocumentManager::OpenURLOptions options;
  447. options.user_initiated = FALSE;
  448. options.entered_by_user = NotEnteredByUser;
  449. options.is_walking_in_history = FALSE;
  450. options.origin_thread = thread;
  451. RETURN_IF_MEMORY_ERROR(frm_doc->ESOpenURL(url, origin_url, FALSE, FALSE, FALSE, options, !thread || thread->IsUserRequested(), open_in_other_window));
  452. return OpStatus::OK;
  453. }
  454. else if (delay_open)
  455. {
  456. if (doc_man)
  457. {
  458. doc_man->SetUrlLoadOnCommand(url, origin_url, FALSE, user_initiated, thread);
  459. doc_man->GetMessageHandler()->PostMessage(MSG_URL_LOAD_NOW, url.Id(TRUE), user_initiated);
  460. }
  461. }
  462. else
  463. window->GetClickedURL(url, origin_url, sub_win_id, user_initiated, open_in_background);
  464. }
  465. else
  466. if (delay_open)
  467. {
  468. OpenUrlInNewWindowInfo* info;
  469. // We should not use the same context ids as mail context ids when opening links from a mail
  470. // it can cause all sorts of weird behaviour, e.g. DSK-248618.
  471. // When shift-clicking, window == NULL, so we have to check the load_window instead
  472. open_in_background = open_in_other_window && open_in_background;
  473. if (((window && window->IsMailOrNewsfeedWindow()) || (load_window && load_window->IsMailOrNewsfeedWindow()))
  474. && url.Type() != URL_ATTACHMENT)
  475. {
  476. URL context_id_free_url = g_url_api->GetURL(url.GetAttribute(URL::KUniName_With_Fragment_Username_Password_Escaped_NOT_FOR_UI));
  477. info = OP_NEW(OpenUrlInNewWindowInfo, (context_id_free_url, origin_url, window_name, open_in_background, user_initiated, load_window ? load_window->Id() : 0, frame_doc ? frame_doc->GetSubWinId() : 0, open_in_page));
  478. }
  479. else
  480. info = OP_NEW(OpenUrlInNewWindowInfo, (url, origin_url, window_name, open_in_background, user_initiated, load_window ? load_window->Id() : 0, frame_doc ? frame_doc->GetSubWinId() : 0, open_in_page));
  481. if (info == NULL)
  482. return OpStatus::ERR_NO_MEMORY;
  483. g_main_message_handler->PostMessage(MSG_OPEN_URL_IN_NEW_WINDOW, 0, reinterpret_cast<MH_PARAM_2>(info));
  484. }
  485. return OpStatus::OK;
  486. }
  487. // Returns NULL on OOM
  488. Window* WindowManager::AddWindow(OpWindow* opWindow, OpWindowCommander* opWindowCommander)
  489. {
  490. Window *newWin = OP_NEW(Window, (++idcounter, opWindow, opWindowCommander));
  491. if (newWin == NULL || OpStatus::IsError(newWin->Construct()))
  492. {
  493. OP_DELETE(newWin);
  494. return NULL;
  495. }
  496. newWin->Into(&win_list);
  497. #ifdef SCOPE_WINDOW_MANAGER_SUPPORT
  498. OpScopeWindowListener::OnNewWindow(newWin);
  499. #endif // SCOPE_WINDOW_MANAGER_SUPPORT
  500. return newWin;
  501. }
  502. void WindowManager::DeleteWindow(Window* window)
  503. {
  504. if (window)
  505. {
  506. if (window == curr_clicked_window)
  507. curr_clicked_window = NULL;
  508. for (Window* ww = FirstWindow(); ww; ww = ww->Suc())
  509. {
  510. if (ww->GetOutputAssociatedWindow() == window)
  511. ww->SetOutputAssociatedWindow(NULL);
  512. if (ww->GetOpenerWindow() == window)
  513. ww->SetOpener(NULL, -1, TRUE);
  514. }
  515. #ifdef _PRINT_SUPPORT_
  516. if (window->GetPreviewMode())
  517. {
  518. // Leave print preview mode, to avoid memory leak.
  519. window->TogglePrintMode(TRUE);
  520. }
  521. #endif // _PRINT_SUPPORT_
  522. #ifdef WEBSERVER_SUPPORT
  523. if (g_webserver)
  524. g_webserver->windowClosed(window->Id());
  525. #endif // WEBSERVER_SUPPORT
  526. #ifdef ABOUT_HTML_DIALOGS
  527. HTML_Dialog *dlg = g_html_dialog_manager->FindDialog(window);
  528. if (dlg)
  529. dlg->CloseDialog();
  530. #endif // ABOUT_HTML_DIALOGS
  531. window->Out();
  532. #ifdef SCOPE_WINDOW_MANAGER_SUPPORT
  533. OpScopeWindowListener::OnWindowRemoved(window);
  534. #endif // SCOPE_WINDOW_MANAGER_SUPPORT
  535. OP_DELETE(window);
  536. }
  537. g_memory_manager->CheckDocMemorySize();
  538. }
  539. Window* WindowManager::GetWindow(unsigned long nid)
  540. {
  541. for (Window* w = FirstWindow(); w; w = w->Suc())
  542. if (w->Id() == nid)
  543. return w;
  544. return NULL;
  545. }
  546. void WindowManager::Insert(Window* window, Window* precede)
  547. {
  548. window->Out();
  549. if (precede)
  550. window->Precede(precede);
  551. else
  552. window->Into(&win_list);
  553. }
  554. const uni_char* WindowManager::GetPopupMessage(ST_MESSAGETYPE *strType)
  555. {
  556. if(strType)
  557. *strType = messageStringType;
  558. const uni_char *szResult = (current_popup_message[0] ? current_popup_message : NULL);
  559. return szResult;
  560. }
  561. void WindowManager::SetPopupMessage(const uni_char *msg, BOOL fStatusLineOnly, ST_MESSAGETYPE strType)
  562. {
  563. if (msg && !uni_strcmp(msg, current_popup_message))
  564. return;
  565. current_popup_message_statusline_only = fStatusLineOnly;
  566. messageStringType = strType;
  567. if (msg)
  568. uni_strncpy(current_popup_message, msg, 4096);
  569. else
  570. current_popup_message[0] = 0;
  571. current_popup_message[4095] = 0; // Ensures that the string is always null terminated.
  572. }
  573. OP_STATUS WindowManager::UpdateWindows(BOOL /* unused = FALSE */)
  574. {
  575. for (Window* w = FirstWindow(); w; w = w->Suc())
  576. w->UpdateWindow();
  577. return OpStatus::OK;
  578. }
  579. OP_STATUS WindowManager::UpdateWindowsAllDocuments(BOOL /* unused = FALSE */)
  580. {
  581. for (Window* w = FirstWindow(); w; w = w->Suc())
  582. w->UpdateWindowAllDocuments();
  583. return OpStatus::OK;
  584. }
  585. OP_STATUS WindowManager::UpdateAllWindowDefaults(BOOL scroll, BOOL progress, BOOL news, WORD scale, BOOL size)
  586. {
  587. BOOL failed = FALSE;
  588. for (Window *w = FirstWindow(); w; w = w->Suc())
  589. {
  590. if (w->HasFeature(WIN_FEATURE_NAVIGABLE)) // document windows
  591. if (OpStatus::IsError(w->UpdateWindowDefaults(scroll, progress, news, scale, size)))
  592. failed = TRUE;
  593. }
  594. return failed ? OpStatus::ERR_NO_MEMORY : OpStatus::OK;
  595. }
  596. Window* WindowManager::SignalNewWindow(Window* opener, int width, int height, BOOL3 scrollbars, BOOL3 toolbars, BOOL3 focus_document, BOOL3 open_background, BOOL opened_by_script)
  597. {
  598. OP_STATUS status = OpStatus::OK;
  599. BOOL wic_focusdoc = focus_document == NO ? FALSE : TRUE;
  600. BOOL wic_openback = (open_background == NO || open_background == MAYBE) ? FALSE : TRUE;
  601. WindowCommander* opener_wic = opener ? opener->GetWindowCommander() : NULL;
  602. WindowCommander* windowCommander;
  603. windowCommander = OP_NEW(WindowCommander, ());
  604. if (windowCommander == NULL)
  605. {
  606. g_memory_manager->RaiseCondition(OpStatus::ERR_NO_MEMORY);
  607. return NULL;
  608. }
  609. status = windowCommander->Init();
  610. if (OpStatus::IsError(status))
  611. {
  612. if (OpStatus::IsMemoryError(status))
  613. {
  614. g_memory_manager->RaiseCondition(status);
  615. }
  616. OP_DELETE(windowCommander);
  617. return NULL;
  618. }
  619. BOOL show_scrollbars = scrollbars != NO;
  620. if (scrollbars == MAYBE)
  621. show_scrollbars = g_pcdoc->GetIntegerPref(PrefsCollectionDoc::ShowScrollbars);
  622. status = g_windowCommanderManager->GetUiWindowListener()->CreateUiWindow(
  623. windowCommander, opener_wic,
  624. width, height,
  625. ( show_scrollbars ? OpUiWindowListener::CREATEFLAG_SCROLLBARS : OpUiWindowListener::CREATEFLAG_NO_FLAGS ) |
  626. ( toolbars ? OpUiWindowListener::CREATEFLAG_TOOLBARS : OpUiWindowListener::CREATEFLAG_NO_FLAGS ) |
  627. ( wic_focusdoc ? OpUiWindowListener::CREATEFLAG_FOCUS_DOCUMENT : OpUiWindowListener::CREATEFLAG_NO_FLAGS ) |
  628. ( wic_openback ? OpUiWindowListener::CREATEFLAG_OPEN_BACKGROUND : OpUiWindowListener::CREATEFLAG_NO_FLAGS ) |
  629. ( opened_by_script ? OpUiWindowListener::CREATEFLAG_OPENED_BY_SCRIPT : OpUiWindowListener::CREATEFLAG_NO_FLAGS ) |
  630. OpUiWindowListener::CREATEFLAG_USER_INITIATED
  631. );
  632. // get the Window* that was created with help from the windowCommander
  633. if (OpStatus::IsSuccess(status))
  634. {
  635. for (Window* w = FirstWindow(); w; w = w->Suc())
  636. {
  637. if (w->GetWindowCommander() == windowCommander)
  638. {
  639. if (opener)
  640. {
  641. // If the opener window is private, set the new as private too.
  642. if (opener->GetPrivacyMode())
  643. w->SetPrivacyMode(TRUE);
  644. #ifdef WEB_TURBO_MODE
  645. // Inherit turbo mode from opener window alt. global setting
  646. BOOL use_turbo;
  647. if (opener->GetType() == WIN_TYPE_NORMAL)
  648. use_turbo = opener->GetTurboMode();
  649. else
  650. use_turbo = g_pcnet->GetIntegerPref(PrefsCollectionNetwork::UseWebTurbo);
  651. w->SetTurboMode(use_turbo);
  652. #endif // WEB_TURBO_MODE
  653. }
  654. return w;
  655. }
  656. }
  657. }
  658. if (OpStatus::IsMemoryError(status))
  659. {
  660. g_memory_manager->RaiseCondition(status);
  661. }
  662. // failed, so clean up.
  663. OP_DELETE(windowCommander);
  664. return NULL;
  665. }
  666. void WindowManager::CloseWindow(Window *window)
  667. {
  668. g_windowCommanderManager->GetUiWindowListener()->CloseUiWindow(window->GetWindowCommander());
  669. }
  670. Window* WindowManager::GetAWindow(BOOL unused1, BOOL3 new_window, BOOL3 background,
  671. int width /*= 0 */, int height /*= 0*/,
  672. BOOL unused2, /*=FALSE*/
  673. BOOL3 scrollbars, /*=MAYBE*/
  674. BOOL3 toolbars, /*=MAYBE*/
  675. const uni_char* unused3 /*= NULL*/,
  676. const uni_char* unused4 /* = NULL */,
  677. BOOL unused5, /*=FALSE*/
  678. Window* opener /* = NULL */
  679. )
  680. {
  681. OP_ASSERT(new_window == YES || new_window == MAYBE);
  682. #ifdef QUICK
  683. Window* active_window = opener ? opener : g_application->GetActiveWindow();
  684. #ifdef GADGET_SUPPORT
  685. if (opener && opener->GetOpWindow() && ((OpWindow *)opener->GetOpWindow())->GetStyle() == OpWindow::STYLE_GADGET)
  686. {
  687. // Anything opened from a gadget should use a new window if possible
  688. new_window = YES;
  689. if (!g_pcdoc->GetIntegerPref(PrefsCollectionDoc::NewWindow))
  690. {
  691. // Can we reuse an existing window?
  692. DesktopWindow* desktop_window = (DesktopWindow *)g_application->GetActiveBrowserDesktopWindow();
  693. if (desktop_window && desktop_window->GetWindowCommander())
  694. {
  695. active_window = desktop_window->GetWindowCommander()->GetWindow();
  696. new_window = MAYBE;
  697. }
  698. }
  699. }
  700. #endif // GADGET_SUPPORT
  701. if (new_window == MAYBE && !g_pcdoc->GetIntegerPref(PrefsCollectionDoc::NewWindow))
  702. if (active_window && !active_window->IsCustomWindow())
  703. return active_window;
  704. return SignalNewWindow(active_window, width, height, scrollbars, toolbars, YES, background);
  705. #else
  706. return SignalNewWindow(opener, width, height, scrollbars, toolbars, YES, background);
  707. #endif
  708. }
  709. #ifdef MSWIN
  710. Window* WindowManager::GetADDEIdWindow(DWORD id, BOOL &tile_now) // tile_now (in or out) : autotile
  711. {
  712. Window* dde_window = NULL;
  713. for (Window* window = FirstWindow(); window; window = window->Suc())
  714. if (id == window->Id() && !window->IsCustomWindow())
  715. {
  716. dde_window = window;
  717. tile_now = TRUE;
  718. }
  719. return dde_window;
  720. }
  721. #endif
  722. void WindowManager::SetGlobalImagesSetting(SHOWIMAGESTATE set)
  723. {
  724. for (Window *welm = FirstWindow(); welm; welm = welm->Suc())
  725. welm->SetImagesSetting(set);
  726. }
  727. void WindowManager::ReloadAll()
  728. {
  729. for (Window *w = FirstWindow(); w; w = w->Suc())
  730. w->Reload(WasEnteredByUser);
  731. }
  732. void WindowManager::RefreshAll()
  733. {
  734. for (Window *w = FirstWindow(); w; w = w->Suc())
  735. {
  736. OpStatus::Ignore(w->DocManager()->UpdateCurrentDoc(FALSE, FALSE, TRUE));//FIXME:OOM
  737. }
  738. }
  739. void WindowManager::PrefChanged(OpPrefsCollection::Collections id, int pref, int newvalue)
  740. {
  741. switch (id)
  742. {
  743. case OpPrefsCollection::Doc:
  744. if (pref == PrefsCollectionDoc::ShowImageState)
  745. SetGlobalImagesSetting((SHOWIMAGESTATE) newvalue);
  746. break;
  747. case OpPrefsCollection::Display:
  748. switch (pref)
  749. {
  750. #ifdef SUPPORT_TEXT_DIRECTION
  751. case PrefsCollectionDisplay::RTLFlipsUI:
  752. #endif // SUPPORT_TEXT_DIRECTION
  753. case PrefsCollectionDisplay::LeftHandedUI:
  754. UpdateWindows();
  755. }
  756. break;
  757. }
  758. }
  759. void WindowManager::HandleCallback(OpMessage msg, MH_PARAM_1 par1, MH_PARAM_2 par2)
  760. {
  761. if (msg == MSG_OPEN_URL_IN_NEW_WINDOW)
  762. {
  763. // info is never null here, we make sure of that when we send
  764. // this message to ourself.
  765. OpenUrlInNewWindowInfo* info = reinterpret_cast<OpenUrlInNewWindowInfo*>(par2);
  766. BOOL3 open_in_new_window = YES;
  767. BOOL3 open_in_background = info->open_in_background_window?YES:MAYBE;
  768. Window* new_window = GetAWindow(TRUE, open_in_new_window, open_in_background, 0, 0, FALSE, MAYBE, MAYBE, NULL, NULL, info->open_in_page, GetWindow(info->opener_id));
  769. if (new_window)
  770. {
  771. Window* opener = GetWindow(info->opener_id);
  772. if (opener)
  773. {
  774. // Copy settings from opening window
  775. new_window->SetCSSMode(opener->GetCSSMode());
  776. new_window->SetScale(opener->GetScale());
  777. new_window->SetTextScale(opener->GetTextScale());
  778. // Bug#128887: Use the force encoding for the target URL.
  779. #ifdef PREFS_HOSTOVERRIDE
  780. const OpStringC force_encoding(g_pcdisplay->GetStringPref(PrefsCollectionDisplay::ForceEncoding, info->new_url));
  781. if (!force_encoding.IsEmpty())
  782. {
  783. char sbencoding[128]; /* ARRAY OK 2008-02-28 peter */
  784. uni_cstrlcpy(sbencoding, force_encoding.CStr(), ARRAY_SIZE(sbencoding));
  785. new_window->SetForceEncoding(sbencoding);
  786. }
  787. else
  788. #endif
  789. {
  790. new_window->SetForceEncoding(g_pcdisplay->GetForceEncoding());
  791. }
  792. new_window->SetERA_Mode(opener->GetERA_Mode());
  793. BOOL show_img = opener->ShowImages();
  794. BOOL load_img = opener->LoadImages();
  795. if (load_img && show_img)
  796. new_window->SetImagesSetting(FIGS_ON);
  797. else
  798. if (show_img)
  799. new_window->SetImagesSetting(FIGS_SHOW);
  800. else
  801. new_window->SetImagesSetting(FIGS_OFF);
  802. if (!new_window->GetOpener())
  803. {
  804. BOOL allow_js_access_to_opener = TRUE;
  805. #ifdef WEBSERVER_SUPPORT
  806. allow_js_access_to_opener = !info->ref_url.url.GetAttribute(URL::KIsUniteServiceAdminURL);
  807. #endif // WEBSERVER_SUPPORT
  808. new_window->SetOpener(opener, info->opener_sub_win_id, allow_js_access_to_opener);
  809. }
  810. }
  811. if (info->window_name)
  812. new_window->SetName(info->window_name);
  813. OP_STATUS ret = new_window->OpenURL(info->new_url, info->ref_url, TRUE, FALSE, -1, info->user_initiated, info->open_in_background_window);
  814. if (OpStatus::IsError(ret))
  815. g_memory_manager->RaiseCondition(ret);
  816. }
  817. OP_DELETE(info);
  818. }
  819. else if (msg == MSG_ES_CLOSE_WINDOW)
  820. {
  821. Window *window = GetWindow(par2);
  822. if (window)
  823. window->Close();
  824. }
  825. }
  826. void WindowManager::AddDocumentWithBlink()
  827. {
  828. OP_ASSERT(m_documents_having_blink >= 0);
  829. if (m_documents_having_blink == 0)
  830. m_blink_timer_listener.SetEnabled(TRUE);
  831. m_documents_having_blink++;
  832. }
  833. void WindowManager::RemoveDocumentWithBlink()
  834. {
  835. OP_ASSERT(m_documents_having_blink > 0);
  836. m_documents_having_blink--;
  837. if (m_documents_having_blink == 0)
  838. m_blink_timer_listener.SetEnabled(FALSE);
  839. }
  840. #ifdef _OPERA_DEBUG_DOC_
  841. unsigned WindowManager::GetActiveDocumentCount()
  842. {
  843. unsigned count = 0;
  844. for (Window *w = FirstWindow(); w; w = w->Suc())
  845. {
  846. DocumentTreeIterator it(w);
  847. it.SetIncludeThis();
  848. while (it.Next())
  849. count++;
  850. }
  851. return count;
  852. }
  853. #endif // _OPERA_DEBUG_DOC_
  854. OP_STATUS WindowManager::OnlineModeChanged()
  855. {
  856. OP_STATUS status = OpStatus::OK;
  857. for (Window *w = FirstWindow(); w; w = w->Suc())
  858. if (OpStatus::IsMemoryError(w->DocManager()->OnlineModeChanged()))
  859. {
  860. OpStatus::Ignore(status);
  861. status = OpStatus::ERR_NO_MEMORY;
  862. }
  863. return status;
  864. }
  865. void WindowManager::BlinkTimerListener::PostNewTimerMessage()
  866. {
  867. OP_ASSERT(!m_message_in_queue);
  868. OP_ASSERT(m_is_active);
  869. int milliseconds_between_blinks = 1000;
  870. if (m_timer) // Might be NULL if OOM
  871. m_timer->Start(milliseconds_between_blinks);
  872. m_message_in_queue = TRUE;
  873. }
  874. WindowManager::BlinkTimerListener::BlinkTimerListener() :
  875. m_is_active(FALSE),
  876. m_message_in_queue(FALSE)
  877. {
  878. OP_STATUS status = OpStatus::OK;
  879. m_timer = OP_NEW(OpTimer, ());
  880. if (!m_timer)
  881. status = OpStatus::ERR_NO_MEMORY;
  882. if (OpStatus::IsError(status))
  883. {
  884. OP_ASSERT(FALSE);
  885. // Have no idea how to handle this. If posting the
  886. // message fails, we will not get called again, and opera won't
  887. // have blinking elements. Tragedy!
  888. g_memory_manager->RaiseCondition(status);//FIXME:OOM At least we can
  889. //tell the memory manager
  890. m_timer = NULL;
  891. return;
  892. }
  893. m_timer->SetTimerListener(this);
  894. OP_ASSERT(m_timer);
  895. }
  896. WindowManager::BlinkTimerListener::~BlinkTimerListener()
  897. {
  898. OP_DELETE(m_timer);
  899. }
  900. /* virtual */
  901. void WindowManager::BlinkTimerListener::OnTimeOut(OpTimer* timer)
  902. {
  903. OP_ASSERT(m_message_in_queue);
  904. OP_ASSERT(timer);
  905. OP_ASSERT(timer == m_timer);
  906. m_message_in_queue = FALSE;
  907. if (m_is_active)
  908. PostNewTimerMessage();
  909. // Turn the text on off on off on off on off
  910. g_opera->layout_module.m_blink_on = !g_opera->layout_module.m_blink_on;
  911. for (Window* win = g_windowManager->FirstWindow(); win; win = win->Suc())
  912. {
  913. FramesDocument *doc = win->DocManager()->GetCurrentVisibleDoc();
  914. if (doc && doc->HasBlink())
  915. doc->Blink();
  916. }
  917. }
  918. void WindowManager::BlinkTimerListener::SetEnabled(BOOL enable)
  919. {
  920. if (enable)
  921. {
  922. m_is_active = TRUE;
  923. if (!m_message_in_queue)
  924. PostNewTimerMessage();
  925. }
  926. else
  927. {
  928. m_is_active = FALSE;
  929. m_message_in_queue = FALSE;
  930. if (m_timer)
  931. m_timer->Stop();
  932. }
  933. }
  934. URL_CONTEXT_ID WindowManager::AddWindowToPrivacyModeContext()
  935. {
  936. m_number_of_windows_in_privacy_mode++;
  937. if (!m_number_of_windows_in_privacy_mode || !m_privacy_mode_context_id)
  938. {
  939. m_privacy_mode_context_id = urlManager->GetNewContextID();
  940. if (!m_privacy_mode_context_id)
  941. return 0;
  942. TRAPD(status, (urlManager->AddContextL(m_privacy_mode_context_id
  943. , OPFILE_ABSOLUTE_FOLDER, OPFILE_ABSOLUTE_FOLDER, OPFILE_ABSOLUTE_FOLDER, OPFILE_ABSOLUTE_FOLDER
  944. , FALSE, PrefsCollectionNetwork::DiskCacheSize)));
  945. if (OpStatus::IsError(status))
  946. return 0;
  947. urlManager->SetContextIsRAM_Only(m_privacy_mode_context_id, TRUE);
  948. }
  949. return m_privacy_mode_context_id;
  950. }
  951. void WindowManager::RemoveWindowFromPrivacyModeContext()
  952. {
  953. m_number_of_windows_in_privacy_mode--;
  954. OP_ASSERT(m_number_of_windows_in_privacy_mode >= 0);
  955. if (m_number_of_windows_in_privacy_mode == 0 && m_privacy_mode_context_id)
  956. ExitPrivacyMode();
  957. }
  958. void WindowManager::ExitPrivacyMode()
  959. {
  960. OP_ASSERT(m_number_of_windows_in_privacy_mode == 0);
  961. if (m_privacy_mode_context_id)
  962. {
  963. #ifdef USE_OP_CLIPBOARD
  964. g_clipboard_manager->EmptyClipboard(m_privacy_mode_context_id);
  965. #endif
  966. urlManager->RemoveContext(m_privacy_mode_context_id, TRUE);
  967. m_privacy_mode_context_id = 0;
  968. }
  969. #ifdef SECMAN_USERCONSENT
  970. g_secman_instance->OnExitPrivateMode();
  971. #endif // SECMAN_USERCONSENT
  972. #ifdef WINDOW_COMMANDER_TRANSFER
  973. g_transferManager->RemovePrivacyModeTransfers();
  974. #endif
  975. }
  976. #ifdef WEB_TURBO_MODE
  977. OP_STATUS WindowManager::CheckTuboModeContext()
  978. {
  979. if( m_turbo_mode_context_id )
  980. return OpStatus::OK;
  981. OpFileFolder cache_folder;
  982. RETURN_IF_ERROR(g_folder_manager->AddFolder(OPFILE_CACHE_FOLDER, UNI_L("turbo"),&cache_folder));
  983. m_turbo_mode_context_id = urlManager->GetNewContextID();
  984. if( !m_turbo_mode_context_id )
  985. return OpStatus::ERR;
  986. TRAPD(op_err, urlManager->AddContextL(m_turbo_mode_context_id, OPFILE_ABSOLUTE_FOLDER, OPFILE_COOKIE_FOLDER, cache_folder, cache_folder, TRUE, (int) PrefsCollectionNetwork::DiskCacheSize));
  987. if( OpStatus::IsSuccess(op_err) || OpStatus::IsMemoryError(op_err) )
  988. return op_err;
  989. else
  990. return OpStatus::ERR;
  991. }
  992. #endif // WEB_TURBO_MODE