OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 struct WebIntentServiceData; | 67 struct WebIntentServiceData; |
68 } | 68 } |
69 | 69 |
70 class CONTENT_EXPORT WebContentsImpl | 70 class CONTENT_EXPORT WebContentsImpl |
71 : public NON_EXPORTED_BASE(content::WebContents), | 71 : public NON_EXPORTED_BASE(content::WebContents), |
72 public content::RenderViewHostDelegate, | 72 public content::RenderViewHostDelegate, |
73 public content::RenderWidgetHostDelegate, | 73 public content::RenderWidgetHostDelegate, |
74 public RenderViewHostManager::Delegate, | 74 public RenderViewHostManager::Delegate, |
75 public content::NotificationObserver { | 75 public content::NotificationObserver { |
76 public: | 76 public: |
77 // See WebContents::Create for a description of these parameters. | |
78 WebContentsImpl(content::BrowserContext* browser_context, | |
79 content::SiteInstance* site_instance, | |
80 int routing_id, | |
81 const WebContentsImpl* base_web_contents, | |
82 WebContentsImpl* opener, | |
83 SessionStorageNamespaceImpl* session_storage_namespace); | |
84 virtual ~WebContentsImpl(); | 77 virtual ~WebContentsImpl(); |
85 | 78 |
| 79 static WebContentsImpl* Create( |
| 80 content::BrowserContext* browser_context, |
| 81 content::SiteInstance* site_instance, |
| 82 int routing_id, |
| 83 const WebContentsImpl* base_web_contents); |
| 84 |
| 85 static WebContentsImpl* CreateWithOpener( |
| 86 content::BrowserContext* browser_context, |
| 87 content::SiteInstance* site_instance, |
| 88 int routing_id, |
| 89 const WebContentsImpl* base_web_contents, |
| 90 WebContentsImpl* opener); |
| 91 |
86 // Returns the content specific prefs for the given RVH. | 92 // Returns the content specific prefs for the given RVH. |
87 static webkit_glue::WebPreferences GetWebkitPrefs( | 93 static webkit_glue::WebPreferences GetWebkitPrefs( |
88 content::RenderViewHost* rvh, const GURL& url); | 94 content::RenderViewHost* rvh, const GURL& url); |
89 | 95 |
| 96 // Complex initialization here. Specifically needed to avoid having |
| 97 // members call back into our virtual functions in the constructor. |
| 98 virtual void Init(content::BrowserContext* browser_context, |
| 99 content::SiteInstance* site_instance, |
| 100 int routing_id, |
| 101 const content::WebContents* base_web_contents); |
| 102 |
90 // Returns the SavePackage which manages the page saving job. May be NULL. | 103 // Returns the SavePackage which manages the page saving job. May be NULL. |
91 SavePackage* save_package() const { return save_package_.get(); } | 104 SavePackage* save_package() const { return save_package_.get(); } |
92 | 105 |
93 // Updates the max page ID for the current SiteInstance in this | 106 // Updates the max page ID for the current SiteInstance in this |
94 // WebContentsImpl to be at least |page_id|. | 107 // WebContentsImpl to be at least |page_id|. |
95 void UpdateMaxPageID(int32 page_id); | 108 void UpdateMaxPageID(int32 page_id); |
96 | 109 |
97 // Updates the max page ID for the given SiteInstance in this WebContentsImpl | 110 // Updates the max page ID for the given SiteInstance in this WebContentsImpl |
98 // to be at least |page_id|. | 111 // to be at least |page_id|. |
99 void UpdateMaxPageIDForSiteInstance(content::SiteInstance* site_instance, | 112 void UpdateMaxPageIDForSiteInstance(content::SiteInstance* site_instance, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 152 } |
140 | 153 |
141 JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const { | 154 JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const { |
142 return java_bridge_dispatcher_host_manager_.get(); | 155 return java_bridge_dispatcher_host_manager_.get(); |
143 } | 156 } |
144 | 157 |
145 content::BrowserPluginHost* browser_plugin_host() const { | 158 content::BrowserPluginHost* browser_plugin_host() const { |
146 return browser_plugin_host_.get(); | 159 return browser_plugin_host_.get(); |
147 } | 160 } |
148 | 161 |
149 // Like GetController from WebContents, but returns the concrete object. | |
150 NavigationControllerImpl& GetControllerImpl(); | |
151 | |
152 // Expose the render manager for testing. | 162 // Expose the render manager for testing. |
153 RenderViewHostManager* GetRenderManagerForTesting(); | 163 RenderViewHostManager* GetRenderManagerForTesting(); |
154 | 164 |
155 // content::WebContents ------------------------------------------------------ | 165 // content::WebContents ------------------------------------------------------ |
156 virtual const base::PropertyBag* GetPropertyBag() const OVERRIDE; | 166 virtual const base::PropertyBag* GetPropertyBag() const OVERRIDE; |
157 virtual base::PropertyBag* GetPropertyBag() OVERRIDE; | 167 virtual base::PropertyBag* GetPropertyBag() OVERRIDE; |
158 virtual content::WebContentsDelegate* GetDelegate() OVERRIDE; | 168 virtual content::WebContentsDelegate* GetDelegate() OVERRIDE; |
159 virtual void SetDelegate(content::WebContentsDelegate* delegate) OVERRIDE; | 169 virtual void SetDelegate(content::WebContentsDelegate* delegate) OVERRIDE; |
160 virtual content::NavigationController& GetController() OVERRIDE; | 170 virtual NavigationControllerImpl& GetController() OVERRIDE; |
161 virtual const content::NavigationController& GetController() const OVERRIDE; | 171 virtual const NavigationControllerImpl& GetController() const OVERRIDE; |
162 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; | 172 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; |
163 virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE; | 173 virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE; |
164 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE; | 174 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE; |
165 virtual content::RenderWidgetHostView* | 175 virtual content::RenderWidgetHostView* |
166 GetRenderWidgetHostView() const OVERRIDE; | 176 GetRenderWidgetHostView() const OVERRIDE; |
167 virtual content::WebContentsView* GetView() const OVERRIDE; | 177 virtual content::WebContentsView* GetView() const OVERRIDE; |
168 virtual content::WebUI* CreateWebUI(const GURL& url) OVERRIDE; | 178 virtual content::WebUI* CreateWebUI(const GURL& url) OVERRIDE; |
169 virtual content::WebUI* GetWebUI() const OVERRIDE; | 179 virtual content::WebUI* GetWebUI() const OVERRIDE; |
170 virtual content::WebUI* GetCommittedWebUI() const OVERRIDE; | 180 virtual content::WebUI* GetCommittedWebUI() const OVERRIDE; |
171 virtual void SetUserAgentOverride(const std::string& override) OVERRIDE; | 181 virtual void SetUserAgentOverride(const std::string& override) OVERRIDE; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 const content::OpenURLParams& params) OVERRIDE; | 265 const content::OpenURLParams& params) OVERRIDE; |
256 | 266 |
257 // RenderViewHostDelegate ---------------------------------------------------- | 267 // RenderViewHostDelegate ---------------------------------------------------- |
258 | 268 |
259 virtual content::RenderViewHostDelegateView* GetDelegateView() OVERRIDE; | 269 virtual content::RenderViewHostDelegateView* GetDelegateView() OVERRIDE; |
260 virtual content::RenderViewHostDelegate::RendererManagement* | 270 virtual content::RenderViewHostDelegate::RendererManagement* |
261 GetRendererManagementDelegate() OVERRIDE; | 271 GetRendererManagementDelegate() OVERRIDE; |
262 virtual bool OnMessageReceived(content::RenderViewHost* render_view_host, | 272 virtual bool OnMessageReceived(content::RenderViewHost* render_view_host, |
263 const IPC::Message& message) OVERRIDE; | 273 const IPC::Message& message) OVERRIDE; |
264 virtual const GURL& GetURL() const OVERRIDE; | 274 virtual const GURL& GetURL() const OVERRIDE; |
265 virtual WebContents* GetAsWebContents() OVERRIDE; | 275 virtual content::WebContents* GetAsWebContents() OVERRIDE; |
266 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; | 276 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; |
267 virtual void RenderViewCreated( | 277 virtual void RenderViewCreated( |
268 content::RenderViewHost* render_view_host) OVERRIDE; | 278 content::RenderViewHost* render_view_host) OVERRIDE; |
269 virtual void RenderViewReady( | 279 virtual void RenderViewReady( |
270 content::RenderViewHost* render_view_host) OVERRIDE; | 280 content::RenderViewHost* render_view_host) OVERRIDE; |
271 virtual void RenderViewGone(content::RenderViewHost* render_view_host, | 281 virtual void RenderViewGone(content::RenderViewHost* render_view_host, |
272 base::TerminationStatus status, | 282 base::TerminationStatus status, |
273 int error_code) OVERRIDE; | 283 int error_code) OVERRIDE; |
274 virtual void RenderViewDeleted( | 284 virtual void RenderViewDeleted( |
275 content::RenderViewHost* render_view_host) OVERRIDE; | 285 content::RenderViewHost* render_view_host) OVERRIDE; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE; | 437 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE; |
428 virtual void CreateViewAndSetSizeForRVH( | 438 virtual void CreateViewAndSetSizeForRVH( |
429 content::RenderViewHost* rvh) OVERRIDE; | 439 content::RenderViewHost* rvh) OVERRIDE; |
430 | 440 |
431 // content::NotificationObserver --------------------------------------------- | 441 // content::NotificationObserver --------------------------------------------- |
432 | 442 |
433 virtual void Observe(int type, | 443 virtual void Observe(int type, |
434 const content::NotificationSource& source, | 444 const content::NotificationSource& source, |
435 const content::NotificationDetails& details) OVERRIDE; | 445 const content::NotificationDetails& details) OVERRIDE; |
436 | 446 |
437 protected: | |
438 friend class content::WebContentsObserver; | |
439 | |
440 // Add and remove observers for page navigation notifications. Adding or | |
441 // removing multiple times has no effect. The order in which notifications | |
442 // are sent to observers is undefined. Clients must be sure to remove the | |
443 // observer before they go away. | |
444 void AddObserver(content::WebContentsObserver* observer); | |
445 void RemoveObserver(content::WebContentsObserver* observer); | |
446 | 447 |
447 private: | 448 private: |
448 friend class NavigationControllerImpl; | 449 friend class NavigationControllerImpl; |
| 450 friend class content::WebContentsObserver; |
| 451 friend class content::WebContents; // To implement factory methods. |
449 | 452 |
450 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials); | 453 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials); |
451 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle); | 454 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle); |
452 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, | 455 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, |
453 CrossSiteCantPreemptAfterUnload); | 456 CrossSiteCantPreemptAfterUnload); |
454 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles); | 457 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles); |
455 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate); | 458 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate); |
456 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload); | 459 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload); |
457 | 460 |
458 // So InterstitialPageImpl can access SetIsLoading. | 461 // So InterstitialPageImpl can access SetIsLoading. |
459 friend class InterstitialPageImpl; | 462 friend class InterstitialPageImpl; |
460 | 463 |
461 // TODO(brettw) TestWebContents shouldn't exist! | 464 // TODO(brettw) TestWebContents shouldn't exist! |
462 friend class content::TestWebContents; | 465 friend class content::TestWebContents; |
463 | 466 |
| 467 // See WebContents::Create for a description of these parameters. |
| 468 WebContentsImpl(content::BrowserContext* browser_context, |
| 469 WebContentsImpl* opener); |
| 470 |
| 471 // Add and remove observers for page navigation notifications. Adding or |
| 472 // removing multiple times has no effect. The order in which notifications |
| 473 // are sent to observers is undefined. Clients must be sure to remove the |
| 474 // observer before they go away. |
| 475 void AddObserver(content::WebContentsObserver* observer); |
| 476 void RemoveObserver(content::WebContentsObserver* observer); |
| 477 |
464 // Clears this tab's opener if it has been closed. | 478 // Clears this tab's opener if it has been closed. |
465 void OnWebContentsDestroyed(content::WebContents* web_contents); | 479 void OnWebContentsDestroyed(content::WebContents* web_contents); |
466 | 480 |
467 // Callback function when showing JS dialogs. | 481 // Callback function when showing JS dialogs. |
468 void OnDialogClosed(content::RenderViewHost* rvh, | 482 void OnDialogClosed(content::RenderViewHost* rvh, |
469 IPC::Message* reply_msg, | 483 IPC::Message* reply_msg, |
470 bool success, | 484 bool success, |
471 const string16& user_input); | 485 const string16& user_input); |
472 | 486 |
473 // IPC message handlers. | 487 // IPC message handlers. |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 content::NotificationRegistrar registrar_; | 811 content::NotificationRegistrar registrar_; |
798 | 812 |
799 // Used during IPC message dispatching so that the handlers can get a pointer | 813 // Used during IPC message dispatching so that the handlers can get a pointer |
800 // to the RVH through which the message was received. | 814 // to the RVH through which the message was received. |
801 content::RenderViewHost* message_source_; | 815 content::RenderViewHost* message_source_; |
802 | 816 |
803 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); | 817 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); |
804 }; | 818 }; |
805 | 819 |
806 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 820 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
OLD | NEW |