| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_WEB_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_WEB_CONTENTS_H_ |
| 6 #define CHROME_BROWSER_WEB_CONTENTS_H_ | 6 #define CHROME_BROWSER_WEB_CONTENTS_H_ |
| 7 | 7 |
| 8 #include "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
| 9 #include "chrome/browser/download/save_package.h" | 9 #include "chrome/browser/download/save_package.h" |
| 10 #include "chrome/browser/fav_icon_helper.h" | 10 #include "chrome/browser/fav_icon_helper.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 virtual HWND GetContainerHWND() const { return GetHWND(); } | 52 virtual HWND GetContainerHWND() const { return GetHWND(); } |
| 53 virtual void GetContainerBounds(gfx::Rect *out) const; | 53 virtual void GetContainerBounds(gfx::Rect *out) const; |
| 54 virtual void ShowContents(); | 54 virtual void ShowContents(); |
| 55 virtual void HideContents(); | 55 virtual void HideContents(); |
| 56 virtual void SizeContents(const gfx::Size& size); | 56 virtual void SizeContents(const gfx::Size& size); |
| 57 | 57 |
| 58 // Causes the renderer to invoke the onbeforeunload event handler. The | 58 // Causes the renderer to invoke the onbeforeunload event handler. The |
| 59 // result will be returned via ViewMsg_ShouldClose. | 59 // result will be returned via ViewMsg_ShouldClose. |
| 60 virtual void FirePageBeforeUnload(); | 60 virtual void FirePageBeforeUnload(); |
| 61 | 61 |
| 62 // Close the page after the page has responded that it can be closed via | |
| 63 // ViewMsg_ShouldClose. This is where the page itself is closed. The | |
| 64 // unload handler is triggered here, which can block with a dialog, but cannot | |
| 65 // cancel the close of the page. | |
| 66 virtual void FirePageUnload(); | |
| 67 | |
| 68 // TabContents | 62 // TabContents |
| 69 virtual WebContents* AsWebContents() { return this; } | 63 virtual WebContents* AsWebContents() { return this; } |
| 70 virtual SiteInstance* GetSiteInstance() const { | 64 virtual SiteInstance* GetSiteInstance() const { |
| 71 return render_manager_.current_host()->site_instance(); | 65 return render_manager_.current_host()->site_instance(); |
| 72 } | 66 } |
| 73 virtual bool NavigateToPendingEntry(bool reload); | 67 virtual bool NavigateToPendingEntry(bool reload); |
| 74 virtual void Stop(); | 68 virtual void Stop(); |
| 75 virtual void DidBecomeSelected(); | 69 virtual void DidBecomeSelected(); |
| 76 virtual void WasHidden(); | 70 virtual void WasHidden(); |
| 77 virtual void Destroy(); | 71 virtual void Destroy(); |
| 78 virtual SkBitmap GetFavIcon(); | 72 virtual SkBitmap GetFavIcon(); |
| 79 virtual std::wstring GetStatusText() const; | 73 virtual std::wstring GetStatusText() const; |
| 80 | 74 |
| 81 // Find functions | 75 // Find functions |
| 82 virtual void StartFinding(int request_id, | 76 virtual void StartFinding(int request_id, |
| 83 const std::wstring& search_string, | 77 const std::wstring& search_string, |
| 84 bool forward, | 78 bool forward, |
| 85 bool match_case, | 79 bool match_case, |
| 86 bool find_next); | 80 bool find_next); |
| 87 virtual void StopFinding(bool clear_selection); | 81 virtual void StopFinding(bool clear_selection); |
| 88 virtual void OpenFindInPageWindow(const Browser& browser); | 82 virtual void OpenFindInPageWindow(const Browser& browser); |
| 89 virtual void ReparentFindWindow(HWND new_parent); | 83 virtual void ReparentFindWindow(HWND new_parent); |
| 90 virtual bool AdvanceFindSelection(bool forward_direction); | 84 virtual bool AdvanceFindSelection(bool forward_direction); |
| 91 virtual bool IsFindWindowFullyVisible(); | 85 virtual bool IsFindWindowFullyVisible(); |
| 92 virtual bool GetFindInPageWindowLocation(int* x, int* y); | 86 virtual bool GetFindInPageWindowLocation(int* x, int* y); |
| 93 | 87 |
| 94 // Text zoom | |
| 95 virtual void AlterTextSize(text_zoom::TextSize size); | |
| 96 | |
| 97 // Change encoding of page. | |
| 98 virtual void SetPageEncoding(const std::wstring& encoding_name); | |
| 99 | |
| 100 bool is_starred() const { return is_starred_; } | 88 bool is_starred() const { return is_starred_; } |
| 101 | 89 |
| 102 // Set whether the contents should block javascript message boxes or not. | 90 // Set whether the contents should block javascript message boxes or not. |
| 103 // Default is not to block any message boxes. | 91 // Default is not to block any message boxes. |
| 104 void SetSuppressJavascriptMessageBoxes(bool suppress_javascript_messages); | 92 void set_suppress_javascript_messages( |
| 93 bool suppress_javascript_messages) { |
| 94 suppress_javascript_messages_ = suppress_javascript_messages; |
| 95 } |
| 105 | 96 |
| 106 // Various other systems need to know about our interstitials. | 97 // Various other systems need to know about our interstitials. |
| 107 bool showing_interstitial_page() const { | 98 bool showing_interstitial_page() const { |
| 108 return render_manager_.showing_interstitial_page(); | 99 return render_manager_.showing_interstitial_page(); |
| 109 } | 100 } |
| 110 bool showing_repost_interstitial() const { | 101 bool showing_repost_interstitial() const { |
| 111 return render_manager_.showing_repost_interstitial(); | 102 return render_manager_.showing_repost_interstitial(); |
| 112 } | 103 } |
| 113 | 104 |
| 114 // Overridden from TabContents to remember at what time the download bar was | 105 // Overridden from TabContents to remember at what time the download bar was |
| 115 // shown. | 106 // shown. |
| 116 void SetDownloadShelfVisible(bool visible); | 107 void SetDownloadShelfVisible(bool visible); |
| 117 | 108 |
| 118 // Returns the SavePackage which manages the page saving job. | 109 // Returns the SavePackage which manages the page saving job. May be NULL. |
| 119 SavePackage* get_save_package() const { return save_package_.get(); } | 110 SavePackage* save_package() const { return save_package_.get(); } |
| 120 | 111 |
| 121 // Whether or not the info bar is visible. This delegates to | 112 // Whether or not the info bar is visible. This delegates to |
| 122 // the ChromeFrame method InfoBarVisibilityChanged. | 113 // the ChromeFrame method InfoBarVisibilityChanged. |
| 123 void SetInfoBarVisible(bool visible); | 114 void SetInfoBarVisible(bool visible); |
| 124 virtual bool IsInfoBarVisible() { return info_bar_visible_; } | 115 virtual bool IsInfoBarVisible() { return info_bar_visible_; } |
| 125 | 116 |
| 126 // Whether or not the FindInPage bar is visible. | 117 // Whether or not the FindInPage bar is visible. |
| 127 void SetFindInPageVisible(bool visible); | 118 void SetFindInPageVisible(bool visible); |
| 128 | 119 |
| 129 // Create the InfoBarView and returns it if none has been created. | 120 // Create the InfoBarView and returns it if none has been created. |
| 130 // Just returns existing InfoBarView if it is already created. | 121 // Just returns existing InfoBarView if it is already created. |
| 131 virtual InfoBarView* GetInfoBarView(); | 122 virtual InfoBarView* GetInfoBarView(); |
| 132 | 123 |
| 133 // Prepare for saving page. | 124 // Prepare for saving page. |
| 134 void OnSavePage(); | 125 void OnSavePage(); |
| 135 | 126 |
| 136 // Save page with the main HTML file path, the directory for saving resources, | 127 // Save page with the main HTML file path, the directory for saving resources, |
| 137 // and the save type: HTML only or complete web page. | 128 // and the save type: HTML only or complete web page. |
| 138 void SavePage(const std::wstring& main_file, const std::wstring& dir_path, | 129 void SavePage(const std::wstring& main_file, const std::wstring& dir_path, |
| 139 SavePackage::SavePackageType save_type); | 130 SavePackage::SavePackageType save_type); |
| 140 | 131 |
| 141 // Get all savable resource links from current webpage, include main | |
| 142 // frame and sub-frame. | |
| 143 void GetAllSavableResourceLinksForCurrentPage(const GURL& page_url); | |
| 144 | |
| 145 // Get html data by serializing all frames of current page with lists | |
| 146 // which contain all resource links that have local copy. | |
| 147 // The parameter links contain original URLs of all saved links. | |
| 148 // The parameter local_paths contain corresponding local file paths of | |
| 149 // all saved links, which matched with vector:links one by one. | |
| 150 // The parameter local_directory_name is relative path of directory which | |
| 151 // contain all saved auxiliary files included all sub frames and resouces. | |
| 152 void GetSerializedHtmlDataForCurrentPageWithLocalLinks( | |
| 153 const std::vector<std::wstring>& links, | |
| 154 const std::vector<std::wstring>& local_paths, | |
| 155 const std::wstring& local_directory_name); | |
| 156 | |
| 157 // Locates a sub frame with given xpath and executes the given | |
| 158 // javascript in its context. | |
| 159 void ExecuteJavascriptInWebFrame(const std::wstring& frame_xpath, | |
| 160 const std::wstring& jscript); | |
| 161 | |
| 162 // Locates a sub frame with given xpath and logs a message to its | |
| 163 // console. | |
| 164 void AddMessageToConsole(const std::wstring& frame_xpath, | |
| 165 const std::wstring& message, | |
| 166 ConsoleMessageLevel level); | |
| 167 | |
| 168 // Request the corresponding render view to perform these operations | |
| 169 void Undo(); | |
| 170 void Redo(); | |
| 171 void Replace(const std::wstring& text); | |
| 172 void AddToDictionary(const std::wstring& word); | |
| 173 void Delete(); | |
| 174 void SelectAll(); | |
| 175 | |
| 176 // Sets the WebApp for this WebContents. | 132 // Sets the WebApp for this WebContents. |
| 177 void SetWebApp(WebApp* web_app); | 133 void SetWebApp(WebApp* web_app); |
| 178 WebApp* web_app() { return web_app_.get(); } | 134 WebApp* web_app() { return web_app_.get(); } |
| 179 | 135 |
| 180 // Return whether this tab contents was created to contain an application. | 136 // Return whether this tab contents was created to contain an application. |
| 181 bool IsWebApplication() const; | 137 bool IsWebApplication() const; |
| 182 | 138 |
| 183 // Tell Gears to create a shortcut for the current page. | 139 // Tell Gears to create a shortcut for the current page. |
| 184 void CreateShortcut(); | 140 void CreateShortcut(); |
| 185 | 141 |
| 186 // Tell the render view to perform a file upload. |form| is the name or ID of | |
| 187 // the form that should be used to perform the upload. |file| is the name or | |
| 188 // ID of the file input that should be set to |file_path|. |submit| is the | |
| 189 // name or ID of the submit button. If non empty, the submit button will be | |
| 190 // pressed. If not, the form will be filled with the information but the user | |
| 191 // will perform the post operation. | |
| 192 // | |
| 193 // |other_values| contains a list of key value pairs separated by '\n'. | |
| 194 // Each key value pair is of the form key=value where key is a form name or | |
| 195 // ID and value is the desired value. | |
| 196 void StartFileUpload(const std::wstring& file_path, | |
| 197 const std::wstring& form, | |
| 198 const std::wstring& file, | |
| 199 const std::wstring& submit, | |
| 200 const std::wstring& other_values); | |
| 201 | |
| 202 // JavascriptMessageBoxHandler calls this when the dialog is closed. | 142 // JavascriptMessageBoxHandler calls this when the dialog is closed. |
| 203 void OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg, bool success, | 143 void OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg, bool success, |
| 204 const std::wstring& prompt); | 144 const std::wstring& prompt); |
| 205 | 145 |
| 206 void CopyImageAt(int x, int y); | |
| 207 void InspectElementAt(int x, int y); | |
| 208 void ShowJavaScriptConsole(); | |
| 209 void AllowDomAutomationBindings(); | |
| 210 | |
| 211 // Tell the render view to fill in a form and optionally submit it. | |
| 212 void FillForm(const FormData& form); | |
| 213 | |
| 214 // Tell the render view to fill a password form and trigger autocomplete | |
| 215 // in the case of multiple matching logins. | |
| 216 void FillPasswordForm(const PasswordFormDomManager::FillData& form_data); | |
| 217 | |
| 218 // D&d drop target messages that get forwarded on to the render view host. | |
| 219 void DragTargetDragEnter(const WebDropData& drop_data, | |
| 220 const gfx::Point& client_pt, | |
| 221 const gfx::Point& screen_pt); | |
| 222 void DragTargetDragOver(const gfx::Point& client_pt, | |
| 223 const gfx::Point& screen_pt); | |
| 224 void DragTargetDragLeave(); | |
| 225 void DragTargetDrop(const gfx::Point& client_pt, | |
| 226 const gfx::Point& screen_pt); | |
| 227 | |
| 228 // Called by PluginInstaller to start installation of missing plugin. | |
| 229 void InstallMissingPlugin(); | |
| 230 | |
| 231 // Returns the PasswordManager, creating it if necessary. | 146 // Returns the PasswordManager, creating it if necessary. |
| 232 PasswordManager* GetPasswordManager(); | 147 PasswordManager* GetPasswordManager(); |
| 233 | 148 |
| 234 // Returns the PluginInstaller, creating it if necessary. | 149 // Returns the PluginInstaller, creating it if necessary. |
| 235 PluginInstaller* GetPluginInstaller(); | 150 PluginInstaller* GetPluginInstaller(); |
| 236 | 151 |
| 237 // Return the currently active RenderProcessHost, RenderViewHost, and | 152 // Return the currently active RenderProcessHost, RenderViewHost, and |
| 238 // SiteInstance, respectively. Each of these may change over time. Callers | 153 // SiteInstance, respectively. Each of these may change over time. Callers |
| 239 // should be aware that the SiteInstance could be deleted if its ref count | 154 // should be aware that the SiteInstance could be deleted if its ref count |
| 240 // drops to zero (i.e., if all RenderViewHosts and NavigationEntries that | 155 // drops to zero (i.e., if all RenderViewHosts and NavigationEntries that |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 // Returns true if this WebContents will notify about disconnection. | 238 // Returns true if this WebContents will notify about disconnection. |
| 324 bool notify_disconnection() const { return notify_disconnection_; } | 239 bool notify_disconnection() const { return notify_disconnection_; } |
| 325 | 240 |
| 326 protected: | 241 protected: |
| 327 FRIEND_TEST(WebContentsTest, UpdateTitle); | 242 FRIEND_TEST(WebContentsTest, UpdateTitle); |
| 328 | 243 |
| 329 // Should be deleted via CloseContents. | 244 // Should be deleted via CloseContents. |
| 330 virtual ~WebContents(); | 245 virtual ~WebContents(); |
| 331 | 246 |
| 332 // RenderViewHostDelegate | 247 // RenderViewHostDelegate |
| 333 virtual RenderViewHostDelegate::FindInPage* GetFindInPageDelegate(); | 248 virtual RenderViewHostDelegate::FindInPage* GetFindInPageDelegate() const; |
| 249 virtual RenderViewHostDelegate::Save* GetSaveDelegate() const; |
| 250 |
| 334 virtual Profile* GetProfile() const; | 251 virtual Profile* GetProfile() const; |
| 335 | 252 |
| 336 virtual void CreateView(int route_id, HANDLE modal_dialog_event); | 253 virtual void CreateView(int route_id, HANDLE modal_dialog_event); |
| 337 virtual void CreateWidget(int route_id); | 254 virtual void CreateWidget(int route_id); |
| 338 virtual void ShowView(int route_id, | 255 virtual void ShowView(int route_id, |
| 339 WindowOpenDisposition disposition, | 256 WindowOpenDisposition disposition, |
| 340 const gfx::Rect& initial_pos, | 257 const gfx::Rect& initial_pos, |
| 341 bool user_gesture); | 258 bool user_gesture); |
| 342 virtual void ShowWidget(int route_id, const gfx::Rect& initial_pos); | 259 virtual void ShowWidget(int route_id, const gfx::Rect& initial_pos); |
| 343 virtual void RendererReady(RenderViewHost* render_view_host); | 260 virtual void RendererReady(RenderViewHost* render_view_host); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 IPC::Message* reply_msg); | 325 IPC::Message* reply_msg); |
| 409 virtual void PasswordFormsSeen(const std::vector<PasswordForm>& forms); | 326 virtual void PasswordFormsSeen(const std::vector<PasswordForm>& forms); |
| 410 virtual void TakeFocus(bool reverse); | 327 virtual void TakeFocus(bool reverse); |
| 411 virtual void DidGetPrintedPagesCount(int cookie, int number_pages); | 328 virtual void DidGetPrintedPagesCount(int cookie, int number_pages); |
| 412 virtual void DidPrintPage(const ViewHostMsg_DidPrintPage_Params& params); | 329 virtual void DidPrintPage(const ViewHostMsg_DidPrintPage_Params& params); |
| 413 virtual GURL GetAlternateErrorPageURL() const; | 330 virtual GURL GetAlternateErrorPageURL() const; |
| 414 virtual WebPreferences GetWebkitPrefs(); | 331 virtual WebPreferences GetWebkitPrefs(); |
| 415 virtual void OnMissingPluginStatus(int status); | 332 virtual void OnMissingPluginStatus(int status); |
| 416 virtual void OnCrashedPlugin(const std::wstring& plugin_path); | 333 virtual void OnCrashedPlugin(const std::wstring& plugin_path); |
| 417 virtual void OnJSOutOfMemory(); | 334 virtual void OnJSOutOfMemory(); |
| 418 virtual void OnReceivedSavableResourceLinksForCurrentPage( | |
| 419 const std::vector<GURL>& resources_list, | |
| 420 const std::vector<GURL>& referrers_list, | |
| 421 const std::vector<GURL>& frames_list); | |
| 422 virtual void OnReceivedSerializedHtmlData(const GURL& frame_url, | |
| 423 const std::string& data, | |
| 424 int32 status); | |
| 425 virtual void ShouldClosePage(bool proceed) { | 335 virtual void ShouldClosePage(bool proceed) { |
| 426 render_manager_.ShouldClosePage(proceed); | 336 render_manager_.ShouldClosePage(proceed); |
| 427 } | 337 } |
| 428 virtual bool CanBlur() const; | 338 virtual bool CanBlur() const; |
| 429 virtual void RendererUnresponsive(RenderViewHost* render_view_host); | 339 virtual void RendererUnresponsive(RenderViewHost* render_view_host); |
| 430 virtual void RendererResponsive(RenderViewHost* render_view_host); | 340 virtual void RendererResponsive(RenderViewHost* render_view_host); |
| 431 virtual void LoadStateChanged(const GURL& url, net::LoadState load_state); | 341 virtual void LoadStateChanged(const GURL& url, net::LoadState load_state); |
| 432 | 342 |
| 433 // Notification that a page has an OpenSearch description document available | 343 // Notification that a page has an OpenSearch description document available |
| 434 // at url. This checks to see if we should generate a keyword based on the | 344 // at url. This checks to see if we should generate a keyword based on the |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 typedef base::hash_map<int, RenderWidgetHost*> PendingWidgets; | 649 typedef base::hash_map<int, RenderWidgetHost*> PendingWidgets; |
| 740 PendingWidgets pending_widgets_; | 650 PendingWidgets pending_widgets_; |
| 741 | 651 |
| 742 // Non-null if we're displaying content for a web app. | 652 // Non-null if we're displaying content for a web app. |
| 743 scoped_refptr<WebApp> web_app_; | 653 scoped_refptr<WebApp> web_app_; |
| 744 | 654 |
| 745 DISALLOW_COPY_AND_ASSIGN(WebContents); | 655 DISALLOW_COPY_AND_ASSIGN(WebContents); |
| 746 }; | 656 }; |
| 747 | 657 |
| 748 #endif // CHROME_BROWSER_WEB_CONTENTS_H_ | 658 #endif // CHROME_BROWSER_WEB_CONTENTS_H_ |
| OLD | NEW |