Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(873)

Side by Side Diff: chrome/browser/web_contents.h

Issue 5005: Reorganize the declarations to have some grouping and logical ordering in tab... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/tabs/tab_strip.cc ('k') | chrome/browser/web_contents.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 class PasswordManager; 21 class PasswordManager;
22 class PluginInstaller; 22 class PluginInstaller;
23 class RenderViewHost; 23 class RenderViewHost;
24 class RenderViewHostFactory; 24 class RenderViewHostFactory;
25 class RenderWidgetHost; 25 class RenderWidgetHost;
26 class RenderWidgetHostHWND; 26 class RenderWidgetHostHWND;
27 class SadTabView; 27 class SadTabView;
28 struct WebDropData; 28 struct WebDropData;
29 class WebDropTarget; 29 class WebDropTarget;
30 30
31 // WebContents represents the contents of a tab that shows web pages. It embeds
32 // a RenderViewHost (via RenderViewHostManager) to actually display the page.
31 class WebContents : public TabContents, 33 class WebContents : public TabContents,
32 public RenderViewHostDelegate, 34 public RenderViewHostDelegate,
33 public RenderViewHostManager::Delegate, 35 public RenderViewHostManager::Delegate,
34 public ChromeViews::HWNDViewContainer, 36 public ChromeViews::HWNDViewContainer,
35 public SelectFileDialog::Listener, 37 public SelectFileDialog::Listener,
38 public NotificationObserver,
36 public WebApp::Observer { 39 public WebApp::Observer {
37 public: 40 public:
38 // If instance is NULL, then creates a new process for this view. Otherwise 41 // If instance is NULL, then creates a new process for this view. Otherwise
39 // initialize with a process already created for a different WebContents. 42 // initialize with a process already created for a different WebContents.
40 // This will share the process between views in the same instance. If 43 // This will share the process between views in the same instance. If
41 // render_view_factory is NULL, this will create RenderViewHost objects 44 // render_view_factory is NULL, this will create RenderViewHost objects
42 // directly. 45 // directly.
43 WebContents(Profile* profile, 46 WebContents(Profile* profile,
44 SiteInstance* instance, 47 SiteInstance* instance,
45 RenderViewHostFactory* render_view_factory, 48 RenderViewHostFactory* render_view_factory,
46 int routing_id, 49 int routing_id,
47 HANDLE modal_dialog_event); 50 HANDLE modal_dialog_event);
48 51
49 static void RegisterUserPrefs(PrefService* prefs); 52 static void RegisterUserPrefs(PrefService* prefs);
50 53
51 virtual void CreateView(HWND parent_hwnd, const gfx::Rect& initial_bounds); 54 // Getters -------------------------------------------------------------------
52 virtual HWND GetContainerHWND() const { return GetHWND(); }
53 virtual void GetContainerBounds(gfx::Rect *out) const;
54 virtual void ShowContents();
55 virtual void HideContents();
56 virtual void SizeContents(const gfx::Size& size);
57 55
58 // TabContents 56 // Returns the PasswordManager, creating it if necessary.
57 PasswordManager* GetPasswordManager();
58
59 // Returns the PluginInstaller, creating it if necessary.
60 PluginInstaller* GetPluginInstaller();
61
62 // Returns the SavePackage which manages the page saving job. May be NULL.
63 SavePackage* save_package() const { return save_package_.get(); }
64
65 // Return the currently active RenderProcessHost, RenderViewHost, and
66 // SiteInstance, respectively. Each of these may change over time. Callers
67 // should be aware that the SiteInstance could be deleted if its ref count
68 // drops to zero (i.e., if all RenderViewHosts and NavigationEntries that
69 // use it are deleted).
70 RenderProcessHost* process() const {
71 return render_manager_.current_host()->process();
72 }
73 RenderViewHost* render_view_host() const {
74 return render_manager_.current_host();
75 }
76 RenderWidgetHostView* view() const {
77 return render_manager_.current_view();
78 }
79
80 bool is_starred() const { return is_starred_; }
81
82 // TabContents (public overrides) --------------------------------------------
83
84 virtual void Destroy();
59 virtual WebContents* AsWebContents() { return this; } 85 virtual WebContents* AsWebContents() { return this; }
60 virtual SiteInstance* GetSiteInstance() const { 86 virtual SiteInstance* GetSiteInstance() const;
61 return render_manager_.current_host()->site_instance(); 87 virtual SkBitmap GetFavIcon();
62 } 88 virtual std::wstring GetStatusText() const;
63 virtual bool NavigateToPendingEntry(bool reload); 89 virtual bool NavigateToPendingEntry(bool reload);
64 virtual void Stop(); 90 virtual void Stop();
65 virtual void DidBecomeSelected();
66 virtual void WasHidden();
67 virtual void Destroy();
68 virtual SkBitmap GetFavIcon();
69 virtual std::wstring GetStatusText() const;
70
71 // Find functions
72 virtual void StartFinding(int request_id, 91 virtual void StartFinding(int request_id,
73 const std::wstring& search_string, 92 const std::wstring& search_string,
74 bool forward, 93 bool forward,
75 bool match_case, 94 bool match_case,
76 bool find_next); 95 bool find_next);
77 virtual void StopFinding(bool clear_selection); 96 virtual void StopFinding(bool clear_selection);
78 virtual void OpenFindInPageWindow(const Browser& browser); 97 virtual void Cut();
79 virtual void ReparentFindWindow(HWND new_parent); 98 virtual void Copy();
80 virtual bool AdvanceFindSelection(bool forward_direction); 99 virtual void Paste();
81 virtual bool IsFindWindowFullyVisible(); 100 virtual void DidBecomeSelected();
82 virtual bool GetFindInPageWindowLocation(int* x, int* y); 101 virtual void WasHidden();
83 102 virtual void ShowContents();
84 bool is_starred() const { return is_starred_; } 103 virtual void HideContents();
85 104 virtual void SizeContents(const gfx::Size& size);
86 // Set whether the contents should block javascript message boxes or not. 105 virtual HWND GetContentHWND();
87 // Default is not to block any message boxes. 106 virtual void CreateView(HWND parent_hwnd, const gfx::Rect& initial_bounds);
88 void set_suppress_javascript_messages( 107 virtual HWND GetContainerHWND() const { return GetHWND(); }
89 bool suppress_javascript_messages) { 108 virtual void GetContainerBounds(gfx::Rect *out) const;
90 suppress_javascript_messages_ = suppress_javascript_messages;
91 }
92
93 // Various other systems need to know about our interstitials.
94 bool showing_interstitial_page() const {
95 return render_manager_.showing_interstitial_page();
96 }
97 bool showing_repost_interstitial() const {
98 return render_manager_.showing_repost_interstitial();
99 }
100
101 // Overridden from TabContents to remember at what time the download bar was
102 // shown.
103 void SetDownloadShelfVisible(bool visible);
104
105 // Returns the SavePackage which manages the page saving job. May be NULL.
106 SavePackage* save_package() const { return save_package_.get(); }
107
108 // Whether or not the info bar is visible. This delegates to
109 // the ChromeFrame method InfoBarVisibilityChanged.
110 void SetInfoBarVisible(bool visible);
111 virtual bool IsInfoBarVisible() { return info_bar_visible_; }
112
113 // Whether or not the FindInPage bar is visible.
114 void SetFindInPageVisible(bool visible);
115
116 // Create the InfoBarView and returns it if none has been created. 109 // Create the InfoBarView and returns it if none has been created.
117 // Just returns existing InfoBarView if it is already created. 110 // Just returns existing InfoBarView if it is already created.
118 virtual InfoBarView* GetInfoBarView(); 111 virtual InfoBarView* GetInfoBarView();
112 virtual bool IsInfoBarVisible() { return info_bar_visible_; }
113 virtual void SetDownloadShelfVisible(bool visible);
119 114
120 // Prepare for saving page. 115 // Find in page --------------------------------------------------------------
121 void OnSavePage();
122 116
123 // Save page with the main HTML file path, the directory for saving resources, 117 // TODO(brettw) these should be commented.
124 // and the save type: HTML only or complete web page. 118 void OpenFindInPageWindow(const Browser& browser);
125 void SavePage(const std::wstring& main_file, const std::wstring& dir_path, 119 void ReparentFindWindow(HWND new_parent);
126 SavePackage::SavePackageType save_type); 120 bool AdvanceFindSelection(bool forward_direction);
121 bool IsFindWindowFullyVisible();
122 bool GetFindInPageWindowLocation(int* x, int* y);
123 void SetFindInPageVisible(bool visible);
124
125 // Web apps ------------------------------------------------------------------
127 126
128 // Sets the WebApp for this WebContents. 127 // Sets the WebApp for this WebContents.
129 void SetWebApp(WebApp* web_app); 128 void SetWebApp(WebApp* web_app);
130 WebApp* web_app() { return web_app_.get(); } 129 WebApp* web_app() { return web_app_.get(); }
131 130
132 // Return whether this tab contents was created to contain an application. 131 // Return whether this tab contents was created to contain an application.
133 bool IsWebApplication() const; 132 bool IsWebApplication() const;
134 133
135 // Tell Gears to create a shortcut for the current page. 134 // Tell Gears to create a shortcut for the current page.
136 void CreateShortcut(); 135 void CreateShortcut();
137 136
138 // JavascriptMessageBoxHandler calls this when the dialog is closed. 137 // Interstitials -------------------------------------------------------------
139 void OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg, bool success,
140 const std::wstring& prompt);
141 138
142 // Returns the PasswordManager, creating it if necessary. 139 // Various other systems need to know about our interstitials.
143 PasswordManager* GetPasswordManager(); 140 bool showing_interstitial_page() const {
144 141 return render_manager_.showing_interstitial_page();
145 // Returns the PluginInstaller, creating it if necessary.
146 PluginInstaller* GetPluginInstaller();
147
148 // Return the currently active RenderProcessHost, RenderViewHost, and
149 // SiteInstance, respectively. Each of these may change over time. Callers
150 // should be aware that the SiteInstance could be deleted if its ref count
151 // drops to zero (i.e., if all RenderViewHosts and NavigationEntries that
152 // use it are deleted).
153 RenderProcessHost* process() const {
154 return render_manager_.current_host()->process();
155 } 142 }
156 RenderViewHost* render_view_host() const { 143 bool showing_repost_interstitial() const {
157 return render_manager_.current_host(); 144 return render_manager_.showing_repost_interstitial();
158 } 145 }
159 RenderWidgetHostView* view() const {
160 return render_manager_.current_view();
161 }
162
163 // Overridden from TabContents to return the window of the
164 // RenderWidgetHostView.
165 virtual HWND GetContentHWND();
166
167 // Handling the drag and drop of files into the content area.
168 virtual bool CanDisplayFile(const std::wstring& full_path);
169
170 // Displays asynchronously a print preview (generated by the renderer) if not
171 // already displayed and ask the user for its preferred print settings with
172 // the "Print..." dialog box. (managed by the print worker thread).
173 // TODO(maruel): Creates a snapshot of the renderer to be used for the new
174 // tab for the printing facility.
175 void PrintPreview();
176
177 // Prints the current document immediately. Since the rendering is
178 // asynchronous, the actual printing will not be completed on the return of
179 // this function. Returns false if printing is impossible at the moment.
180 bool PrintNow();
181
182 virtual void WillCaptureContents();
183 virtual void DidCaptureContents();
184
185 virtual void Cut();
186 virtual void Copy();
187 virtual void Paste();
188 146
189 // The rest of the system wants to interact with the delegate our render view 147 // The rest of the system wants to interact with the delegate our render view
190 // host manager has. See those setters for more. 148 // host manager has. See those setters for more.
191 InterstitialPageDelegate* interstitial_page_delegate() const { 149 InterstitialPageDelegate* interstitial_page_delegate() const {
192 return render_manager_.interstitial_delegate(); 150 return render_manager_.interstitial_delegate();
193 } 151 }
194 void set_interstitial_delegate(InterstitialPageDelegate* delegate) { 152 void set_interstitial_delegate(InterstitialPageDelegate* delegate) {
195 render_manager_.set_interstitial_delegate(delegate); 153 render_manager_.set_interstitial_delegate(delegate);
196 } 154 }
197 155
(...skipping 10 matching lines...) Expand all
208 // If |wait_for_navigation| is true, the interstitial page is removed when 166 // If |wait_for_navigation| is true, the interstitial page is removed when
209 // the original page has transitioned to the new contents. This is useful 167 // the original page has transitioned to the new contents. This is useful
210 // when you want to hide the interstitial page as you navigate to a new page. 168 // when you want to hide the interstitial page as you navigate to a new page.
211 // Hiding the interstitial page right away would show the previous displayed 169 // Hiding the interstitial page right away would show the previous displayed
212 // page. If |proceed| is true, the WebContents will expect the navigation 170 // page. If |proceed| is true, the WebContents will expect the navigation
213 // to complete. If not, it will revert to the last shown page. 171 // to complete. If not, it will revert to the last shown page.
214 void HideInterstitialPage(bool wait_for_navigation, bool proceed) { 172 void HideInterstitialPage(bool wait_for_navigation, bool proceed) {
215 render_manager_.HideInterstitialPage(wait_for_navigation, proceed); 173 render_manager_.HideInterstitialPage(wait_for_navigation, proceed);
216 } 174 }
217 175
218 // Allows the WebContents to react when a cross-site response is ready to be 176 // Misc state & callbacks ----------------------------------------------------
219 // delivered to a pending RenderViewHost. We must first run the onunload 177
220 // handler of the old RenderViewHost before we can allow it to proceed. 178 // Set whether the contents should block javascript message boxes or not.
221 void OnCrossSiteResponse(int new_render_process_host_id, 179 // Default is not to block any message boxes.
222 int new_request_id) { 180 void set_suppress_javascript_messages(
223 render_manager_.OnCrossSiteResponse(new_render_process_host_id, 181 bool suppress_javascript_messages) {
224 new_request_id); 182 suppress_javascript_messages_ = suppress_javascript_messages;
225 } 183 }
226 184
185 // JavascriptMessageBoxHandler calls this when the dialog is closed.
186 void OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg,
187 bool success,
188 const std::wstring& prompt);
189
190 // Whether or not the info bar is visible. This delegates to
191 // the ChromeFrame method InfoBarVisibilityChanged. See also IsInfoBarVisible
192 // (a TabContents override).
193 void SetInfoBarVisible(bool visible);
194
195 // Prepare for saving page.
196 void OnSavePage();
197
198 // Save page with the main HTML file path, the directory for saving resources,
199 // and the save type: HTML only or complete web page.
200 void SavePage(const std::wstring& main_file, const std::wstring& dir_path,
201 SavePackage::SavePackageType save_type);
202
203 // Displays asynchronously a print preview (generated by the renderer) if not
204 // already displayed and ask the user for its preferred print settings with
205 // the "Print..." dialog box. (managed by the print worker thread).
206 // TODO(maruel): Creates a snapshot of the renderer to be used for the new
207 // tab for the printing facility.
208 void PrintPreview();
209
210 // Prints the current document immediately. Since the rendering is
211 // asynchronous, the actual printing will not be completed on the return of
212 // this function. Returns false if printing is impossible at the moment.
213 bool PrintNow();
214
227 // Returns true if the active NavigationEntry's page_id equals page_id. 215 // Returns true if the active NavigationEntry's page_id equals page_id.
228 bool IsActiveEntry(int32 page_id); 216 bool IsActiveEntry(int32 page_id);
229 217
230 const std::string& contents_mime_type() const { 218 const std::string& contents_mime_type() const {
231 return contents_mime_type_; 219 return contents_mime_type_;
232 } 220 }
233 221
234 // Returns true if this WebContents will notify about disconnection. 222 // Returns true if this WebContents will notify about disconnection.
235 bool notify_disconnection() const { return notify_disconnection_; } 223 bool notify_disconnection() const { return notify_disconnection_; }
236 224
237 protected: 225 protected:
238 FRIEND_TEST(WebContentsTest, UpdateTitle);
239
240 // Should be deleted via CloseContents. 226 // Should be deleted via CloseContents.
241 virtual ~WebContents(); 227 virtual ~WebContents();
242 228
243 // RenderViewHostDelegate 229 // TabContents (private overrides) -------------------------------------------
230
231 virtual void SetInitialFocus(bool reverse);
232 virtual void SetIsLoading(bool is_loading, LoadNotificationDetails* details);
233
234 // RenderViewHostDelegate ----------------------------------------------------
235
244 virtual RenderViewHostDelegate::FindInPage* GetFindInPageDelegate() const; 236 virtual RenderViewHostDelegate::FindInPage* GetFindInPageDelegate() const;
245 virtual RenderViewHostDelegate::Save* GetSaveDelegate() const; 237 virtual RenderViewHostDelegate::Save* GetSaveDelegate() const;
246
247 virtual Profile* GetProfile() const; 238 virtual Profile* GetProfile() const;
248
249 virtual void CreateView(int route_id, HANDLE modal_dialog_event); 239 virtual void CreateView(int route_id, HANDLE modal_dialog_event);
250 virtual void CreateWidget(int route_id); 240 virtual void CreateWidget(int route_id);
251 virtual void ShowView(int route_id, 241 virtual void ShowView(int route_id,
252 WindowOpenDisposition disposition, 242 WindowOpenDisposition disposition,
253 const gfx::Rect& initial_pos, 243 const gfx::Rect& initial_pos,
254 bool user_gesture); 244 bool user_gesture);
255 virtual void ShowWidget(int route_id, const gfx::Rect& initial_pos); 245 virtual void ShowWidget(int route_id, const gfx::Rect& initial_pos);
256 virtual void RendererReady(RenderViewHost* render_view_host); 246 virtual void RendererReady(RenderViewHost* render_view_host);
257 virtual void RendererGone(RenderViewHost* render_view_host); 247 virtual void RendererGone(RenderViewHost* render_view_host);
258 virtual void DidNavigate(RenderViewHost* render_view_host, 248 virtual void DidNavigate(RenderViewHost* render_view_host,
259 const ViewHostMsg_FrameNavigate_Params& params); 249 const ViewHostMsg_FrameNavigate_Params& params);
260 virtual void UpdateRenderViewSize();
261 virtual void UpdateState(RenderViewHost* render_view_host, 250 virtual void UpdateState(RenderViewHost* render_view_host,
262 int32 page_id, 251 int32 page_id,
263 const GURL& url, 252 const GURL& url,
264 const std::wstring& title, 253 const std::wstring& title,
265 const std::string& state); 254 const std::string& state);
266 virtual void UpdateTitle(RenderViewHost* render_view_host, 255 virtual void UpdateTitle(RenderViewHost* render_view_host,
267 int32 page_id, 256 int32 page_id,
268 const std::wstring& title); 257 const std::wstring& title);
269 virtual void UpdateEncoding(RenderViewHost* render_view_host, 258 virtual void UpdateEncoding(RenderViewHost* render_view_host,
270 const std::wstring& encoding_name); 259 const std::wstring& encoding_name);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 const std::wstring& default_prompt, 303 const std::wstring& default_prompt,
315 const int flags, 304 const int flags,
316 IPC::Message* reply_msg); 305 IPC::Message* reply_msg);
317 virtual void RunBeforeUnloadConfirm(const std::wstring& message, 306 virtual void RunBeforeUnloadConfirm(const std::wstring& message,
318 IPC::Message* reply_msg); 307 IPC::Message* reply_msg);
319 virtual void ShowModalHTMLDialog(const GURL& url, int width, int height, 308 virtual void ShowModalHTMLDialog(const GURL& url, int width, int height,
320 const std::string& json_arguments, 309 const std::string& json_arguments,
321 IPC::Message* reply_msg); 310 IPC::Message* reply_msg);
322 virtual void PasswordFormsSeen(const std::vector<PasswordForm>& forms); 311 virtual void PasswordFormsSeen(const std::vector<PasswordForm>& forms);
323 virtual void TakeFocus(bool reverse); 312 virtual void TakeFocus(bool reverse);
313 virtual void PageHasOSDD(RenderViewHost* render_view_host,
314 int32 page_id, const GURL& url, bool autodetected);
315 virtual void InspectElementReply(int num_resources);
324 virtual void DidGetPrintedPagesCount(int cookie, int number_pages); 316 virtual void DidGetPrintedPagesCount(int cookie, int number_pages);
325 virtual void DidPrintPage(const ViewHostMsg_DidPrintPage_Params& params); 317 virtual void DidPrintPage(const ViewHostMsg_DidPrintPage_Params& params);
318 virtual void HandleKeyboardEvent(const WebKeyboardEvent& event);
326 virtual GURL GetAlternateErrorPageURL() const; 319 virtual GURL GetAlternateErrorPageURL() const;
327 virtual WebPreferences GetWebkitPrefs(); 320 virtual WebPreferences GetWebkitPrefs();
328 virtual void OnMissingPluginStatus(int status); 321 virtual void OnMissingPluginStatus(int status);
329 virtual void OnCrashedPlugin(const std::wstring& plugin_path); 322 virtual void OnCrashedPlugin(const std::wstring& plugin_path);
330 virtual void OnJSOutOfMemory(); 323 virtual void OnJSOutOfMemory();
331 virtual void ShouldClosePage(bool proceed) { 324 virtual void ShouldClosePage(bool proceed) {
332 render_manager_.ShouldClosePage(proceed); 325 render_manager_.ShouldClosePage(proceed);
333 } 326 }
327 // Allows the WebContents to react when a cross-site response is ready to be
328 // delivered to a pending RenderViewHost. We must first run the onunload
329 // handler of the old RenderViewHost before we can allow it to proceed.
330 void OnCrossSiteResponse(int new_render_process_host_id,
331 int new_request_id) {
332 render_manager_.OnCrossSiteResponse(new_render_process_host_id,
333 new_request_id);
334 }
334 virtual bool CanBlur() const; 335 virtual bool CanBlur() const;
335 virtual void RendererUnresponsive(RenderViewHost* render_view_host); 336 virtual void RendererUnresponsive(RenderViewHost* render_view_host);
336 virtual void RendererResponsive(RenderViewHost* render_view_host); 337 virtual void RendererResponsive(RenderViewHost* render_view_host);
337 virtual void LoadStateChanged(const GURL& url, net::LoadState load_state); 338 virtual void LoadStateChanged(const GURL& url, net::LoadState load_state);
338
339 // Notification that a page has an OpenSearch description document available
340 // at url. This checks to see if we should generate a keyword based on the
341 // OSDD, and if necessary uses TemplateURLFetcher to download the OSDD
342 // and create a keyword.
343 virtual void PageHasOSDD(RenderViewHost* render_view_host,
344 int32 page_id, const GURL& url, bool autodetected);
345
346 virtual void OnDidGetApplicationInfo( 339 virtual void OnDidGetApplicationInfo(
347 int32 page_id, 340 int32 page_id,
348 const webkit_glue::WebApplicationInfo& info); 341 const webkit_glue::WebApplicationInfo& info);
349 342
350 // Overridden from TabContents. 343 // SelectFileDialog::Listener ------------------------------------------------
351 virtual void SetInitialFocus(bool reverse);
352 344
353 // Handle reply from inspect element request
354 virtual void InspectElementReply(int num_resources);
355
356 // Handle keyboard events not processed by the renderer.
357 virtual void HandleKeyboardEvent(const WebKeyboardEvent& event);
358
359 // Notifies the RenderWidgetHost instance about the fact that the
360 // page is loading, or done loading and calls the base implementation.
361 void SetIsLoading(bool is_loading, LoadNotificationDetails* details);
362
363 // Overridden from SelectFileDialog::Listener:
364 virtual void FileSelected(const std::wstring& path, void* params); 345 virtual void FileSelected(const std::wstring& path, void* params);
365 virtual void FileSelectionCanceled(void* params); 346 virtual void FileSelectionCanceled(void* params);
366 347
367 // Another part of RenderViewHostManager::Delegate. 348 // RenderViewHostManager::Delegate -------------------------------------------
368 // 349
350 virtual void BeforeUnloadFiredFromRenderManager(
351 bool proceed,
352 bool* proceed_to_fire_unload);
353 virtual void DidStartLoadingFromRenderManager(
354 RenderViewHost* render_view_host, int32 page_id) {
355 DidStartLoading(render_view_host, page_id);
356 }
357 virtual void RendererGoneFromRenderManager(RenderViewHost* render_view_host) {
358 RendererGone(render_view_host);
359 }
360 virtual void UpdateRenderViewSizeForRenderManager();
361 virtual void NotifySwappedFromRenderManager() {
362 NotifySwapped();
363 }
364 virtual NavigationController* GetControllerForRenderManager() {
365 return controller();
366 }
367
369 // Initializes the given renderer if necessary and creates the view ID 368 // Initializes the given renderer if necessary and creates the view ID
370 // corresponding to this view host. If this method is not called and the 369 // corresponding to this view host. If this method is not called and the
371 // process is not shared, then the WebContents will act as though the renderer 370 // process is not shared, then the WebContents will act as though the renderer
372 // is not running (i.e., it will render "sad tab"). This method is 371 // is not running (i.e., it will render "sad tab"). This method is
373 // automatically called from LoadURL. 372 // automatically called from LoadURL.
374 // 373 //
375 // If you are attaching to an already-existing RenderView, you should call 374 // If you are attaching to an already-existing RenderView, you should call
376 // InitWithExistingID. 375 // InitWithExistingID.
377 // 376 //
378 // TODO(brettw) clean this up! This logic seems out of place. This is called 377 // TODO(brettw) clean this up! This logic seems out of place. This is called
379 // by the RenderViewHostManager, but also overridden by the DOMUIHost. Any 378 // by the RenderViewHostManager, but also overridden by the DOMUIHost. Any
380 // logic that has to be here should have a more clear name. 379 // logic that has to be here should have a more clear name.
381 virtual bool CreateRenderViewForRenderManager( 380 virtual bool CreateRenderViewForRenderManager(
382 RenderViewHost* render_view_host); 381 RenderViewHost* render_view_host);
383 382
384 private: 383 private:
384 FRIEND_TEST(WebContentsTest, UpdateTitle);
385 friend class TestWebContents; 385 friend class TestWebContents;
386 386
387 // When CreateShortcut is invoked RenderViewHost::GetApplicationInfo is 387 // When CreateShortcut is invoked RenderViewHost::GetApplicationInfo is
388 // invoked. CreateShortcut caches the state of the page needed to create the 388 // invoked. CreateShortcut caches the state of the page needed to create the
389 // shortcut in PendingInstall. When OnDidGetApplicationInfo is invoked, it 389 // shortcut in PendingInstall. When OnDidGetApplicationInfo is invoked, it
390 // uses the information from PendingInstall and the WebApplicationInfo 390 // uses the information from PendingInstall and the WebApplicationInfo
391 // to create the shortcut. 391 // to create the shortcut.
392 class GearsCreateShortcutCallbackFunctor; 392 class GearsCreateShortcutCallbackFunctor;
393 struct PendingInstall { 393 struct PendingInstall {
394 int32 page_id; 394 int32 page_id;
395 SkBitmap icon; 395 SkBitmap icon;
396 std::wstring title; 396 std::wstring title;
397 GURL url; 397 GURL url;
398 // This object receives the GearsCreateShortcutCallback and routes the 398 // This object receives the GearsCreateShortcutCallback and routes the
399 // message back to the WebContents, if we haven't been deleted. 399 // message back to the WebContents, if we haven't been deleted.
400 GearsCreateShortcutCallbackFunctor* callback_functor; 400 GearsCreateShortcutCallbackFunctor* callback_functor;
401 }; 401 };
402 402
403 void ScrollCommon(UINT message, int scroll_type, short position, 403 // NotificationObserver ------------------------------------------------------
404 HWND scrollbar);
405 bool ScrollZoom(int scroll_type);
406 void WheelZoom(int distance);
407 404
408 // Backend for LoadURL that optionally creates a history entry. The 405 virtual void Observe(NotificationType type,
409 // transition type will be ignored if a history entry is not created. 406 const NotificationSource& source,
410 void LoadURL(const std::wstring& url, bool create_history_entry, 407 const NotificationDetails& details);
411 PageTransition::Type transition);
412 408
413 // Windows Event handlers 409 // Windows events ------------------------------------------------------------
410
414 virtual void OnDestroy(); 411 virtual void OnDestroy();
415 virtual void OnHScroll(int scroll_type, short position, HWND scrollbar); 412 virtual void OnHScroll(int scroll_type, short position, HWND scrollbar);
416 virtual void OnMouseLeave(); 413 virtual void OnMouseLeave();
417 virtual LRESULT OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param); 414 virtual LRESULT OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param);
418 virtual void OnPaint(HDC junk_dc); 415 virtual void OnPaint(HDC junk_dc);
419 virtual LRESULT OnReflectedMessage(UINT msg, WPARAM w_param, LPARAM l_param); 416 virtual LRESULT OnReflectedMessage(UINT msg, WPARAM w_param, LPARAM l_param);
420 virtual void OnSetFocus(HWND window); 417 virtual void OnSetFocus(HWND window);
421 virtual void OnVScroll(int scroll_type, short position, HWND scrollbar); 418 virtual void OnVScroll(int scroll_type, short position, HWND scrollbar);
422 virtual void OnWindowPosChanged(WINDOWPOS* window_pos); 419 virtual void OnWindowPosChanged(WINDOWPOS* window_pos);
423 virtual void OnSize(UINT param, const CSize& size); 420 virtual void OnSize(UINT param, const CSize& size);
424 virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param); 421 virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param);
425 virtual void OnNCPaint(HRGN rgn); 422 virtual void OnNCPaint(HRGN rgn);
426 423
427 // Callback from HistoryService for our request for a favicon. 424 // Backend for all scroll messages, the |message| parameter indicates which
428 void OnFavIconData(HistoryService::Handle handle, 425 // one it is.
429 bool know_favicon, 426 void ScrollCommon(UINT message, int scroll_type, short position,
430 scoped_refptr<RefCountedBytes> data, 427 HWND scrollbar);
431 bool expired);
432 428
433 // NotificationObserver implementation. 429 // TODO(brettw) comment these. They're confusing.
434 virtual void Observe(NotificationType type, 430 bool ScrollZoom(int scroll_type);
435 const NotificationSource& source, 431 void WheelZoom(int distance);
436 const NotificationDetails& details);
437
438 // Helper functions for sending notifications.
439 void NotifySwapped();
440 void NotifyConnected();
441 void NotifyDisconnected();
442
443 // Called by OnMsgNavigate to update history state.
444 virtual void UpdateHistoryForNavigation(const GURL& display_url,
445 const ViewHostMsg_FrameNavigate_Params& params);
446
447 // If params has a searchable form, this tries to create a new keyword.
448 void GenerateKeywordIfNecessary(
449 const ViewHostMsg_FrameNavigate_Params& params);
450
451 // Sets up the View that holds the rendered web page, receives messages for
452 // it and contains page plugins.
453 RenderWidgetHostHWND* CreatePageView(RenderViewHost* render_view_host);
454 432
455 // Navigation helpers -------------------------------------------------------- 433 // Navigation helpers --------------------------------------------------------
456 // 434 //
457 // These functions are helpers for Navigate() and DidNavigate(). 435 // These functions are helpers for Navigate() and DidNavigate().
458 436
459 // Handles post-navigation tasks in DidNavigate AFTER the entry has been 437 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
460 // committed to the navigation controller. Note that the navigation entry is 438 // committed to the navigation controller. Note that the navigation entry is
461 // not provided since it may be invalid/changed after being committed. The 439 // not provided since it may be invalid/changed after being committed. The
462 // current navigation entry is in the NavigationController at this point. 440 // current navigation entry is in the NavigationController at this point.
463 void DidNavigateMainFramePostCommit( 441 void DidNavigateMainFramePostCommit(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // true if the shortcut was created. 476 // true if the shortcut was created.
499 void OnGearsCreateShortcutDone(const GearsShortcutData& shortcut_data, 477 void OnGearsCreateShortcutDone(const GearsShortcutData& shortcut_data,
500 bool success); 478 bool success);
501 479
502 // If our controller was restored and the page id is > than the site 480 // If our controller was restored and the page id is > than the site
503 // instance's page id, the site instances page id is updated as well as the 481 // instance's page id, the site instances page id is updated as well as the
504 // renderers max page id. 482 // renderers max page id.
505 void UpdateMaxPageIDIfNecessary(SiteInstance* site_instance, 483 void UpdateMaxPageIDIfNecessary(SiteInstance* site_instance,
506 RenderViewHost* rvh); 484 RenderViewHost* rvh);
507 485
508 // RenderViewHostManager::Delegate pass-throughs ----------------------------- 486 // Called by OnMsgNavigate to update history state. Overridden by subclasses
487 // that don't want to be added to history.
488 virtual void UpdateHistoryForNavigation(const GURL& display_url,
489 const ViewHostMsg_FrameNavigate_Params& params);
509 490
510 virtual void BeforeUnloadFiredFromRenderManager( 491 // Misc view stuff -----------------------------------------------------------
511 bool proceed,
512 bool* proceed_to_fire_unload);
513 virtual void DidStartLoadingFromRenderManager(
514 RenderViewHost* render_view_host, int32 page_id) {
515 DidStartLoading(render_view_host, page_id);
516 }
517 virtual void RendererGoneFromRenderManager(RenderViewHost* render_view_host) {
518 RendererGone(render_view_host);
519 }
520 virtual void UpdateRenderViewSizeForRenderManager() {
521 UpdateRenderViewSize();
522 }
523 virtual void NotifySwappedFromRenderManager() {
524 NotifySwapped();
525 }
526 virtual NavigationController* GetControllerForRenderManager() {
527 return controller();
528 }
529 492
530 // --------------------------------------------------------------------------- 493 // Sets up the View that holds the rendered web page, receives messages for
494 // it and contains page plugins.
495 RenderWidgetHostHWND* CreatePageView(RenderViewHost* render_view_host);
531 496
532 // Enumerate and 'un-parent' any plugin windows that are children 497 // Enumerate and 'un-parent' any plugin windows that are children
533 // of this web contents. 498 // of this web contents.
534 void DetachPluginWindows(); 499 void DetachPluginWindows();
535 static BOOL CALLBACK EnumPluginWindowsCallback(HWND window, LPARAM param); 500 static BOOL CALLBACK EnumPluginWindowsCallback(HWND window, LPARAM param);
536 501
502 // Misc non-view stuff -------------------------------------------------------
503
504 // Helper functions for sending notifications.
505 void NotifySwapped();
506 void NotifyConnected();
507 void NotifyDisconnected();
508
509 // If params has a searchable form, this tries to create a new keyword.
510 void GenerateKeywordIfNecessary(
511 const ViewHostMsg_FrameNavigate_Params& params);
512
537 // Data ---------------------------------------------------------------------- 513 // Data ----------------------------------------------------------------------
538 514
539 // Manages creation and swapping of render views. 515 // Manages creation and swapping of render views.
540 RenderViewHostManager render_manager_; 516 RenderViewHostManager render_manager_;
541 517
542 // For testing, passed to new RenderViewHost managers. 518 // For testing, passed to new RenderViewHost managers.
543 RenderViewHostFactory* render_view_factory_; 519 RenderViewHostFactory* render_view_factory_;
544 520
545 // Handles print preview and print job for this contents. 521 // Handles print preview and print job for this contents.
546 printing::PrintViewManager printing_; 522 printing::PrintViewManager printing_;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 572
597 // PluginInstaller, lazily created. 573 // PluginInstaller, lazily created.
598 scoped_ptr<PluginInstaller> plugin_installer_; 574 scoped_ptr<PluginInstaller> plugin_installer_;
599 575
600 // A drop target object that handles drags over this WebContents. 576 // A drop target object that handles drags over this WebContents.
601 scoped_refptr<WebDropTarget> drop_target_; 577 scoped_refptr<WebDropTarget> drop_target_;
602 578
603 // The SadTab renderer. 579 // The SadTab renderer.
604 scoped_ptr<SadTabView> sad_tab_; 580 scoped_ptr<SadTabView> sad_tab_;
605 581
606 // This flag is true while we are in the photo-booth. See dragged_tab.cc.
607 bool capturing_contents_;
608
609 // Handles downloading favicons. 582 // Handles downloading favicons.
610 FavIconHelper fav_icon_helper_; 583 FavIconHelper fav_icon_helper_;
611 584
612 // Dialog box used for choosing files to upload from file form fields. 585 // Dialog box used for choosing files to upload from file form fields.
613 scoped_refptr<SelectFileDialog> select_file_dialog_; 586 scoped_refptr<SelectFileDialog> select_file_dialog_;
614 587
615 // Info bar for crashed plugin message. 588 // Info bar for crashed plugin message.
616 // IMPORTANT: This instance is owned by the InfoBarView. It is valid 589 // IMPORTANT: This instance is owned by the InfoBarView. It is valid
617 // only if InfoBarView::GetChildIndex for this view is valid. 590 // only if InfoBarView::GetChildIndex for this view is valid.
618 InfoBarMessageView* crashed_plugin_info_bar_; 591 InfoBarMessageView* crashed_plugin_info_bar_;
(...skipping 26 matching lines...) Expand all
645 typedef base::hash_map<int, RenderWidgetHost*> PendingWidgets; 618 typedef base::hash_map<int, RenderWidgetHost*> PendingWidgets;
646 PendingWidgets pending_widgets_; 619 PendingWidgets pending_widgets_;
647 620
648 // Non-null if we're displaying content for a web app. 621 // Non-null if we're displaying content for a web app.
649 scoped_refptr<WebApp> web_app_; 622 scoped_refptr<WebApp> web_app_;
650 623
651 DISALLOW_COPY_AND_ASSIGN(WebContents); 624 DISALLOW_COPY_AND_ASSIGN(WebContents);
652 }; 625 };
653 626
654 #endif // CHROME_BROWSER_WEB_CONTENTS_H_ 627 #endif // CHROME_BROWSER_WEB_CONTENTS_H_
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/tab_strip.cc ('k') | chrome/browser/web_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698