Opera 12.15 Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

win.h 61KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
  2. **
  3. ** Copyright (C) 1995-2011 Opera Software ASA. All rights reserved.
  4. **
  5. ** This file is part of the Opera web browser. It may not be distributed
  6. ** under any circumstances.
  7. */
  8. #ifndef DOCHAND_WIN_H
  9. #define DOCHAND_WIN_H
  10. #include "modules/display/cursor.h"
  11. #include "modules/doc/css_mode.h"
  12. #include "modules/doc/doctypes.h"
  13. #include "modules/prefs/prefsmanager/prefstypes.h"
  14. #include "modules/url/url2.h"
  15. #include "modules/util/simset.h"
  16. #include "modules/dochand/winman_constants.h"
  17. #include "modules/hardcore/cpuusagetracker/cpuusagetracker.h"
  18. #include "modules/windowcommander/OpWindowCommander.h" // For LoadingInformation
  19. #include "modules/util/OpHashTable.h"
  20. #include "modules/dochand/documentreferrer.h"
  21. #ifdef SUPPORT_VISUAL_ADBLOCK
  22. #include "modules/prefs/prefsmanager/collections/pc_network.h"
  23. #endif // SUPPORT_VISUAL_ADBLOCK
  24. #ifdef _AUTO_WIN_RELOAD_SUPPORT_
  25. # include "modules/hardcore/timer/optimer.h"
  26. #endif // _AUTO_WIN_RELOAD_SUPPORT_
  27. #ifdef USE_OP_CLIPBOARD
  28. # include "modules/dragdrop/clipboard_manager.h"
  29. #endif // USE_OP_CLIPBOARD
  30. class CSS;
  31. class DocumentManager;
  32. class HTML_Document;
  33. class Image;
  34. class LinkElement;
  35. class LinkElementDatabase;
  36. class OpSnHandler;
  37. class OpWindow;
  38. class OpWindowCommander;
  39. class PrinterInfo;
  40. class VisualDevice;
  41. class WindowCommander;
  42. class WindowListener;
  43. class ProgressLine;
  44. class DocListElm;
  45. class DocumentReferrer;
  46. class DocumentOrigin;
  47. class OpGadget;
  48. class SearchData;
  49. class CSSCollection;
  50. class ViewportController;
  51. #ifdef SVG_SUPPORT
  52. class SVGImageRef;
  53. #endif // SVG_SUPPORT
  54. #ifdef SCOPE_PROFILER
  55. class OpProfilingSession;
  56. #endif // SCOPE_PROFILER
  57. #ifdef ABSTRACT_CERTIFICATES
  58. # include "modules/pi/network/OpCertificate.h"
  59. #endif
  60. #if defined _SPAT_NAV_SUPPORT_ && defined SN_LEAVE_SUPPORT
  61. class SnLeaveListener
  62. {
  63. public:
  64. virtual ~SnLeaveListener() {};
  65. virtual void LeaveInDirection(int direction, int x, int y, class OpView *view) = 0;
  66. virtual void LeaveInDirection(int direction) = 0;
  67. };
  68. #endif // _SPAT_NAV_SUPPORT_ && SN_LEAVE_SUPPORT
  69. #define MAX_PROGRESS_MESS_LENGTH 200
  70. #ifdef _AUTO_WIN_RELOAD_SUPPORT_
  71. // user wants to reload the window automatically
  72. class AutoWinReloadParam : public OpTimerListener
  73. {
  74. public:
  75. AutoWinReloadParam (Window* win);
  76. ~AutoWinReloadParam ();
  77. BOOL OnSecTimer ( ); // Returns TRUE if we should reload
  78. void Enable ( BOOL fEnable);
  79. void Toggle ( );
  80. void SetSecUserSetting ( int secUserSetting);
  81. void SetParams ( BOOL fEnable, int secUserSetting, BOOL fOnlyIfExpired, BOOL fUpdatePrefsManager=TRUE);
  82. int GetSecRemaining ( ) const { return m_secRemaining; }
  83. BOOL GetOptIsEnabled ( ) const { return m_fEnabled; }
  84. int GetOptSecUserSetting( ) const { return m_secUserSetting; }
  85. BOOL GetOptOnlyIfExpired ( ) const { return m_fOnlyIfExpired; }
  86. virtual void OnTimeOut(OpTimer* timer);
  87. private:
  88. BOOL m_fEnabled;
  89. int m_secUserSetting; // sec. between each reload
  90. int m_secRemaining; // sec remaining to next reload
  91. BOOL m_fOnlyIfExpired; // only reload if "expired/changed"
  92. OpTimer* m_timer;
  93. Window* m_win;
  94. };
  95. #endif // _AUTO_WIN_RELOAD_SUPPORT_
  96. #ifdef DOM_JIL_API_SUPPORT
  97. /**
  98. * An ScreenPropsChangedListener listens to any change of screen properties
  99. * that current window is displayed on.
  100. */
  101. class ScreenPropsChangedListener
  102. {
  103. public:
  104. /**
  105. * Deletes the ScreenPropsChangedListener.
  106. */
  107. virtual ~ScreenPropsChangedListener() {}
  108. /**
  109. * Called when a screen properties have changes
  110. */
  111. virtual void OnScreenPropsChanged() = 0;
  112. };
  113. #endif //DOM_JIL_API_SUPPORT
  114. class OpenUrlInNewWindowInfo
  115. {
  116. public:
  117. URL new_url;
  118. DocumentReferrer ref_url;
  119. uni_char* window_name;
  120. BOOL open_in_background_window;
  121. BOOL user_initiated;
  122. unsigned long opener_id;
  123. int opener_sub_win_id;
  124. BOOL open_in_page;
  125. OpenUrlInNewWindowInfo(URL& url,
  126. DocumentReferrer refurl,
  127. const uni_char* win_name,
  128. BOOL open_in_bg_win,
  129. BOOL user_init,
  130. unsigned long open_win_id,
  131. int open_sub_win_id,
  132. BOOL open_in_page = FALSE);
  133. ~OpenUrlInNewWindowInfo() { delete [] window_name; }
  134. };
  135. class Window
  136. : public Link,
  137. public MessageObject
  138. #if defined (SHORTCUT_ICON_SUPPORT) && defined (ASYNC_IMAGE_DECODERS)
  139. , public ImageListener
  140. #endif
  141. , public OpDocumentListener::DialogCallback
  142. #ifdef USE_OP_CLIPBOARD
  143. , public ClipboardListener
  144. #endif // USE_OP_CLIPBOARD
  145. {
  146. public:
  147. void SetFeatures(Window_Type type);
  148. BOOL HasFeature(Window_Feature feature);
  149. BOOL HasAllFeatures(Window_Feature feature);
  150. void SetCanClose(BOOL bState) { bCanSelfClose = bState; }
  151. BOOL CanClose() const { return bCanSelfClose; }
  152. void SetCanBeClosedByScript(BOOL flag) { can_be_closed_by_script = flag; }
  153. #ifdef SELFTEST
  154. /**
  155. * Signals to the selftest system that the window is about to close and so
  156. * shouldn't be (re)used.
  157. */
  158. void SetIsAboutToClose(BOOL is_about_to_close)
  159. {
  160. m_is_about_to_close = is_about_to_close;
  161. }
  162. /**
  163. * Returns the state set by SetIsAboutToClose().
  164. */
  165. BOOL IsAboutToClose() const { return m_is_about_to_close; }
  166. #endif // SELFTEST
  167. OpWindowCommander::FullScreenState GetFullScreenState() const { return m_fullscreen_state; }
  168. /**
  169. * @returns ERR_NO_MEMORY on OOM, ERR_NOT_SUPPORTED if the fullscreen
  170. * state was not allowed, otherwise OK.
  171. */
  172. OP_STATUS SetFullScreenState(OpWindowCommander::FullScreenState state);
  173. BOOL IsFullScreen() const { return m_fullscreen_state != OpWindowCommander::FULLSCREEN_NONE; }
  174. OpWindow* GetOpWindow() { return m_opWindow; }
  175. /**
  176. * Returns WindowCommander associated with this window.
  177. * This never returns NULL.
  178. */
  179. WindowCommander* GetWindowCommander() const { return m_windowCommander; }
  180. enum OnlineMode
  181. {
  182. ONLINE,
  183. OFFLINE,
  184. USER_RESPONDING,
  185. DENIED
  186. };
  187. #ifdef SUPPORT_VISUAL_ADBLOCK
  188. // used when in content blocker mode to send mouse clicks to a listener instead of processing them
  189. void SetContentBlockEditMode(BOOL edit_mode) { m_content_block_edit_mode = edit_mode; }
  190. BOOL GetContentBlockEditMode() { return m_content_block_edit_mode; }
  191. // is the content blocker enabled in prefs?
  192. BOOL IsContentBlockerEnabled()
  193. {
  194. if (m_content_block_server_name)
  195. return m_content_block_enabled;
  196. else
  197. return m_content_block_enabled && g_pcnet->GetIntegerPref(PrefsCollectionNetwork::EnableContentBlocker, GetCurrentShownURL().GetServerName()) != 0;
  198. }
  199. // Used when in content blocker mode to be able to load otherwise blocked content
  200. void SetContentBlockEnabled(BOOL enable) { m_content_block_enabled = enable; }
  201. void SetContentBlockServerName(ServerName *server_name)
  202. {
  203. m_content_block_server_name = server_name;
  204. m_content_block_enabled = g_pcnet->GetIntegerPref(PrefsCollectionNetwork::EnableContentBlocker, m_content_block_server_name) != 0;
  205. }
  206. #endif // SUPPORT_VISUAL_ADBLOCK
  207. #ifdef WAND_SUPPORT
  208. void IncrementeWandInProgressCounter() { m_wand_in_progress_count++; } // yes, there is a typo in the name
  209. void DecrementWandInProgressCounter() { OP_ASSERT(m_wand_in_progress_count > 0); m_wand_in_progress_count--; }
  210. #endif // WAND_SUPPORT
  211. /* Sets the OOM occurred state.
  212. *
  213. * When the window is in the OOM occurred state and a new document
  214. * is about to be loaded in it, the current document is unloaded
  215. * first, before the new load is started. It increases the chances
  216. * of a successful load that won't run into OOM immediately, at
  217. * the risk of ending up with a blank page if the load fails for
  218. * some reason.
  219. *
  220. * @param oom TRUE if an OOM has occurred, FALSE to clear.
  221. */
  222. void SetOOMOccurred(BOOL oom) { m_oom_occurred = oom; }
  223. /** Gets the OOM occurred state.
  224. *
  225. * @return TRUE if OOM has occurred, FALSE otherwise.
  226. */
  227. BOOL GetOOMOccurred() { return m_oom_occurred; }
  228. private:
  229. void LowLevelSetSecurityState(BYTE sec, BOOL is_inline, const uni_char *name, URL *url= NULL);
  230. #ifdef SVG_SUPPORT
  231. /**
  232. * Set this SVGImage to be the favicon of the window.
  233. */
  234. OP_STATUS SetSVGAsWindowIcon(SVGImageRef* ref);
  235. public:
  236. /**
  237. * Removes this window's favicon if 'ref' is the window icon.
  238. * Note: ref can be deleted.
  239. */
  240. void RemoveSVGWindowIcon(SVGImageRef* ref);
  241. private:
  242. #endif // SVG_SUPPORT
  243. void SetFeature(Window_Feature feature);
  244. void RemoveFeature(Window_Feature feature);
  245. void SetId(unsigned long nid) {this->id = nid;}
  246. unsigned long m_features;
  247. OnlineMode m_online_mode;
  248. INT32 m_frames_policy;
  249. #ifdef SUPPORT_VISUAL_ADBLOCK
  250. BOOL m_content_block_edit_mode;
  251. BOOL m_content_block_enabled;
  252. ServerName* m_content_block_server_name;
  253. #endif // SUPPORT_VISUAL_ADBLOCK
  254. WindowCommander* m_windowCommander;
  255. LoadingInformation m_loading_information;
  256. VisualDevice* vis_device; // visual device of the window
  257. DocumentManager* doc_manager; // windows document manager
  258. MessageHandler* msg_handler; // windows message handler (handles messages between parts of the code)
  259. uni_char* current_message; // message shown in the status bar
  260. uni_char* current_default_message; // message shown in the status bar (see JS window.defaultStatus)
  261. ProgressState progress_state; // message shown in the status bar
  262. WinState state; // busy, clickable or not busy
  263. #ifndef MOUSELESS
  264. CursorType current_cursor; // current mouse cursor shape
  265. CursorType m_pending_cursor; // used to track cursor values derived from elements as we traverse the document tree towards the target
  266. CursorType cursor_set_by_doc; // mouse cursor last set by document, only relevant if has_cursor_set_by_doc is TRUE
  267. BOOL has_cursor_set_by_doc; // TRUE if doc wants another cursor than the default. See cursor_set_by_doc.
  268. #endif // !MOUSELESS
  269. #ifdef LIBOPERA
  270. int cursor_content; // The content types associated with the current cursor.
  271. #endif // LIBOPERA
  272. URL active_link_url; // URL currently under the mouse pointer
  273. OpWindowCommander::FullScreenState m_fullscreen_state;
  274. OpWindowCommander::FullScreenState m_previous_fullscreen_state; // To workaround printing problems. See Window::StartPrinting().
  275. BOOL m_is_background_transparent;
  276. BOOL m_is_explicit_suppress_window, m_is_implicit_suppress_window;
  277. BOOL m_is_scriptable_window;
  278. BOOL m_is_visible_on_screen; // See setter/getter. Def TRUE
  279. #ifdef _SPAT_NAV_SUPPORT_
  280. OpSnHandler* sn_handler; // Used by spatial navigation
  281. #ifdef SN_LEAVE_SUPPORT
  282. SnLeaveListener * sn_listener; // Listener called when navigating away from the opera window.
  283. #endif // SN_LEAVE_SUPPORT
  284. #endif /* _SPAT_NAV_SUPPORT */
  285. BOOL m_draw_highlight_rects;
  286. BOOL bCanSelfClose;
  287. #ifdef SELFTEST
  288. BOOL m_is_about_to_close;
  289. #endif // SELFTEST
  290. BOOL m_url_came_from_address_field;
  291. #if defined REDIRECT_ON_ERROR || defined AB_ERROR_SEARCH_FORM
  292. OpString m_typed_in_url;
  293. #endif // defined REDIRECT_ON_ERROR || defined AB_ERROR_SEARCH_FORM
  294. BOOL show_img;
  295. #ifdef FIT_LARGE_IMAGES_TO_WINDOW_WIDTH
  296. BOOL fit_img;
  297. #endif // FIT_LARGE_IMAGES_TO_WINDOW_WIDTH
  298. BOOL load_img;
  299. BOOL is_ssr_mode;
  300. BOOL era_mode;
  301. LayoutMode layout_mode;
  302. /* @see SetLimitParagraphWidth */
  303. BOOL limit_paragraph_width;
  304. int flex_root_max_width;
  305. WORD scale;
  306. int m_text_scale;
  307. long progress_count;
  308. OpFileLength doc_progress_count;
  309. OpFileLength upload_total_bytes;
  310. int upload_file_count;
  311. int upload_file_loaded_count;
  312. BOOL phase_uploading;
  313. time_t start_time;
  314. uni_char progress_mess[MAX_PROGRESS_MESS_LENGTH + 1]; /* ARRAY OK 2008-02-28 jl */
  315. uni_char progress_mess_low[MAX_PROGRESS_MESS_LENGTH + 1]; /* ARRAY OK 2008-02-28 jl */
  316. unsigned long OutputAssociatedWindow;
  317. BOOL bShowScrollbars;
  318. unsigned long id;
  319. BOOL loading;
  320. BOOL end_progress_message_sent;
  321. BOOL history_cleanup_message_sent;
  322. BOOL user_load_from_cache;
  323. BOOL pending_unlock_all_painting; /**< Whether we have a message pending that will trigger paint unlock. */
  324. OpStringS name;
  325. #ifdef CPUUSAGETRACKING
  326. CPUUsageTracker cpu_usage_tracker;
  327. #endif // CPUUSAGETRACKING
  328. CSSMODE CSSMode;
  329. BOOL forceColors;
  330. BOOL truezoom;
  331. UINT32 truezoom_base_scale;
  332. BOOL is_something_hovered;
  333. /**< TRUE if the most recent call to either OpDocumentListener::OnHover
  334. or OpDocumentListener::OnNoHover was to OnHover, and FALSE otherwise. */
  335. BOOL ecmascript_disabled;
  336. enum
  337. {
  338. NOT_PAUSED = 0,
  339. PAUSED_PRINTING = 1,
  340. PAUSED_OTHER = 2
  341. };
  342. int ecmascript_paused;
  343. void ResumeEcmaScriptIfNotPaused();
  344. ViewportController* viewportcontroller;
  345. OpStringS8 forceEncoding;
  346. BYTE SecurityState;
  347. /**< Current security state. */
  348. BYTE SecurityState_signalled;
  349. /**< Security state last signalled to UI. */
  350. BOOL SecurityState_changed_by_inline;
  351. /**< The last time SecurityState was changed it was changed because of an
  352. inline element. */
  353. BOOL SecurityState_signal_delayed;
  354. /**< The security state has changed, but we've delayed signalling this to
  355. the UI because we've not started loading a document yet. */
  356. OpStringS SecurityTextName;
  357. BOOL m_privacy_mode;
  358. #ifdef TRUST_RATING
  359. TrustRating m_trust_rating;
  360. #endif
  361. #ifdef WEB_TURBO_MODE
  362. BOOL m_turbo_mode;
  363. #endif // WEB_TURBO_MODE
  364. int currWinHistoryLength;
  365. int current_history_number;
  366. int min_history_number;
  367. int max_history_number;
  368. BOOL check_history;
  369. BOOL is_canceling_loading;
  370. BOOL title_update_title_posted;
  371. OpString title;
  372. BOOL generated_title;
  373. #ifdef SHORTCUT_ICON_SUPPORT
  374. class UrlImageContentProvider* shortcut_icon_provider;
  375. URL m_shortcut_icon_url;
  376. #endif // SHORTCUT_ICON_SUPPORT
  377. char* lastUserName;
  378. char* lastProxyUserName;
  379. OpString homePage;
  380. Window_Type type;
  381. COLORREF default_background_color;
  382. #ifdef _PRINT_SUPPORT_
  383. PrinterInfo* printer_info;
  384. PrinterInfo* preview_printer_info;
  385. BOOL preview_mode;
  386. BOOL print_mode;
  387. DM_PrintType frames_print_type;
  388. /* For asynchronous printing */
  389. BOOL is_formatting_print_doc;
  390. BOOL is_printing;
  391. #endif // _PRINT_SUPPORT_
  392. #ifdef _AUTO_WIN_RELOAD_SUPPORT_
  393. AutoWinReloadParam m_userAutoReload;
  394. #endif // _AUTO_WIN_RELOAD_SUPPORT_
  395. // the window that opened us is specified here
  396. Window* opener;
  397. int opener_sub_win_id;
  398. // if it was opened by script this flag will be set
  399. BOOL is_available_to_script;
  400. DocumentOrigin* opener_origin;
  401. BOOL can_be_closed_by_script;
  402. #if defined SEARCH_MATCHES_ALL
  403. SearchData* m_search_data;
  404. #endif // SEARCH_MATCHES_ALL
  405. BOOL always_load_from_cache;
  406. #ifdef LIBOPERA
  407. // Was the last request initiated by the user?
  408. //
  409. // I'm not 100% happy with this solution, but for LIBOPERA we want to
  410. // emit a noConnection signal if the network is down, except for requests
  411. // that are not initiated by the user. Maybe this information should be
  412. // attached to the Comm object somehow instead? (mstensho)
  413. BOOL m_lastReqUserInitiated;
  414. #endif // LIBOPERA
  415. OpWindow* m_opWindow;
  416. WindowListener *windowlistener;
  417. BOOL m_bWasInFullscreen;
  418. #ifdef ACCESS_KEYS_SUPPORT
  419. BOOL in_accesskey_mode;
  420. #endif // ACCESS_KEYS_SUPPORT
  421. void SetMessageInternal();
  422. unsigned window_locked;
  423. BOOL window_closed;
  424. OpINT32Set already_requested_urls;
  425. BOOL use_already_requested_urls;
  426. BOOL forced_java_disabled;
  427. BOOL forced_plugins_disabled;
  428. BOOL document_word_wrap_forced;
  429. #ifdef WAND_SUPPORT
  430. int m_wand_in_progress_count;
  431. #endif // WAND_SUPPORT
  432. AutoDeleteHead moved_urls;
  433. #ifdef HISTORY_SUPPORT
  434. BOOL m_global_history_enabled;
  435. #endif // HISTORY_SUPPORT
  436. #ifdef NEARBY_ELEMENT_DETECTION
  437. class ElementExpander*
  438. element_expander;
  439. #endif // NEARBY_ELEMENT_DETECTION
  440. #ifdef GRAB_AND_SCROLL
  441. BOOL scroll_is_pan_overridden;
  442. BOOL scroll_is_pan;
  443. #endif // GRAB_AND_SCROLL
  444. /**
  445. * If you cancel a keydown event the corresponding keypress event should be
  446. * automatically cancelled (preventDefaulted) but since we don't have
  447. * enough control of events now we're not able to directly connect
  448. * the keydown and keypress events.
  449. * Instead, we'll remember a cancelled keydown here and if this
  450. * int (keycode) matches that of a keypress, that keypress will
  451. * be cancelled as well. Default value here is OP_KEY_INVALID which means
  452. * "no currently cancelled keydowns". It should be set to OP_KEY_INVALID
  453. * whenever we're reasonably sure there will not come any keypresses
  454. * matching any recent keydowns.
  455. *
  456. * @see SetRecentlyCancelledKeyDown()
  457. * @see HasRecentlyCancelledKeyDown()
  458. */
  459. OpKey::Code recently_cancelled_keydown;
  460. /**
  461. * A top level document has the right to display one download
  462. * dialog even if it was unsolicited. This flag keeps track
  463. * of when it has done that.
  464. */
  465. BOOL has_shown_unsolicited_download_dialog;
  466. #ifdef DOM_JIL_API_SUPPORT
  467. ScreenPropsChangedListener* m_screen_props_listener;
  468. #endif // DOM_JIL_API_SUPPORT
  469. BOOL m_oom_occurred;
  470. /** The ID for the next DocListElm to be created. The ID from the
  471. * window's DocumentManager should always be used.
  472. */
  473. int m_next_doclistelm_id;
  474. #ifdef SCOPE_PROFILER
  475. /**
  476. * When profiling is enabled, this variable will point to the profiling
  477. * session used to create OpProbeTimelines. The OpProbeTimelines will in
  478. * turn record the profiling data for each document in the Window.
  479. *
  480. * The Window does *not* own the OpProfilingSession, and must not delete
  481. * it.
  482. */
  483. OpProfilingSession *m_profiling_session;
  484. #endif // SCOPE_PROFILER
  485. #ifdef KEYBOARD_SELECTION_SUPPORT
  486. /**
  487. * A flag used for sending keyboard selection mode changed events
  488. * to the ui. The mode can change between focusing different
  489. * frames and when walking in history or reloading.
  490. */
  491. BOOL m_current_keyboard_selection_mode;
  492. #endif // KEYBOARD_SELECTION_SUPPORT
  493. #ifdef USE_OP_CLIPBOARD
  494. void OnCopy(OpClipboard*);
  495. void OnCut(OpClipboard*);
  496. void OnPaste(OpClipboard*);
  497. void OnEnd();
  498. #endif // USE_OP_CLIPBOARD
  499. protected:
  500. #if defined(_MACINTOSH_) && defined(_POPUP_MENU_SUPPORT_)
  501. void TrackContextMenu_Macintosh ( unsigned idr_menu, POINT ptWhere);
  502. void TrackLinkMenu_Macintosh ( );
  503. #endif // defined(_MACINTOSH_) && defined(_POPUP_MENU_SUPPORT_)
  504. /**
  505. * Call UpdateWindow() if ssr status of window and doc were not in sync
  506. */
  507. void UpdateWindowIfLayoutChanged();
  508. /**
  509. * Unlocks the VisualDevice paint lock for all documents in this Window.
  510. */
  511. void UnlockPaintLock();
  512. public:
  513. void ClearMessage();
  514. Window(unsigned long nid, OpWindow* opWindow, OpWindowCommander* opWindowCommander);
  515. ~Window();
  516. void ConstructL();
  517. OP_STATUS Construct() { TRAPD(err,ConstructL()); return err; }
  518. BOOL Close(); // return TRUE on success (if a window contains edits, the user can cancel the request to close it)
  519. void SetOpener(Window* opened_by, int sub_win_id, BOOL make_available_to_script = TRUE, BOOL from_window_open = FALSE);
  520. Window* GetOpenerWindow() { return opener; }
  521. FramesDocument* GetOpener(BOOL is_script = TRUE);
  522. URL GetOpenerSecurityContext();
  523. DocumentOrigin* GetOpenerOrigin() { return opener_origin; }
  524. BOOL CanBeClosedByScript() { return can_be_closed_by_script || type != WIN_TYPE_NORMAL; }
  525. #if defined SEARCH_MATCHES_ALL
  526. void ResetSearch();
  527. #endif // SEARCH_MATCHES_ALL
  528. int GetCurrWinHistoryLength() { return currWinHistoryLength; }
  529. int GetCurrentHistoryNumber() {return current_history_number; }
  530. Window* Suc() const { return (Window*) Link::Suc(); }
  531. Window* Pred() const { return (Window*) Link::Pred(); }
  532. VisualDevice* VisualDev() const { return vis_device; }
  533. DocumentManager* DocManager() const { return doc_manager; }
  534. MessageHandler* GetMessageHandler() const { return msg_handler; }
  535. #ifndef MOUSELESS
  536. void SetCursor(CursorType cursor, BOOL set_by_document = FALSE);
  537. void UseDefaultCursor();
  538. void SetCurrentCursor();
  539. CursorType GetCurrentArrowCursor();
  540. /**
  541. * Calculates the current suitable cursor based on the current state and what doc has asked
  542. * for.
  543. */
  544. CursorType GetCurrentCursor();
  545. /**
  546. * Sets a cursor value for tracking, which could probably be used later as the window cursor
  547. */
  548. void SetPendingCursor(const CursorType cur_type) { m_pending_cursor = cur_type; }
  549. /**
  550. * Gets the above cursor value
  551. */
  552. CursorType GetPendingCursor() const { return m_pending_cursor; }
  553. /**
  554. * Sets the pending cursor as the current cursor for the window
  555. * If pending cursor was CURSOR_AUTO will set the default cursor
  556. */
  557. void CommitPendingCursor();
  558. #endif // !MOUSELESS
  559. uni_char* GetMessage() const { return current_message; }
  560. uni_char* GetDefaultMessage() const { return current_default_message; }
  561. OP_STATUS SetMessage(const uni_char* msg);
  562. OP_STATUS SetDefaultMessage(const uni_char* msg);
  563. void DisplayLinkInformation(const URL &link_url, ST_MESSAGETYPE mt = ST_ASTRING, const uni_char *title = NULL);
  564. void DisplayLinkInformation(const uni_char* link, ST_MESSAGETYPE mt = ST_ASTRING, const uni_char *title = NULL);
  565. void DisplayLinkInformation(const uni_char* hlink, const uni_char* rel_name, ST_MESSAGETYPE mt = ST_ASTRING, const uni_char *title = NULL);
  566. WinState GetState() const { return state; }
  567. void SetState(WinState s);
  568. BOOL IsCancelingLoading() { return is_canceling_loading; }
  569. BOOL ShowImages() const { return show_img; }
  570. #ifdef FIT_LARGE_IMAGES_TO_WINDOW_WIDTH
  571. BOOL FitImages() const { return fit_img; }
  572. void SetFitImages(BOOL flag) { fit_img=flag; }
  573. #endif // FIT_LARGE_IMAGES_TO_WINDOW_WIDTH
  574. void SetImagesSetting(SHOWIMAGESTATE setting);
  575. BOOL LoadImages() const { return load_img; }
  576. LayoutMode GetLayoutMode() const;
  577. void SetLayoutMode(LayoutMode mode);
  578. /**
  579. * Is this window currently set to apply text paragraph width limit?
  580. *
  581. * @return TRUE if we have set this window to apply text paragraph
  582. * width limit.
  583. * Note! This function may return TRUE, although the
  584. * content has decided that width limit should not be applied.
  585. * This function will also always return FALSE if the window is in
  586. * non-normal (MSR/CSSR/ERA/...) layout mode.
  587. */
  588. BOOL GetLimitParagraphWidth();
  589. /**
  590. * Turn on/off text paragraph width limit.
  591. *
  592. * @param set TRUE to turn text paragraph width limit on,
  593. * FALSE to turn it off.
  594. * If TRUE, the width limit can still be overridden
  595. * by content or non-normal layout modes. If the
  596. * setting changed, the line widths will be requested
  597. * to be recalculated.
  598. */
  599. void SetLimitParagraphWidth(BOOL set);
  600. int GetFlexRootMaxWidth() const { return flex_root_max_width; }
  601. void SetFlexRootMaxWidth(int max_width, BOOL reformat = TRUE);
  602. INT32 GetFramesPolicy() { return m_frames_policy; }
  603. void SetFramesPolicy(INT32 frames_policy);
  604. void SetForceWordWrap(BOOL value) { document_word_wrap_forced = value; }
  605. BOOL ForceWordWrap() { return document_word_wrap_forced; }
  606. BOOL GetHandheld() const { return is_ssr_mode; }
  607. BOOL GetERA_Mode() const { return era_mode; }
  608. void SetERA_Mode(BOOL value);
  609. void Sync(); ///< Flushes pending drawoperations so that things wouldn't lag behind, if we do something agressive.
  610. void SetWindowSize(int xWin, int yWin);
  611. void SetWindowPos(int wWin, int hWin);
  612. void GetWindowSize(int& xWin, int& yWin);
  613. void GetWindowPos(int& wWin, int& hWin);
  614. void SetClientSize(int cx, int cy);
  615. void GetClientSize(int &cx, int &cy);
  616. /**
  617. * Get the size of the viewport in document coordinates
  618. *
  619. * It is possible to set the base scale between physical pixels
  620. * and layout pixels using the OpViewportController::SetTrueZoomBaseScale
  621. * api.
  622. *
  623. * In TrueZoom mode, this function will return viewport scaled with the layout
  624. * base scale.
  625. *
  626. * If we are zooming with regular "desktop" zoom, this function will
  627. * scale the viewport with the regular zoom factor.
  628. *
  629. * @param viewport_width (out) The width of the viewport in CSS pixels
  630. * @param viewport_height (out) The height of the viewport in CSS pixels
  631. *
  632. */
  633. void GetCSSViewportSize(unsigned int& viewport_width, unsigned int& viewport_height);
  634. void HandleNewWindowSize(unsigned int width, unsigned int height);
  635. #ifdef LINK_SUPPORT
  636. /**
  637. * Returns the first of a list of <link> elements in the
  638. * current document or NULL if theer are none. See GetLinkDatabase
  639. * for a different view of the list.
  640. */
  641. const LinkElement* GetLinkList() const;
  642. /**
  643. * Returns a database object that allows iterating over sub-
  644. * LinkElements. Will never return NULL. See LinkElementDatabase
  645. * for more information.
  646. */
  647. const LinkElementDatabase* GetLinkDatabase() const;
  648. #endif // LINK_SUPPORT
  649. /** Return the CSSCollection object for the current document. */
  650. CSSCollection* GetCSSCollection() const;
  651. #ifdef _SPAT_NAV_SUPPORT_
  652. OpSnHandler* GetSnHandler() const { return sn_handler; }
  653. OpSnHandler* GetSnHandlerConstructIfNeeded();
  654. # ifdef SN_LEAVE_SUPPORT
  655. // FIXME: Make into a proper core API (move to somewhere in windowcommander)
  656. void LeaveInDirection(INT32 direction);
  657. void SetSnLeaveListener(SnLeaveListener *listener);
  658. void SnMarkSelection(); // re-highlights the SN item
  659. # endif
  660. #endif /* _SPAT_NAV_SUPPORT */
  661. void SetCurrentHistoryPos(int pos, BOOL update_doc_man, BOOL is_user_initiated);
  662. int GetCurrentHistoryPos() { return current_history_number; }
  663. void SetMaxHistoryPos(int pos) {max_history_number = pos; }
  664. void SetMinHistoryPos(int pos) { min_history_number = pos; }
  665. void SetCurrentHistoryPosOnly(int pos) { current_history_number = pos; }
  666. void SetMaxHistory(int len);
  667. void SetLastHistoryPos(int pos);
  668. /** Get the ID to use when creating a new DocListElm within this
  669. * Window, and make a new ID for the next.
  670. */
  671. int GetNextDocListElmId();
  672. /**
  673. * Set user data for a specific history position.
  674. *
  675. * The data can later be retrieved with GetHistoryUserData().
  676. *
  677. * @param history_ID the ID for the history position, previously
  678. * sent in OpViewportInfoListener::OnNewPage().
  679. * @param user_data a pointer to the user data to set. Callee takes ownership of this object.
  680. * @retval OpStatus::OK if operation was successfull
  681. * @retval OpStatus::ERR if an error occured, for example if the history_ID could not be found
  682. */
  683. OP_STATUS SetHistoryUserData(int history_ID, OpHistoryUserData* user_data);
  684. /**
  685. * Returns previously stored user data for a specific history
  686. * position.
  687. *
  688. * @see SetHistoryUserData().
  689. *
  690. * @param history_ID the ID for the history position
  691. * @param[out] user_data where to fill in the pointer to the user
  692. * data. If no user data had previously been set, it is filled
  693. * with NULL. The returned instance is still owned by the callee.
  694. * @retval OpStatus::OK if operation was successfull
  695. * @retval OpStatus::ERR if an error occured, for example if the history_ID could not be found
  696. */
  697. OP_STATUS GetHistoryUserData(int history_ID, OpHistoryUserData** user_data) const;
  698. #ifdef DOCHAND_HISTORY_MANIPULATION_SUPPORT
  699. void RemoveElementFromHistory(int pos);
  700. void InsertElementInHistory(int pos, DocListElm * elm);
  701. void RemoveAllElementsFromHistory(BOOL unlink = FALSE);
  702. #endif // DOCHAND_HISTORY_MANIPULATION_SUPPORT
  703. /** Always disable java. Ignore java enabled pref, even for host overrides. */
  704. void ForceJavaDisabled(BOOL force_off) { forced_java_disabled = force_off; }
  705. BOOL GetForceJavaDisabled() { return forced_java_disabled; }
  706. /** Always disable plugins.*/
  707. void ForcePluginsDisabled(BOOL force_off) { forced_plugins_disabled = force_off; }
  708. BOOL GetForcePluginsDisabled() { return forced_plugins_disabled; }
  709. void RemoveAllElementsExceptCurrent();
  710. //void UpdateHistoryItem(const uni_char* title, const char* url_name);
  711. void EnsureHistoryLimits();
  712. BOOL HasHistoryNext() const { return current_history_number < max_history_number; }
  713. BOOL HasHistoryPrev() const { return current_history_number > min_history_number; }
  714. void SetHistoryNext(BOOL unused = FALSE);
  715. void SetHistoryPrev(BOOL unused = FALSE);
  716. int GetHistoryMin() const { return min_history_number; }
  717. int GetHistoryMax() const { return max_history_number; }
  718. int GetHistoryLen() const { return max_history_number - min_history_number + 1; }
  719. void SetCheckHistory(BOOL val) { check_history = val; }
  720. void CheckHistory();
  721. void HighlightItem(BOOL forward);
  722. void HighlightHeading(BOOL forward);
  723. void HighlightURL(BOOL forward);
  724. /**
  725. * Enables/disables drawing of highlight. This is enabled by default.
  726. * @param enable set to TRUE to enable drawing, FALSE otherwise.
  727. */
  728. void SetDrawHighlightRects(BOOL enable) { m_draw_highlight_rects = enable; }
  729. /**
  730. * Returns TRUE if spatnav highlight rects shall be drawn in this window.
  731. */
  732. BOOL DrawHighlightRects() { return m_draw_highlight_rects; }
  733. #ifdef _SPAT_NAV_SUPPORT_
  734. BOOL MarkNextLinkInDirection(INT32 direction, POINT* startingPoint = NULL, BOOL scroll = FALSE);
  735. BOOL MarkNextImageInDirection(INT32 direction, POINT* startingPoint = NULL, BOOL scroll = FALSE);
  736. BOOL MarkNextItemInDirection(INT32 direction, POINT* startingPoint = NULL, BOOL scroll = FALSE);
  737. #endif /* _SPAT_NAV_SUPPORT */
  738. OP_STATUS GetHighlightedURL(uint16 key, BOOL bNewWindow, BOOL bOpenInBackground);
  739. static uni_char* ComposeLinkInformation(const uni_char* hlink, const uni_char* rel_name);
  740. /**
  741. * @param bSubResourcesOnly TRUE if the method was called to
  742. * indicate that e.g. (i)frames or additional inlines started
  743. * loading, i.e. something which is not the top document.
  744. */
  745. OP_STATUS StartProgressDisplay(BOOL bReset, BOOL bResetSecurityState= TRUE, BOOL bSubResourcesOnly = FALSE);
  746. /**
  747. * Marks the url as visited. Used to do more, thus the name of the method.
  748. *
  749. * @param[in] url The url to send to the UI.
  750. */
  751. OP_STATUS SetProgressText(URL& url, BOOL unused = FALSE);
  752. void ResetProgressDisplay();
  753. void EndProgressDisplay();
  754. void SetProgressCount(long count) { progress_count = count; }
  755. long GetProgressCount() const { return progress_count; }
  756. time_t GetProgressStartTime() const { return start_time; }
  757. /**
  758. * Set the number of bytes loaded in the Window's main document,
  759. * not including inlines.
  760. */
  761. void SetDocProgressCount(OpFileLength count) { doc_progress_count = count; }
  762. OpFileLength GetDocProgressCount() const { return doc_progress_count; }
  763. const uni_char* GetProgressMessage();// const { return (progress_mess[0] ? progress_mess : progress_mess_low); }
  764. void SetProgressState(ProgressState state, const uni_char *extra_info, MessageHandler *mh, long bytes, URL *url);
  765. ProgressState GetProgressState() {return progress_state;};
  766. void SetUploadTotal(OpFileLength progress_info1);
  767. void SetUploadFileCount(int total, int loaded);
  768. #ifdef PROGRESS_EVENTS_SUPPORT
  769. /**
  770. * Propagate upload progress information to the Window's documents.
  771. *
  772. * @param[in] mh The handler of the loading URL.
  773. * @param[in] loading_url The url being uploaded.
  774. * @param[in] bytes The upload delta (in bytes.)
  775. * @returns The method has no error conditions.
  776. */
  777. void UpdateUploadProgress(MessageHandler *mh, const URL &loading_url, unsigned long bytes);
  778. #endif // PROGRESS_EVENTS_SUPPORT
  779. OP_STATUS UpdateWindow(BOOL unused = FALSE);
  780. OP_STATUS UpdateWindowAllDocuments(BOOL unused = FALSE);
  781. OP_STATUS UpdateWindowDefaults(BOOL scroll, BOOL progress, BOOL news, WORD scale, BOOL size);
  782. INT32 GetScale() const { return scale; }
  783. void SetScale(INT32 scale);
  784. void SetTextScale(int scale);
  785. int GetTextScale() { return m_text_scale; }
  786. #ifdef PIXEL_SCALE_RENDERING_SUPPORT
  787. /** Get the ratio of device pixels to css pixels
  788. *
  789. * @returns the ratio of device pixels to css pixels, in percentage
  790. */
  791. int GetPixelScale();
  792. #endif // PIXEL_SCALE_RENDERING_SUPPORT
  793. #ifdef GRAB_AND_SCROLL
  794. BOOL GetScrollIsPan() const;
  795. void OverrideScrollIsPan();
  796. #endif
  797. /**
  798. * Checks if a key has recently had its keydown event cancelled.
  799. *
  800. * Background: If you cancel a keydown event then the corresponding
  801. * keypress event should be automaticall cancelled. Whether that has
  802. * happened is kept track of here in the Window class.
  803. *
  804. * @param key The key for which a keypress has arrived and we
  805. * want to check if its keydown was cancelled.
  806. *
  807. * @returns TRUE if key was recently cancelled, in which case a
  808. * keypress event with the same key should also be cancelled.
  809. *
  810. * @see SetRecentlyCancelledKeyDown()
  811. */
  812. BOOL HasRecentlyCancelledKeyDown(OpKey::Code key) { return key == recently_cancelled_keydown; }
  813. /**
  814. * Records or clears that a key has had its keydown event cancelled.
  815. *
  816. * Background: If you cancel a keydown event then the corresponding
  817. * keypress event should be automaticall cancelled. Whether that has
  818. * happened is kept track of here in the Window class.
  819. *
  820. * @param key The virtual key to remember a keydown for. Set to OP_KEY_INVALID
  821. * to clear all memories of past cancelled keydown events.
  822. *
  823. * @see HasRecentlyCancelledKeyDown()
  824. */
  825. void SetRecentlyCancelledKeyDown(OpKey::Code key) { recently_cancelled_keydown = key; }
  826. /** In truezoom the scaling affects only the content, not the layout. (No reflow caused when scaling) */
  827. void SetTrueZoom(BOOL status);
  828. BOOL GetTrueZoom() { return truezoom; }
  829. /** Set default scale to base text metrics and window size on in TrueZoom */
  830. void SetTrueZoomBaseScale(UINT32 scale);
  831. UINT32 GetTrueZoomBaseScale() const { return truezoom_base_scale; }
  832. Window* GetOutputAssociatedWindow();
  833. void SetOutputAssociatedWindow(Window* ass);
  834. void SetOutputAssociatedWindowId(unsigned long ass) { OutputAssociatedWindow = ass; }
  835. BOOL ShowScrollbars() const { return bShowScrollbars; }
  836. void SetShowScrollbars(BOOL show);
  837. unsigned long Id() const { return id; }
  838. void GotoHistoryPos(); // Only for startup
  839. void SetLoading(BOOL set);
  840. BOOL IsLoading() const;
  841. COLORREF GetDefaultBackgroundColor() { return default_background_color; }
  842. void SetDefaultBackgroundColor( const COLORREF &background_color ) { default_background_color = background_color; }
  843. #ifdef ABSTRACT_CERTIFICATES
  844. const OpCertificate* GetCertificate();
  845. #endif
  846. const uni_char* Name() const { return name.CStr(); }
  847. void SetName(const uni_char *n);
  848. #ifdef CPUUSAGETRACKING
  849. /**
  850. * Returns the CPUUsageTracker that collects time spent processing
  851. * this Window (i.e. tab). Use this when we start working on something
  852. * related to this Window after leaving generic code.
  853. *
  854. * @returns A pointer to a CPUUsageTracker. Never NULL.
  855. */
  856. CPUUsageTracker* GetCPUUsageTracker() { return &cpu_usage_tracker; }
  857. #endif // CPUUSAGETRACKING
  858. void SetForceColors(BOOL f);
  859. BOOL ForceColors();
  860. void SetCSSMode(CSSMODE f);
  861. void SetNextCSSMode();
  862. CSSMODE GetCSSMode() const { return CSSMode; }
  863. /** Set character encoding to force for this window.
  864. * @param encoding Name of encoding to force.
  865. * @param isnewwin Whether this is a virgin window or not.
  866. */
  867. void SetForceEncoding(const char *encoding, BOOL isnewwin = FALSE);
  868. /** Get character encoding forced for this window.
  869. * @return Name of character set forced.
  870. */
  871. const char * GetForceEncoding() const { return forceEncoding.CStr(); }
  872. void UpdateVisitedLinks(const URL& url);
  873. #ifdef HISTORY_SUPPORT
  874. OP_STATUS AddToGlobalHistory(URL& url, const uni_char *title);
  875. void DisableGlobalHistory() { m_global_history_enabled = FALSE; }
  876. BOOL IsGlobalHistoryEnabled() { return m_global_history_enabled; }
  877. #endif // HISTORY_SUPPORT
  878. /**
  879. * Recheck the title on the document and update global
  880. * history and the UI. If delay is TRUE, then this is
  881. * done on a message to avoid getting swamped if a script is
  882. * changing title 50000 times per second. This is recommended.
  883. *
  884. * @param[in] delay Should be TRUE if called externally. Will prevent bad pages from consuming 100% CPU just updating the title.
  885. *
  886. * @returns OpStatus::OK or OpStatus::ERR_NO_MEMORY
  887. */
  888. OP_STATUS UpdateTitle(BOOL delay = TRUE);
  889. BOOL IsWindowTitleGenerated() { return generated_title; }
  890. /**
  891. * Set the title on the Window object and inform listeners about the new title
  892. * so that the UI can be updated.
  893. *
  894. * @param[in] str The (new) title.
  895. *
  896. * @param[in] force If the UI should be told about the title even if it's the same as we already have.
  897. *
  898. * @param[in] generated If the title comes from the document (FALSE) or if generated from the url (TRUE).
  899. *
  900. * @returns OpStatus::OK or OpStatus::ERR_NO_MEMORY
  901. */
  902. OP_STATUS SetWindowTitle(const OpString& str, BOOL force, BOOL generated = FALSE);
  903. OP_STATUS GetWindowTitle(OpString& str) const { return str.Set(title); }
  904. const uni_char* GetWindowTitle() const { return title.CStr(); }
  905. #ifdef SHORTCUT_ICON_SUPPORT
  906. OP_STATUS SetWindowIcon(URL* url);
  907. Image GetWindowIcon() const;
  908. BOOL HasWindowIcon() const;
  909. URL GetWindowIconURL() {return m_shortcut_icon_url; }
  910. OP_STATUS DecodeWindowIcon();
  911. # ifdef ASYNC_IMAGE_DECODERS
  912. // implements ImageListener
  913. void OnPortionDecoded();
  914. void OnError(OP_STATUS status) {}
  915. # endif // ASYNC_IMAGE_DECODERS
  916. #endif // SHORTCUT_ICON_SUPPORT
  917. BYTE GetSecurityState() const { return SecurityState; }
  918. void SignalSecurityState(BOOL changed = FALSE);
  919. /**
  920. * Reset security state for window to unknown. Must only be called when main document url is changed, as
  921. * this will open up for setting high security state, risking an inline setting high security
  922. * state on main document.
  923. */
  924. void ResetSecurityStateToUnknown();
  925. void SetSecurityState(BYTE sec, BOOL is_inline, const uni_char *name, URL *url= NULL);
  926. const uni_char * GetSecurityStateText() const { return SecurityTextName.CStr();; }
  927. BOOL GetPrivacyMode() { return m_privacy_mode; }
  928. void SetPrivacyMode(BOOL privacy_mode);
  929. #ifdef TRUST_RATING
  930. TrustRating GetTrustRating() const { return m_trust_rating; }
  931. /**
  932. * Sets the trust rating of the window. May be called with different ratings
  933. * for the same window. The most strict rating is set as window's final rating.
  934. *
  935. * @param rating - the trust rating of the window.
  936. * @param force - the passed in rating will be set even if it looses the rating.
  937. */
  938. void SetTrustRating(TrustRating rating, BOOL force = FALSE);
  939. /**
  940. * Check trust rating of this Window.
  941. *
  942. * @param force if true check regardless of whether the feature is on or off.
  943. * @param offline if true do not send check request to sitecheck server, only check against cached and in memory results.
  944. * If both force and offline are true, the check will not connect, (offline is respected, force is not.)
  945. */
  946. OP_STATUS CheckTrustRating(BOOL force = FALSE, BOOL offline = FALSE);
  947. #endif // TRUST_RATING
  948. #ifdef WEB_TURBO_MODE
  949. BOOL GetTurboMode() { return m_turbo_mode; }
  950. void SetTurboMode(BOOL turbo_mode);
  951. #endif // WEB_TURBO_MODE
  952. Window_Type GetType() const { return type; }
  953. void SetType(Window_Type new_type) { if (type != WIN_TYPE_BRAND_VIEW &&
  954. type != WIN_TYPE_DOWNLOAD)
  955. {
  956. type = new_type;
  957. SetFeatures(type);
  958. }
  959. }
  960. void SetType(DocType doc_type);
  961. BOOL IsSuppressWindow() { return type == WIN_TYPE_MAIL_VIEW || type == WIN_TYPE_MAIL_COMPOSE || type == WIN_TYPE_IM_VIEW || m_is_explicit_suppress_window || m_is_implicit_suppress_window; }
  962. BOOL IsNormalWindow() {return (type == WIN_TYPE_NORMAL || type == WIN_TYPE_CACHE || type == WIN_TYPE_PLUGINS || type == WIN_TYPE_HISTORY || type == WIN_TYPE_JS_CONSOLE) ? TRUE : FALSE; }
  963. BOOL IsThumbnailWindow() { return (type == WIN_TYPE_THUMBNAIL); }
  964. BOOL IsMailOrNewsfeedWindow() { return type == WIN_TYPE_MAIL_VIEW || type == WIN_TYPE_MAIL_COMPOSE || type == WIN_TYPE_NEWSFEED_VIEW || type == WIN_TYPE_IM_VIEW; }
  965. /** If set to TRUE, the content of the document(s) may be transparent. There will be no default backgroundcolor drawn if
  966. the body of the document is transparent. */
  967. void SetBackgroundTransparent(BOOL transparent) { m_is_background_transparent = transparent; }
  968. BOOL IsBackgroundTransparent() { return m_is_background_transparent; }
  969. #ifdef GADGET_SUPPORT
  970. void SetGadget(OpGadget* gadget);
  971. OpGadget* GetGadget() const;
  972. #endif // GADGET_SUPPORT
  973. BOOL IsScriptableWindow() {return m_is_scriptable_window && (IsNormalWindow() || IsThumbnailWindow() || type == WIN_TYPE_GADGET || type == WIN_TYPE_BRAND_VIEW || type == WIN_TYPE_DIALOG || type == WIN_TYPE_CONTROLLER || type == WIN_TYPE_DEVTOOLS); }
  974. BOOL IsCustomWindow() {return IsNormalWindow() ? FALSE : TRUE;}
  975. void SetIsSuppressWindow(BOOL is_suppress_window) { m_is_explicit_suppress_window = is_suppress_window; }
  976. /**< If is_suppress_window is TRUE, external embeds will be suppressed in
  977. this window until this function is called again with a FALSE
  978. argument. If is_suppress_window is FALSE, external embeds will not
  979. be suppressed unless the window type and/or contents also require
  980. suppression of external embeds. */
  981. void SetIsImplicitSuppressWindow(BOOL is_suppress_window) { m_is_implicit_suppress_window = is_suppress_window; }
  982. /**< If is_suppress_window is TRUE, external embeds will be suppressed in
  983. this window, because its contents require it, until this function is
  984. called again with a FALSE argument. If is_suppress_window is FALSE,
  985. external embeds will no longer be suppressed because of the contents
  986. of the window, but may be suppressed because of the window type or
  987. because suppression has been requested via SetIsSuppressWindow(). */
  988. void SetIsScriptableWindow(BOOL is_scriptable_window) { m_is_scriptable_window = is_scriptable_window; }
  989. void Reload(EnteredByUser entered_by_user = NotEnteredByUser, BOOL conditionally_request_document = FALSE, BOOL conditionally_request_inlines = TRUE);
  990. /**< Reload window.
  991. @param conditionally_request_document If TRUE, use URL_Reload_Conditional reload policy for document URLs, otherwise use URL_Reload_Full.
  992. @param conditionally_request_inlines If TRUE, use URL_Reload_Conditional reload policy for inline URLs, otherwise use URL_Reload_Full. */
  993. #ifdef _AUTO_WIN_RELOAD_SUPPORT_
  994. AutoWinReloadParam* GetUserAutoReload() { return &m_userAutoReload; }
  995. #endif // _AUTO_WIN_RELOAD_SUPPORT_
  996. /** Stop the document loading
  997. * @param oom Set to TRUE to signal that the document is stopped due to OOM.
  998. * The loading is then stopped without parsing pending data (needs memory)
  999. * and the current document will be dropped before starting to load another one.
  1000. */
  1001. BOOL CancelLoad(BOOL oom = FALSE);
  1002. void Activate( BOOL fActivate = TRUE);
  1003. void Raise();
  1004. void Lower();
  1005. FramesDocument* GetCurrentDoc() const;
  1006. /**
  1007. * @return When using frames the active frame document, for non-frames the
  1008. * active document itself, if there is no active document at all
  1009. * NULL is returned.
  1010. */
  1011. FramesDocument* GetActiveFrameDoc();
  1012. BOOL CloneWindow(Window**return_window=0,BOOL open_in_background=FALSE);
  1013. #ifdef SAVE_SUPPORT
  1014. void DEPRECATED(GetSuggestedSaveFileName( URL *url, uni_char *szName, int maxSize));
  1015. OP_BOOLEAN DEPRECATED(SaveAs(URL& url, BOOL load_to_file, BOOL save_inline, BOOL frames_only = FALSE));
  1016. OP_BOOLEAN DEPRECATED(SaveAs(URL& url, BOOL load_to_file, BOOL save_inline, const uni_char* szSaveToFolder, BOOL fCreateDirectory=FALSE, BOOL fExecute=FALSE, BOOL hasfilename=FALSE, const uni_char* handlerapplication=NULL, BOOL frames_only = FALSE));
  1017. #endif // SAVE_SUPPORT
  1018. /** Update document loading information and notify OpLoadingListener.
  1019. *
  1020. * @param loaded_inlines The number of inlines loaded for the
  1021. * document so far.
  1022. * @param total_inlines The total number of inlines found in the
  1023. * document so far.
  1024. */
  1025. void UpdateLoadingInformation(int loaded_inlines, int total_inlines);
  1026. void HandleDocumentProgress(long bytes_read);
  1027. void HandleDataProgress(long bytes, BOOL upload_progress, const uni_char* extrainfo, MessageHandler *mh, URL *url);
  1028. BOOL HandleMessage(UINT message, int id, long user_data);
  1029. void GetClickedURL(URL url, DocumentReferrer& ref_url, short sub_win_id, BOOL user_initiated, BOOL open_in_background_window = FALSE);
  1030. OP_STATUS OpenURL(OpenUrlInNewWindowInfo *info, BOOL check_if_expired = TRUE, BOOL reload = FALSE, EnteredByUser entered_by_user = NotEnteredByUser, BOOL called_externally = FALSE);
  1031. OP_STATUS OpenURL(URL& url, DocumentReferrer ref_url, BOOL check_if_expired, BOOL reload, short sub_win_id, BOOL user_initiated = FALSE, BOOL open_in_background = FALSE, EnteredByUser entered_by_user = NotEnteredByUser, BOOL called_externally = FALSE);
  1032. OP_STATUS OpenURL(const char* url_name, BOOL check_if_expired = TRUE, BOOL user_initiated = FALSE, BOOL reload = FALSE, BOOL is_hotlist_url = FALSE, BOOL open_in_background = FALSE, EnteredByUser entered_by_user = NotEnteredByUser, BOOL called_externally = FALSE);
  1033. void OpenURLL(const char* in_url_str, BOOL check_if_expired = TRUE, BOOL user_initiated = FALSE, BOOL reload = FALSE, BOOL is_hotlist_url = FALSE, BOOL open_in_background = FALSE, EnteredByUser entered_by_user = NotEnteredByUser, BOOL called_externally = FALSE)
  1034. { LEAVE_IF_ERROR(OpenURL(in_url_str, check_if_expired, user_initiated, reload, is_hotlist_url, open_in_background, entered_by_user, called_externally)); }
  1035. OP_STATUS OpenURL(const uni_char* in_url_str, BOOL check_if_expired = TRUE, BOOL user_initiated = FALSE, BOOL reload = FALSE, BOOL is_hotlist_url = FALSE, BOOL open_in_background = FALSE, EnteredByUser entered_by_user = NotEnteredByUser, BOOL called_externally = FALSE, URL_CONTEXT_ID context_id = -1);
  1036. void OpenURLL(const uni_char* in_url_str, BOOL check_if_expired = TRUE, BOOL user_initiated = FALSE, BOOL reload = FALSE, BOOL is_hotlist_url = FALSE, BOOL open_in_background = FALSE, EnteredByUser entered_by_user = NotEnteredByUser, BOOL called_externally = FALSE, URL_CONTEXT_ID context_id = -1)
  1037. { LEAVE_IF_ERROR(OpenURL(in_url_str, check_if_expired, user_initiated, reload, is_hotlist_url, open_in_background, entered_by_user, called_externally, context_id)); }
  1038. void GenericMailToAction(const URL& url, BOOL called_externally, BOOL mailto_from_form, const OpStringC8& servername);
  1039. DocumentManager* GetDocManagerById(int sub_win_id);
  1040. void LoadPendingUrl(URL_ID url_id, int sub_win_id, BOOL user_initiated);
  1041. BOOL HandleLoadingFailed(Str::LocaleString msg_id, URL url);
  1042. void AskAboutUnknownDoc(URL& url, int sub_win_id);
  1043. #ifndef NO_EXTERNAL_APPLICATIONS
  1044. BOOL RunApplication(const OpStringC &application, const OpStringC &filename);
  1045. BOOL ShellExecute(const uni_char* filename);
  1046. #endif // !NO_EXTERNAL_APPLICATIONS
  1047. BOOL GetUserLoadFromCache() const { return user_load_from_cache; }
  1048. void SetUserLoadFromCache(BOOL val) { user_load_from_cache = val; }
  1049. int SetNewHistoryNumber();
  1050. void SetUseHistoryNumber(BOOL value) { OP_ASSERT(!"You need to upgrade the module that called this function!"); }
  1051. void SetCurrentHistoryNumber(int val) { current_history_number = val; }
  1052. int GetCurrentHistoryNumber() const { return current_history_number; }
  1053. const char* GetLastUserName() const { return lastUserName; }
  1054. OP_STATUS SetLastUserName(const char *_name);
  1055. const char* GetLastProxyUserName() const { return lastProxyUserName; }
  1056. OP_STATUS SetLastProxyUserName(const char *_name);
  1057. OP_STATUS GetHomePage(OpString &target) const { return target.Set(homePage); }
  1058. OP_STATUS SetHomePage(const OpStringC& url);
  1059. const URL GetActiveLinkURL() { return active_link_url; }
  1060. void SetActiveLinkURL(const URL& url, HTML_Document* doc);
  1061. void ClearActiveLinkURL();
  1062. URL GetCurrentShownURL();
  1063. URL GetCurrentLoadingURL();
  1064. URL GetCurrentURL();
  1065. /**
  1066. * Returns the url context id for other use cases than network.
  1067. *
  1068. * The context id returned regards features like turbo and app cache, which use a context
  1069. * id internally to organize their data, as transparent, because from a user point
  1070. * of view, it is the same browsing session as having turbo or app cache disabled.
  1071. * It depends on features that require absolute data separation, like the main browsing
  1072. * context (id 0), gadgets, privacy mode, and other future features that might require
  1073. * their own separate context id.
  1074. *
  1075. * This method first checks if base_id is either from turbo or app cache, and if so
  1076. * returns the non app-cache and non-turbo context id. Else it returns base_id.
  1077. *
  1078. * @see Window::GetUrlContextId()
  1079. */
  1080. URL_CONTEXT_ID GetMainUrlContextId(URL_CONTEXT_ID base_id = 0);
  1081. /**
  1082. * Return the url context id that urls opened from this window should use.
  1083. *
  1084. * @see Window::GetMainUrlContextId()
  1085. *
  1086. * @param url Optional url to help with the determination of the correct context id to use (e.g. in appcache's case).
  1087. */
  1088. URL_CONTEXT_ID GetUrlContextId(const uni_char *url = NULL);
  1089. BOOL GetURLCameFromAddressField() { return m_url_came_from_address_field; }
  1090. void SetURLCameFromAddressField(BOOL from_address_field) { m_url_came_from_address_field = from_address_field; }
  1091. #if defined REDIRECT_ON_ERROR || defined AB_ERROR_SEARCH_FORM
  1092. /**
  1093. * Returns the exact text that the user entered in the address
  1094. * bar to be used in the search field for error pages
  1095. * Note: the string will be truncated at a few hundreds
  1096. * chars if it's going to be used on the search field on error
  1097. * pages because more than that would be useless for the user
  1098. * After loading the document, this string is emptied because
  1099. * it will not longer be used
  1100. */
  1101. OpString* GetTypedInUrl() { return &m_typed_in_url; }
  1102. #endif // defined REDIRECT_ON_ERROR || defined AB_ERROR_SEARCH_FORM
  1103. #ifndef HAS_NO_SEARCHTEXT
  1104. BOOL SearchText(const uni_char* key, BOOL forward, BOOL matchcase, BOOL words, BOOL next, BOOL wrap = FALSE, BOOL only_links = FALSE);
  1105. # ifdef SEARCH_MATCHES_ALL
  1106. BOOL HighlightNextMatch(const uni_char* txt,
  1107. BOOL match_case, BOOL match_words,
  1108. BOOL links_only, BOOL forward, BOOL wrap,
  1109. BOOL &wrapped, OpRect& rect);
  1110. /**< Will move the search highlight to the next match found in the document. If no matches have been
  1111. * found yet a search will be executed and the next match highlighted.
  1112. * @param[IN] txt The text to search for.
  1113. * @param[IN] match_case If set to TRUE the search will be case sensitive.
  1114. * @param[IN] match_words If set to TRUE only whole words will be matched.
  1115. * @param[IN] links_only If set to TRUE only text in links will be matched.
  1116. * @param[IN] forward If set to TRUE the next match will be highlighted otherwise the previous.
  1117. * @param[IN] wrap If set to TRUE and there is no more matches in the direction specified
  1118. * by forward it will wrap around and start at the other end of the document.
  1119. * @param[OUT] wrapped Set to TRUE if wrapped around.
  1120. * @param[OUT] rect The coordinate of the search hit if there was any. In document
  1121. * coordinates.
  1122. * @returns TRUE if a next match has been found. */
  1123. void EndSearch(BOOL activate_current_match, int modifiers);
  1124. /**< Must be called from the UI when a search is finished. If activate_current_match is
  1125. * TRUE the current matched element will be activated, eg. links navigated to. The
  1126. * modifiers parameter specifies which shift or control keys are held down, and only
  1127. * needs to be specified if activate_current_match is TRUE. */
  1128. # endif // SEARCH_MATCHES_ALL
  1129. #endif // !HAS_NO_SEARCHTEXT
  1130. #ifdef _PRINT_SUPPORT_
  1131. PrinterInfo* GetPrinterInfo(BOOL preview) { return !printer_info ? preview_printer_info : printer_info; }
  1132. void SetPrinterInfo(PrinterInfo* pr_info) { printer_info = pr_info; }
  1133. BOOL GetPreviewMode() { return preview_mode; }
  1134. void SetPreviewMode(BOOL val) { preview_mode = val; }
  1135. BOOL GetPrintMode() { return print_mode; }
  1136. BOOL TogglePrintMode(BOOL preview);
  1137. BOOL StartPrinting(PrinterInfo* pinfo, int from_page, BOOL selected_only);
  1138. void PrintNextPage(PrinterInfo* pinfo);
  1139. void StopPrinting();
  1140. DM_PrintType GetFramesPrintType() { return frames_print_type; }
  1141. OP_STATUS SetFramesPrintType(DM_PrintType fptype, BOOL update); // { frames_print_type = fptype; }
  1142. /* For async printing */
  1143. BOOL IsFormattingPrintDoc() { return is_formatting_print_doc; }
  1144. void SetFormattingPrintDoc(BOOL formatting) { is_formatting_print_doc = formatting; }
  1145. BOOL IsPrinting() { return is_printing; }
  1146. void SetPrinting(BOOL printing) { is_printing = printing;}
  1147. #endif // _PRINT_SUPPORT_
  1148. void TrackLinkMenu ( );
  1149. void SetAlwaysLoadFromCache(BOOL from_cache);
  1150. BOOL AlwaysLoadFromCache() { return always_load_from_cache; }
  1151. void ToggleImageState();
  1152. #ifdef LIBOPERA
  1153. /** Will be called from DocumentManager to tell this Window if the request
  1154. (call to OpenURL()) is user initiated or not. */
  1155. void SetUserInitiated(BOOL user) { m_lastReqUserInitiated = user; }
  1156. /** Was the last request (call to OpenURL()) user initiated? */
  1157. BOOL WasLastReqUserInitiated() { return m_lastReqUserInitiated; }
  1158. #endif // LIBOPERA
  1159. void RaiseCondition( OP_STATUS type );
  1160. #ifdef ACCESS_KEYS_SUPPORT
  1161. BOOL GetAccesskeyMode() const { return in_accesskey_mode; }
  1162. void SetAccesskeyMode(BOOL mode) { in_accesskey_mode = mode; }
  1163. #endif // ACCESS_KEYS_SUPPORT
  1164. OnlineMode GetOnlineMode();
  1165. OP_STATUS QueryGoOnline(URL *url);
  1166. // implementation of the OpDocumentListener::DialogCallback interface
  1167. void OnDialogReply(OpDocumentListener::DialogCallback::Reply reply);
  1168. void LockWindow();
  1169. void UnlockWindow();
  1170. BOOL IsURLAlreadyRequested(const URL &url);
  1171. void SetURLAlreadyRequested(const URL &url);
  1172. void HandleCallback(OpMessage msg, MH_PARAM_1 par1, MH_PARAM_2 par2);
  1173. void ClearMovedUrls() { moved_urls.Clear(); }
  1174. /**
  1175. * Sets a flag informing the browser core that this window is
  1176. * visible, or not visible to the user. When a window is set to
  1177. * not visble certain then unneeded background processing will be
  1178. * disabled and other processing might prioritize windows that are
  1179. * visible, thus giving the user a perceived performance increase.
  1180. *
  1181. * For the moment this doesn't prevent plugins in background
  1182. * windows from using high amounts of CPU, and scripts will
  1183. * continue running.
  1184. *
  1185. * If this is set to FALSE when the window is actually showing,
  1186. * animations might not run (neither gifs, nor SVGs).
  1187. *
  1188. * Typically this is set to false whenever the window gets covered
  1189. * by any other window and then set to true when the operating
  1190. * system sends a paint event.
  1191. *
  1192. * @param is_visible Set to TRUE if the user can see the Window, FALSE
  1193. * otherwise.
  1194. */
  1195. void SetVisibleOnScreen(BOOL is_visible) { m_is_visible_on_screen = is_visible; }
  1196. /**
  1197. * @return TRUE if the window might be visible to the user. FALSE
  1198. * if it is not possible for the user too see the Window. For
  1199. * instance if the window is in a background tab or completely
  1200. * hidden by other opaque windows (not necessarily opera windows).
  1201. */
  1202. BOOL IsVisibleOnScreen() const { return m_is_visible_on_screen; }
  1203. BOOL IsEcmaScriptDisabled() { return ecmascript_disabled; }
  1204. BOOL IsEcmaScriptEnabled() { return !ecmascript_disabled; }
  1205. void SetEcmaScriptDisabled(BOOL value) { ecmascript_disabled = value; }
  1206. BOOL IsEcmaScriptPaused() { return ecmascript_paused != NOT_PAUSED; }
  1207. void SetEcmaScriptPaused(BOOL value);
  1208. void CancelAllEcmaScriptTimeouts();
  1209. #ifdef NEARBY_ELEMENT_DETECTION
  1210. /**
  1211. * Set new element expander.
  1212. *
  1213. * This element expander is currently displaying nearby elements of
  1214. * interest. If a previously active element expander is set, it will be
  1215. * removed.
  1216. *
  1217. * @param expander New element expander, or NULL to remove the current one
  1218. */
  1219. void SetElementExpander(class ElementExpander* expander);
  1220. /**
  1221. * Get the current element expander, if any.
  1222. */
  1223. ElementExpander*
  1224. GetElementExpander() { return element_expander; }
  1225. #endif // NEARBY_ELEMENT_DETECTION
  1226. ViewportController *GetViewportController() const { return viewportcontroller; }
  1227. /**
  1228. * A page has the right to show one (1) unsolicited download dialog.
  1229. * This keeps track of whether it has done that or not. This flag
  1230. * should only be checked and set on the top document.
  1231. *
  1232. * Set to TRUE when the UI has been sent a signal that might result
  1233. * in a download dialog. For instance AskAboutUnknownDoc or
  1234. * OnDownloadRequest.
  1235. *
  1236. * Set to FALSE when the user has performed an action that should allow
  1237. * the page to spam one more download dialog. For instance after
  1238. * walking in history of loading a (user initiated) document, or
  1239. * clicking in the page.
  1240. */
  1241. void SetHasShownUnsolicitedDownloadDialog(BOOL new_value) { OP_ASSERT(!new_value || !has_shown_unsolicited_download_dialog); has_shown_unsolicited_download_dialog = new_value; }
  1242. /**
  1243. * A page has the right to show one (1) unsolicited download dialog.
  1244. * This keeps track of whether it has done that or not. This flag
  1245. * should only be checked and set on the top document.
  1246. *
  1247. * If this returns TRUE, no calls to listeners that could show
  1248. * download dialogs should be done unless that action is a direct
  1249. * result of something the user did. Examples of functions that
  1250. * should not be called are AskAboutUnknownDoc and OnDownloadRequest.
  1251. */
  1252. BOOL HasShownUnsolicitedDownloadDialog() { return has_shown_unsolicited_download_dialog; }
  1253. /**
  1254. * The Screen Properties (ref OpScreenInfo) for the windows screen
  1255. * has changed, and we need to mark all screen properties caches in
  1256. * all visual devices as dirty, so that new and fresh properties are
  1257. * gathered. This will iterate all doc managers under the window and
  1258. * tell them to update.
  1259. */
  1260. void ScreenPropertiesHaveChanged();
  1261. #ifdef DOM_JIL_API_SUPPORT
  1262. void SetScreenPropsChangeListener(ScreenPropsChangedListener* screen_props_listener) { m_screen_props_listener = screen_props_listener; }
  1263. #endif // DOM_JIL_API_SUPPORT
  1264. WindowViewMode GetViewMode();
  1265. #ifdef SCOPE_PROFILER
  1266. /**
  1267. * Start profiling this Window, using the specified OpProfilingSession.
  1268. *
  1269. * @param session The OpProfilingSession to record profiling data to.
  1270. * The session is not owned by the Window, and must
  1271. * therefore outlive the Window.
  1272. * @return OpStatus::OK if profiling was started; OpStatus::ERR if
  1273. * profiling already was started for this Window; or
  1274. * OpStatus::ERR_NO_MEMORY.
  1275. */
  1276. OP_STATUS StartProfiling(OpProfilingSession *session);
  1277. /**
  1278. * Stop profiling on this Window. If the Window is not currently being
  1279. * profiled, nothing happens.
  1280. */
  1281. void StopProfiling();
  1282. /**
  1283. * Get the current OpProfilingSession for this Window. This can be used to
  1284. * check if we currently are profiling this Window.
  1285. *
  1286. * @return The current OpProfilingSession. (NULL means the Window is not
  1287. * currently being profiled).
  1288. */
  1289. OpProfilingSession *GetProfilingSession() const { return m_profiling_session; }
  1290. #endif // SCOPE_PROFILER
  1291. #ifdef GEOLOCATION_SUPPORT
  1292. /** Called whenever any document in this window starts or stops accessing geolocation data.
  1293. Will result in a call to OpDocumentListener::OnGeolocationAccess. */
  1294. void NotifyGeolocationAccess();
  1295. #endif // GEOLOCATION_SUPPORT
  1296. #ifdef MEDIA_CAMERA_SUPPORT
  1297. /** Called whenever any document in this window starts or stops accessing camera.
  1298. Will result a call to OpDocumentListener::OnCameraAccess. */
  1299. void NotifyCameraAccess();
  1300. #endif // MEDIA_CAMERA_SUPPORT
  1301. #ifdef KEYBOARD_SELECTION_SUPPORT
  1302. /**
  1303. * Called from frames document when keyboard selection mode has
  1304. * changed. Will call a callback to through windowcommander if the
  1305. * mode has changed.
  1306. */
  1307. void UpdateKeyboardSelectionMode(BOOL enabled);
  1308. #endif // KEYBOARD_SELECTION_SUPPORT
  1309. #ifdef EXTENSION_SUPPORT
  1310. /**
  1311. * Perform a screenshot of a visible part of a document in this window and write it to a bitmap.
  1312. *
  1313. * @param target_document The document to take a screenshot of. This can be either
  1314. * the top level document or a child document like an iframe. MUST NOT be NULL.
  1315. * @param source_document The document which requested a screenshot. It is used for determining if it
  1316. * has access to target subdocuments and thus if they should be included in the
  1317. * screenshot. MUST NOT be NULL.
  1318. * @param[out] bitmap Set to the bitmap to which the screenshot is be painted. It is created
  1319. * by this method and the caller takes ownership of it if the call succeeded.
  1320. *
  1321. * @return OpStatus::OK, OpStatus::ERR_NO_MEMORY.
  1322. */
  1323. OP_STATUS PerformScreenshot(FramesDocument* target_document, FramesDocument* source_document, OpBitmap*& bitmap);
  1324. private:
  1325. /**
  1326. * Helper method for PerformScreenshot. Collects a list of all VisualDevices the source_document isn't allowed to access.
  1327. *
  1328. * @param target_document The root document of the subtree to check.
  1329. * @param source_document The document which requested a screenshot.
  1330. * @param visdev_to_hide List of VisualDevices of documents which should not be painted.
  1331. * @return OpStatus::OK, OpStatus::ERR_NO_MEMORY.
  1332. */
  1333. OP_STATUS GetDisallowedScreenshotVisualDevices(FramesDocument* target_document, FramesDocument* source_document, OpVector<VisualDevice>& visdev_to_hide);
  1334. public:
  1335. #endif // EXTENSION_SUPPORT
  1336. };
  1337. #endif // DOCHAND_WIN_H