blob: f38f217afc828f2cf797e291dd07934b8f4f3c80 [file] [log] [blame]
[email protected]91854cd2012-01-10 19:43:571// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]0dd3a0ab2011-02-18 08:17:442// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]93ddb3c2012-04-11 21:44:295#ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
6#define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
[email protected]0dd3a0ab2011-02-18 08:17:447
[email protected]0dd3a0ab2011-02-18 08:17:448#include <map>
[email protected]b24b68a2012-09-24 21:57:269#include <set>
[email protected]0dd3a0ab2011-02-18 08:17:4410#include <string>
[email protected]0dd3a0ab2011-02-18 08:17:4411
[email protected]01d65172011-12-25 04:39:3012#include "base/compiler_specific.h"
[email protected]0dd3a0ab2011-02-18 08:17:4413#include "base/gtest_prod_util.h"
[email protected]3b63f8f42011-03-28 01:54:1514#include "base/memory/scoped_ptr.h"
[email protected]6eac57a2011-07-12 21:15:0915#include "base/observer_list.h"
[email protected]cc510d7e2012-08-08 04:40:1016#include "content/browser/browser_plugin/old/old_browser_plugin_host.h"
[email protected]07161902011-11-11 09:57:4217#include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager.h"
[email protected]2e3bf992012-05-24 17:36:2418#include "content/browser/renderer_host/render_view_host_delegate.h"
[email protected]4ca76c02012-05-16 16:19:0519#include "content/browser/renderer_host/render_widget_host_delegate.h"
[email protected]f9e4dae2012-04-10 21:26:3720#include "content/browser/web_contents/navigation_controller_impl.h"
[email protected]0c4e92e62012-04-11 15:19:0021#include "content/browser/web_contents/render_view_host_manager.h"
[email protected]8d128d62011-09-13 22:11:5722#include "content/common/content_export.h"
[email protected]14392a52012-05-02 20:28:4423#include "content/public/browser/notification_observer.h"
24#include "content/public/browser/notification_registrar.h"
[email protected]58f5d562011-12-20 17:13:0325#include "content/public/browser/web_contents.h"
[email protected]daf82f82011-10-31 22:35:3126#include "content/public/common/renderer_preferences.h"
[email protected]0dd3a0ab2011-02-18 08:17:4427#include "net/base/load_states.h"
[email protected]59363fc92012-09-05 03:46:3128#include "ui/gfx/rect_f.h"
[email protected]bcd2815602012-01-14 18:17:2329#include "ui/gfx/size.h"
[email protected]70435962011-08-02 20:13:2830#include "webkit/glue/resource_type.h"
[email protected]0dd3a0ab2011-02-18 08:17:4431
32#if defined(OS_WIN)
33#include "base/win/scoped_handle.h"
34#endif
35
[email protected]cadaec52012-02-08 21:53:1336class InterstitialPageImpl;
[email protected]a53209b2012-01-20 16:48:1637class SavePackage;
[email protected]adbfb8df2012-02-24 01:19:4338class SessionStorageNamespaceImpl;
[email protected]f66df822012-05-18 16:52:1739class WebContentsImpl;
[email protected]f546640b2012-05-15 00:03:4940struct ViewMsg_PostMessage_Params;
[email protected]daf82f82011-10-31 22:35:3141
[email protected]e582fdd2011-12-20 16:48:1742namespace content {
[email protected]7a846df2012-09-20 19:17:3943class BrowserPluginEmbedder;
44class BrowserPluginGuest;
[email protected]da8543762012-03-20 08:52:2045class ColorChooser;
[email protected]e582fdd2011-12-20 16:48:1746class DownloadItem;
[email protected]51da7e32012-01-30 19:24:5247class JavaScriptDialogCreator;
[email protected]eaabba22012-03-07 15:02:1148class RenderViewHost;
[email protected]5a3bdf52012-05-24 15:12:5749class RenderViewHostDelegateView;
[email protected]eaabba22012-03-07 15:02:1150class RenderViewHostImpl;
[email protected]b24b68a2012-09-24 21:57:2651class RenderWidgetHostImpl;
[email protected]09d31d52012-03-11 22:30:2752class SiteInstance;
[email protected]80e776ae2012-03-23 16:17:2053class TestWebContents;
[email protected]674bc592011-12-20 23:00:4254class WebContentsDelegate;
[email protected]51da7e32012-01-30 19:24:5255class WebContentsObserver;
[email protected]8643e6d2012-01-18 20:26:1056class WebContentsView;
[email protected]f66df822012-05-18 16:52:1757class WebContentsViewDelegate;
[email protected]09d31d52012-03-11 22:30:2758struct LoadNotificationDetails;
[email protected]f66df822012-05-18 16:52:1759
60// Factory function for the implementations that content knows about. Takes
61// ownership of |delegate|.
[email protected]5a3bdf52012-05-24 15:12:5762WebContentsView* CreateWebContentsView(
63 WebContentsImpl* web_contents,
64 WebContentsViewDelegate* delegate,
65 RenderViewHostDelegateView** render_view_host_delegate_view);
[email protected]97714c82012-06-06 10:15:1366
67} // namespace content
[email protected]e582fdd2011-12-20 16:48:1768
[email protected]daf82f82011-10-31 22:35:3169namespace webkit_glue {
70struct WebIntentData;
[email protected]3a3b75a2012-06-01 08:38:3671struct WebIntentServiceData;
[email protected]daf82f82011-10-31 22:35:3172}
[email protected]0dd3a0ab2011-02-18 08:17:4473
[email protected]b172aee2012-04-10 17:05:2674class CONTENT_EXPORT WebContentsImpl
[email protected]01d65172011-12-25 04:39:3075 : public NON_EXPORTED_BASE(content::WebContents),
[email protected]b0b67cf2012-01-18 21:59:5776 public content::RenderViewHostDelegate,
[email protected]4ca76c02012-05-16 16:19:0577 public content::RenderWidgetHostDelegate,
[email protected]14392a52012-05-02 20:28:4478 public RenderViewHostManager::Delegate,
79 public content::NotificationObserver {
[email protected]0dd3a0ab2011-02-18 08:17:4480 public:
[email protected]b172aee2012-04-10 17:05:2681 virtual ~WebContentsImpl();
[email protected]0dd3a0ab2011-02-18 08:17:4482
[email protected]d1198fd2012-08-13 22:50:1983 static WebContentsImpl* Create(
84 content::BrowserContext* browser_context,
85 content::SiteInstance* site_instance,
86 int routing_id,
87 const WebContentsImpl* base_web_contents);
88
89 static WebContentsImpl* CreateWithOpener(
90 content::BrowserContext* browser_context,
91 content::SiteInstance* site_instance,
92 int routing_id,
93 const WebContentsImpl* base_web_contents,
94 WebContentsImpl* opener);
95
[email protected]7a846df2012-09-20 19:17:3996 // Creates a WebContents to be used as a browser plugin guest.
97 static WebContentsImpl* CreateGuest(content::BrowserContext* browser_context,
98 const std::string& host,
99 int guest_instance_id);
100
[email protected]64d69de42012-02-06 00:19:54101 // Returns the content specific prefs for the given RVH.
[email protected]6717bf272012-05-11 23:31:25102 static webkit_glue::WebPreferences GetWebkitPrefs(
[email protected]eaabba22012-03-07 15:02:11103 content::RenderViewHost* rvh, const GURL& url);
[email protected]64d69de42012-02-06 00:19:54104
[email protected]d1198fd2012-08-13 22:50:19105 // Complex initialization here. Specifically needed to avoid having
106 // members call back into our virtual functions in the constructor.
107 virtual void Init(content::BrowserContext* browser_context,
108 content::SiteInstance* site_instance,
109 int routing_id,
110 const content::WebContents* base_web_contents);
111
[email protected]c7dd2f62011-07-18 15:57:59112 // Returns the SavePackage which manages the page saving job. May be NULL.
113 SavePackage* save_package() const { return save_package_.get(); }
114
[email protected]b172aee2012-04-10 17:05:26115 // Updates the max page ID for the current SiteInstance in this
116 // WebContentsImpl to be at least |page_id|.
[email protected]0dd3a0ab2011-02-18 08:17:44117 void UpdateMaxPageID(int32 page_id);
118
[email protected]b172aee2012-04-10 17:05:26119 // Updates the max page ID for the given SiteInstance in this WebContentsImpl
[email protected]74ce1ad2011-12-16 21:51:46120 // to be at least |page_id|.
[email protected]b6583592012-01-25 19:52:33121 void UpdateMaxPageIDForSiteInstance(content::SiteInstance* site_instance,
[email protected]74ce1ad2011-12-16 21:51:46122 int32 page_id);
123
[email protected]91854cd2012-01-10 19:43:57124 // Copy the current map of SiteInstance ID to max page ID from another tab.
125 // This is necessary when this tab adopts the NavigationEntries from
[email protected]b172aee2012-04-10 17:05:26126 // |web_contents|.
127 void CopyMaxPageIDsFrom(WebContentsImpl* web_contents);
[email protected]91854cd2012-01-10 19:43:57128
[email protected]b172aee2012-04-10 17:05:26129 // Called by the NavigationController to cause the WebContentsImpl to navigate
130 // to the current pending entry. The NavigationController should be called
131 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
[email protected]9a7e68c2011-05-26 17:35:50132 // The callbacks can be inside of this function, or at some future time.
[email protected]0dd3a0ab2011-02-18 08:17:44133 //
134 // The entry has a PageID of -1 if newly created (corresponding to navigation
135 // to a new URL).
136 //
137 // If this method returns false, then the navigation is discarded (equivalent
138 // to calling DiscardPendingEntry on the NavigationController).
[email protected]0bfbf882011-12-22 18:19:27139 bool NavigateToPendingEntry(
[email protected]71fde352011-12-29 03:29:56140 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44141
[email protected]ba45bfd2012-05-22 21:51:44142 // Called by InterstitialPageImpl when it creates a RenderViewHost.
143 void RenderViewForInterstitialPageCreated(
144 content::RenderViewHost* render_view_host);
145
[email protected]0dd3a0ab2011-02-18 08:17:44146 // Sets the passed passed interstitial as the currently showing interstitial.
147 // |interstitial_page| should be non NULL (use the remove_interstitial_page
148 // method to unset the interstitial) and no interstitial page should be set
149 // when there is already a non NULL interstitial page set.
[email protected]cadaec52012-02-08 21:53:13150 void set_interstitial_page(InterstitialPageImpl* interstitial_page) {
[email protected]0dd3a0ab2011-02-18 08:17:44151 render_manager_.set_interstitial_page(interstitial_page);
152 }
153
154 // Unsets the currently showing interstitial.
155 void remove_interstitial_page() {
156 render_manager_.remove_interstitial_page();
157 }
158
[email protected]01ec4ec2012-01-18 04:13:47159 void set_opener_web_ui_type(content::WebUI::TypeID opener_web_ui_type) {
[email protected]0dd3a0ab2011-02-18 08:17:44160 opener_web_ui_type_ = opener_web_ui_type;
161 }
162
[email protected]276b37a22011-11-08 20:45:46163 JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const {
164 return java_bridge_dispatcher_host_manager_.get();
165 }
166
[email protected]dd26779c2012-08-08 01:50:28167 content::old::BrowserPluginHost* old_browser_plugin_host() const {
168 return old_browser_plugin_host_.get();
[email protected]172cf712012-05-23 15:07:39169 }
170
[email protected]765187182012-01-11 23:59:28171 // Expose the render manager for testing.
172 RenderViewHostManager* GetRenderManagerForTesting();
173
[email protected]7a846df2012-09-20 19:17:39174 // Returns guest browser plugin object, or NULL if this WebContents is not a
175 // guest.
176 content::BrowserPluginGuest* GetBrowserPluginGuest();
177 // Returns embedder browser plugin object, or NULL if this WebContents is not
178 // an embedder.
179 content::BrowserPluginEmbedder* GetBrowserPluginEmbedder();
180
[email protected]58f5d562011-12-20 17:13:03181 // content::WebContents ------------------------------------------------------
[email protected]674bc592011-12-20 23:00:42182 virtual content::WebContentsDelegate* GetDelegate() OVERRIDE;
183 virtual void SetDelegate(content::WebContentsDelegate* delegate) OVERRIDE;
[email protected]d1198fd2012-08-13 22:50:19184 virtual NavigationControllerImpl& GetController() OVERRIDE;
185 virtual const NavigationControllerImpl& GetController() const OVERRIDE;
[email protected]627e0512011-12-21 22:55:30186 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
[email protected]f5fa20e2011-12-21 22:35:56187 virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11188 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE;
[email protected]6b618e62012-08-16 12:59:18189 virtual int GetRoutingID() const OVERRIDE;
[email protected]5626b0892012-02-20 14:46:58190 virtual content::RenderWidgetHostView*
191 GetRenderWidgetHostView() const OVERRIDE;
[email protected]8643e6d2012-01-18 20:26:10192 virtual content::WebContentsView* GetView() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47193 virtual content::WebUI* CreateWebUI(const GURL& url) OVERRIDE;
194 virtual content::WebUI* GetWebUI() const OVERRIDE;
195 virtual content::WebUI* GetCommittedWebUI() const OVERRIDE;
[email protected]86ef6a392012-05-11 22:03:11196 virtual void SetUserAgentOverride(const std::string& override) OVERRIDE;
197 virtual const std::string& GetUserAgentOverride() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31198 virtual const string16& GetTitle() const OVERRIDE;
199 virtual int32 GetMaxPageID() OVERRIDE;
200 virtual int32 GetMaxPageIDForSiteInstance(
[email protected]b6583592012-01-25 19:52:33201 content::SiteInstance* site_instance) OVERRIDE;
202 virtual content::SiteInstance* GetSiteInstance() const OVERRIDE;
203 virtual content::SiteInstance* GetPendingSiteInstance() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31204 virtual bool IsLoading() const OVERRIDE;
205 virtual bool IsWaitingForResponse() const OVERRIDE;
206 virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE;
207 virtual const string16& GetLoadStateHost() const OVERRIDE;
208 virtual uint64 GetUploadSize() const OVERRIDE;
209 virtual uint64 GetUploadPosition() const OVERRIDE;
210 virtual const std::string& GetEncoding() const OVERRIDE;
211 virtual bool DisplayedInsecureContent() const OVERRIDE;
212 virtual void SetCapturingContents(bool cap) OVERRIDE;
213 virtual bool IsCrashed() const OVERRIDE;
214 virtual void SetIsCrashed(base::TerminationStatus status,
215 int error_code) OVERRIDE;
216 virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE;
217 virtual bool IsBeingDestroyed() const OVERRIDE;
218 virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31219 virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE;
[email protected]9e2e4632012-07-27 16:38:41220 virtual void WasShown() OVERRIDE;
[email protected]3e324142012-06-25 18:26:33221 virtual void WasHidden() OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31222 virtual bool NeedToFireBeforeUnload() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27223 virtual void Stop() OVERRIDE;
[email protected]d9083482012-01-06 00:38:46224 virtual content::WebContents* Clone() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27225 virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
226 virtual gfx::NativeView GetNativeView() const OVERRIDE;
227 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE;
228 virtual void Focus() OVERRIDE;
229 virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE;
230 virtual bool ShowingInterstitialPage() const OVERRIDE;
[email protected]cadaec52012-02-08 21:53:13231 virtual content::InterstitialPage* GetInterstitialPage() const OVERRIDE;
[email protected]a53209b2012-01-20 16:48:16232 virtual bool IsSavable() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27233 virtual void OnSavePage() OVERRIDE;
234 virtual bool SavePage(const FilePath& main_file,
235 const FilePath& dir_path,
[email protected]a53209b2012-01-20 16:48:16236 content::SavePageType save_type) OVERRIDE;
[email protected]aa4f3972012-03-01 18:12:12237 virtual void GenerateMHTML(
238 const FilePath& file,
239 const base::Callback<void(const FilePath&, int64)>& callback) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27240 virtual bool IsActiveEntry(int32 page_id) OVERRIDE;
241
242 virtual const std::string& GetContentsMimeType() const OVERRIDE;
243 virtual bool WillNotifyDisconnection() const OVERRIDE;
244 virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE;
245 virtual void ResetOverrideEncoding() OVERRIDE;
246 virtual content::RendererPreferences* GetMutableRendererPrefs() OVERRIDE;
247 virtual void SetNewTabStartTime(const base::TimeTicks& time) OVERRIDE;
248 virtual base::TimeTicks GetNewTabStartTime() const OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47249 virtual void Close() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27250 virtual void OnCloseStarted() OVERRIDE;
251 virtual bool ShouldAcceptDragAndDrop() const OVERRIDE;
252 virtual void SystemDragEnded() OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47253 virtual void UserGestureDone() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27254 virtual void SetClosedByUserGesture(bool value) OVERRIDE;
255 virtual bool GetClosedByUserGesture() const OVERRIDE;
256 virtual double GetZoomLevel() const OVERRIDE;
257 virtual int GetZoomPercent(bool* enable_increment,
[email protected]9a8408902012-09-26 16:17:59258 bool* enable_decrement) const OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27259 virtual void ViewSource() OVERRIDE;
260 virtual void ViewFrameSource(const GURL& url,
261 const std::string& content_state) OVERRIDE;
262 virtual int GetMinimumZoomPercent() const OVERRIDE;
263 virtual int GetMaximumZoomPercent() const OVERRIDE;
[email protected]bcd2815602012-01-14 18:17:23264 virtual gfx::Size GetPreferredSize() const OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27265 virtual int GetContentRestrictions() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47266 virtual content::WebUI::TypeID GetWebUITypeForCurrentState() OVERRIDE;
267 virtual content::WebUI* GetWebUIForCurrentState() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27268 virtual bool GotResponseToLockMouseRequest(bool allowed) OVERRIDE;
[email protected]a0358d72012-03-09 14:06:50269 virtual bool HasOpener() const OVERRIDE;
[email protected]da8543762012-03-20 08:52:20270 virtual void DidChooseColorInColorChooser(int color_chooser_id,
[email protected]55578b0a2012-04-18 14:31:32271 SkColor color) OVERRIDE;
[email protected]da8543762012-03-20 08:52:20272 virtual void DidEndColorChooser(int color_chooser_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27273
274 // Implementation of PageNavigator.
[email protected]e5d549d2011-12-28 01:29:20275 virtual content::WebContents* OpenURL(
276 const content::OpenURLParams& params) OVERRIDE;
[email protected]151a63d2011-12-20 22:32:52277
[email protected]6b618e62012-08-16 12:59:18278 // Implementation of IPC::Sender.
279 virtual bool Send(IPC::Message* message) OVERRIDE;
280
[email protected]952a68e2011-11-17 00:36:10281 // RenderViewHostDelegate ----------------------------------------------------
282
[email protected]5a3bdf52012-05-24 15:12:57283 virtual content::RenderViewHostDelegateView* GetDelegateView() OVERRIDE;
[email protected]b0b67cf2012-01-18 21:59:57284 virtual content::RenderViewHostDelegate::RendererManagement*
[email protected]952a68e2011-11-17 00:36:10285 GetRendererManagementDelegate() OVERRIDE;
[email protected]7bb761892012-07-20 09:32:47286 virtual bool OnMessageReceived(content::RenderViewHost* render_view_host,
287 const IPC::Message& message) OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31288 virtual const GURL& GetURL() const OVERRIDE;
[email protected]d1198fd2012-08-13 22:50:19289 virtual content::WebContents* GetAsWebContents() OVERRIDE;
[email protected]b7a756d42012-01-23 18:08:17290 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11291 virtual void RenderViewCreated(
292 content::RenderViewHost* render_view_host) OVERRIDE;
293 virtual void RenderViewReady(
294 content::RenderViewHost* render_view_host) OVERRIDE;
295 virtual void RenderViewGone(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10296 base::TerminationStatus status,
297 int error_code) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11298 virtual void RenderViewDeleted(
299 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57300 virtual void DidStartProvisionalLoadForFrame(
301 content::RenderViewHost* render_view_host,
302 int64 frame_id,
303 bool main_frame,
304 const GURL& opener_url,
305 const GURL& url) OVERRIDE;
[email protected]400992b2012-06-14 00:03:54306 virtual void DidRedirectProvisionalLoad(
307 content::RenderViewHost* render_view_host,
308 int32 page_id,
309 const GURL& opener_url,
310 const GURL& source_url,
311 const GURL& target_url) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57312 virtual void DidFailProvisionalLoadWithError(
313 content::RenderViewHost* render_view_host,
314 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params)
315 OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10316 virtual void DidNavigate(
[email protected]eaabba22012-03-07 15:02:11317 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10318 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11319 virtual void UpdateState(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10320 int32 page_id,
321 const std::string& state) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11322 virtual void UpdateTitle(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10323 int32 page_id,
324 const string16& title,
325 base::i18n::TextDirection title_direction) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11326 virtual void UpdateEncoding(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10327 const std::string& encoding) OVERRIDE;
328 virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11329 virtual void Close(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10330 virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11331 virtual void SwappedOut(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]89793072012-07-23 22:25:29332 virtual void DidStartLoading(
333 content::RenderViewHost* render_view_host) OVERRIDE;
334 virtual void DidStopLoading(
335 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10336 virtual void DidCancelLoading() OVERRIDE;
337 virtual void DidChangeLoadProgress(double progress) OVERRIDE;
[email protected]0720b532012-08-28 19:23:37338 virtual void DidUpdateFrameTree(content::RenderViewHost* rvh) OVERRIDE;
[email protected]87717d0e2012-04-26 02:58:43339 virtual void DocumentAvailableInMainFrame(
340 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10341 virtual void DocumentOnLoadCompletedInMainFrame(
[email protected]eaabba22012-03-07 15:02:11342 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10343 int32 page_id) OVERRIDE;
[email protected]196159d2012-05-04 17:26:54344 virtual void RequestOpenURL(content::RenderViewHost* rvh,
345 const GURL& url,
[email protected]445e1042011-12-03 21:03:15346 const content::Referrer& referrer,
[email protected]952a68e2011-11-17 00:36:10347 WindowOpenDisposition disposition,
348 int64 source_frame_id) OVERRIDE;
[email protected]4ad5d77d2011-12-03 02:00:48349 virtual void RequestTransferURL(
350 const GURL& url,
[email protected]bce1f1c2011-12-05 15:11:58351 const content::Referrer& referrer,
[email protected]4ad5d77d2011-12-03 02:00:48352 WindowOpenDisposition disposition,
353 int64 source_frame_id,
[email protected]e5d549d2011-12-28 01:29:20354 const content::GlobalRequestID& transferred_global_request_id) OVERRIDE;
[email protected]e1c3a552012-05-04 20:51:32355 virtual void RouteCloseEvent(content::RenderViewHost* rvh) OVERRIDE;
[email protected]f546640b2012-05-15 00:03:49356 virtual void RouteMessageEvent(
357 content::RenderViewHost* rvh,
358 const ViewMsg_PostMessage_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11359 virtual void RunJavaScriptMessage(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10360 const string16& message,
361 const string16& default_prompt,
362 const GURL& frame_url,
[email protected]be2510c02012-05-28 14:52:14363 content::JavaScriptMessageType type,
[email protected]952a68e2011-11-17 00:36:10364 IPC::Message* reply_msg,
365 bool* did_suppress_message) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11366 virtual void RunBeforeUnloadConfirm(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10367 const string16& message,
[email protected]3b3301f62012-02-29 04:32:32368 bool is_reload,
[email protected]952a68e2011-11-17 00:36:10369 IPC::Message* reply_msg) OVERRIDE;
[email protected]a796f202012-05-30 14:14:25370 virtual bool AddMessageToConsole(int32 level,
371 const string16& message,
372 int32 line_no,
373 const string16& source_id) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10374 virtual content::RendererPreferences GetRendererPrefs(
375 content::BrowserContext* browser_context) const OVERRIDE;
[email protected]6717bf272012-05-11 23:31:25376 virtual webkit_glue::WebPreferences GetWebkitPrefs() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10377 virtual void OnUserGesture() OVERRIDE;
378 virtual void OnIgnoredUIEvent() OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11379 virtual void RendererUnresponsive(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10380 bool is_during_unload) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11381 virtual void RendererResponsive(
382 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10383 virtual void LoadStateChanged(const GURL& url,
384 const net::LoadStateWithParam& load_state,
385 uint64 upload_position,
386 uint64 upload_size) OVERRIDE;
387 virtual void WorkerCrashed() OVERRIDE;
388 virtual void Activate() OVERRIDE;
389 virtual void Deactivate() OVERRIDE;
390 virtual void LostCapture() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10391 virtual void HandleMouseDown() OVERRIDE;
392 virtual void HandleMouseUp() OVERRIDE;
[email protected]590a634e2012-07-19 16:38:23393 virtual void HandlePointerActivate() OVERRIDE;
394 virtual void HandleGestureBegin() OVERRIDE;
395 virtual void HandleGestureEnd() OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38396 virtual void RunFileChooser(
[email protected]eaabba22012-03-07 15:02:11397 content::RenderViewHost* render_view_host,
[email protected]8caadeb2011-11-22 02:45:23398 const content::FileChooserParams& params) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10399 virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
400 virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
401 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
[email protected]61e2b3cc2012-03-02 16:13:34402 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
[email protected]a9c81f02012-06-01 00:15:44403 virtual void RequestToLockMouse(bool user_gesture,
404 bool last_unlocked_by_target) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10405 virtual void LostMouseLock() OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50406 virtual void CreateNewWindow(
407 int route_id,
[email protected]97714c82012-06-06 10:15:13408 const ViewHostMsg_CreateWindow_Params& params,
409 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50410 virtual void CreateNewWidget(int route_id,
411 WebKit::WebPopupType popup_type) OVERRIDE;
412 virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
413 virtual void ShowCreatedWindow(int route_id,
414 WindowOpenDisposition disposition,
415 const gfx::Rect& initial_pos,
416 bool user_gesture) OVERRIDE;
417 virtual void ShowCreatedWidget(int route_id,
418 const gfx::Rect& initial_pos) OVERRIDE;
419 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
420 virtual void ShowContextMenu(
[email protected]ba16e3a2012-09-07 04:14:52421 const content::ContextMenuParams& params,
[email protected]1de0fc02012-09-17 21:37:27422 content::ContextMenuSourceType type) OVERRIDE;
[email protected]f13b4202012-06-12 23:53:23423 virtual void RequestMediaAccessPermission(
424 const content::MediaStreamRequest* request,
425 const content::MediaResponseCallback& callback) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10426
[email protected]16383382012-09-05 23:57:26427#if defined(OS_ANDROID)
428 virtual void AttachLayer(WebKit::WebLayer* layer) OVERRIDE;
429 virtual void RemoveLayer(WebKit::WebLayer* layer) OVERRIDE;
430#endif
431
[email protected]4ca76c02012-05-16 16:19:05432 // RenderWidgetHostDelegate --------------------------------------------------
433
[email protected]b24b68a2012-09-24 21:57:26434 virtual void RenderWidgetDeleted(
435 content::RenderWidgetHostImpl* render_widget_host) OVERRIDE;
[email protected]b87ee522012-05-18 15:16:54436 virtual bool PreHandleKeyboardEvent(
437 const content::NativeWebKeyboardEvent& event,
438 bool* is_keyboard_shortcut) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05439 virtual void HandleKeyboardEvent(
[email protected]b87ee522012-05-18 15:16:54440 const content::NativeWebKeyboardEvent& event) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05441
[email protected]0bfbf882011-12-22 18:19:27442 // RenderViewHostManager::Delegate -------------------------------------------
443
444 virtual bool CreateRenderViewForRenderManager(
[email protected]14392a52012-05-02 20:28:44445 content::RenderViewHost* render_view_host, int opener_route_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27446 virtual void BeforeUnloadFiredFromRenderManager(
[email protected]feaded02012-09-25 19:12:55447 bool proceed, const base::TimeTicks& proceed_time,
[email protected]0bfbf882011-12-22 18:19:27448 bool* proceed_to_fire_unload) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27449 virtual void RenderViewGoneFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11450 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27451 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
452 virtual void NotifySwappedFromRenderManager() OVERRIDE;
[email protected]14392a52012-05-02 20:28:44453 virtual int CreateOpenerRenderViewsForRenderManager(
454 content::SiteInstance* instance) OVERRIDE;
[email protected]d202a7c2012-01-04 07:53:47455 virtual NavigationControllerImpl& GetControllerForRenderManager() OVERRIDE;
[email protected]d2353452012-01-19 19:53:56456 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
[email protected]ad23a092011-12-28 07:02:04457 virtual content::NavigationEntry*
[email protected]0bfbf882011-12-22 18:19:27458 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
459 virtual bool FocusLocationBarByDefault() OVERRIDE;
460 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11461 virtual void CreateViewAndSetSizeForRVH(
462 content::RenderViewHost* rvh) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27463
[email protected]14392a52012-05-02 20:28:44464 // content::NotificationObserver ---------------------------------------------
465
466 virtual void Observe(int type,
467 const content::NotificationSource& source,
468 const content::NotificationDetails& details) OVERRIDE;
469
[email protected]553602e12011-04-05 17:01:18470
[email protected]0dd3a0ab2011-02-18 08:17:44471 private:
[email protected]d202a7c2012-01-04 07:53:47472 friend class NavigationControllerImpl;
[email protected]d1198fd2012-08-13 22:50:19473 friend class content::WebContentsObserver;
474 friend class content::WebContents; // To implement factory methods.
[email protected]0dd3a0ab2011-02-18 08:17:44475
[email protected]2db9bd72012-04-13 20:20:56476 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
477 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
478 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
479 CrossSiteCantPreemptAfterUnload);
[email protected]0dd3a0ab2011-02-18 08:17:44480 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
481 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
482 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
483
[email protected]cadaec52012-02-08 21:53:13484 // So InterstitialPageImpl can access SetIsLoading.
485 friend class InterstitialPageImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44486
[email protected]80e776ae2012-03-23 16:17:20487 // TODO(brettw) TestWebContents shouldn't exist!
488 friend class content::TestWebContents;
[email protected]0dd3a0ab2011-02-18 08:17:44489
[email protected]d1198fd2012-08-13 22:50:19490 // See WebContents::Create for a description of these parameters.
491 WebContentsImpl(content::BrowserContext* browser_context,
492 WebContentsImpl* opener);
493
494 // Add and remove observers for page navigation notifications. Adding or
495 // removing multiple times has no effect. The order in which notifications
496 // are sent to observers is undefined. Clients must be sure to remove the
497 // observer before they go away.
498 void AddObserver(content::WebContentsObserver* observer);
499 void RemoveObserver(content::WebContentsObserver* observer);
500
[email protected]14392a52012-05-02 20:28:44501 // Clears this tab's opener if it has been closed.
502 void OnWebContentsDestroyed(content::WebContents* web_contents);
503
[email protected]51da7e32012-01-30 19:24:52504 // Callback function when showing JS dialogs.
[email protected]eaabba22012-03-07 15:02:11505 void OnDialogClosed(content::RenderViewHost* rvh,
[email protected]51da7e32012-01-30 19:24:52506 IPC::Message* reply_msg,
507 bool success,
508 const string16& user_input);
509
[email protected]d8415ad92012-08-23 14:40:50510 // Callback function when requesting permission to access the PPAPI broker.
511 // |result| is true if permission was granted.
512 void OnPpapiBrokerPermissionResult(int request_id, bool result);
513
[email protected]d0759f492012-04-19 22:50:50514 // IPC message handlers.
[email protected]3a3b75a2012-06-01 08:38:36515 void OnRegisterIntentService(const webkit_glue::WebIntentServiceData& data,
516 bool user_gesture);
[email protected]678105012011-12-09 04:01:21517 void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
[email protected]63c239322011-10-31 23:56:30518 int intent_id);
[email protected]0dd3a0ab2011-02-18 08:17:44519 void OnDidLoadResourceFromMemoryCache(const GURL& url,
[email protected]70435962011-08-02 20:13:28520 const std::string& security_info,
521 const std::string& http_request,
[email protected]6d6cfb3a2012-05-23 22:53:18522 const std::string& mime_type,
[email protected]70435962011-08-02 20:13:28523 ResourceType::Type resource_type);
[email protected]0dd3a0ab2011-02-18 08:17:44524 void OnDidDisplayInsecureContent();
525 void OnDidRunInsecureContent(const std::string& security_origin,
526 const GURL& target_url);
527 void OnDocumentLoadedInFrame(int64 frame_id);
[email protected]1a55c5be2011-11-29 11:36:31528 void OnDidFinishLoad(int64 frame_id,
529 const GURL& validated_url,
530 bool is_main_frame);
531 void OnDidFailLoadWithError(int64 frame_id,
532 const GURL& validated_url,
533 bool is_main_frame,
534 int error_code,
535 const string16& error_description);
[email protected]0dd3a0ab2011-02-18 08:17:44536 void OnUpdateContentRestrictions(int restrictions);
[email protected]0dd3a0ab2011-02-18 08:17:44537 void OnGoToEntryAtOffset(int offset);
[email protected]216813952011-05-19 22:21:26538 void OnUpdateZoomLimits(int minimum_percent,
539 int maximum_percent,
540 bool remember);
[email protected]20b433a2012-05-15 21:23:46541 void OnSaveURL(const GURL& url, const content::Referrer& referrer);
[email protected]3a29a6e2011-08-24 18:26:21542 void OnEnumerateDirectory(int request_id, const FilePath& path);
[email protected]7d189022011-08-25 22:54:20543 void OnJSOutOfMemory();
[email protected]b7a756d42012-01-23 18:08:17544
[email protected]7d189022011-08-25 22:54:20545 void OnRegisterProtocolHandler(const std::string& protocol,
546 const GURL& url,
[email protected]3a3b75a2012-06-01 08:38:36547 const string16& title,
548 bool user_gesture);
[email protected]59363fc92012-09-05 03:46:31549 void OnFindReply(int request_id,
550 int number_of_matches,
551 const gfx::Rect& selection_rect,
552 int active_match_ordinal,
[email protected]b888919c2011-09-02 00:32:16553 bool final_update);
[email protected]59363fc92012-09-05 03:46:31554#if defined(OS_ANDROID)
555 void OnFindMatchRectsReply(int version,
556 const std::vector<gfx::RectF>& rects,
557 const gfx::RectF& active_rect);
558#endif
[email protected]d952a052011-09-06 18:42:45559 void OnCrashedPlugin(const FilePath& plugin_path);
[email protected]7fc4bbb2011-09-08 21:23:10560 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
[email protected]55578b0a2012-04-18 14:31:32561 void OnOpenColorChooser(int color_chooser_id, SkColor color);
[email protected]da8543762012-03-20 08:52:20562 void OnEndColorChooser(int color_chooser_id);
[email protected]55578b0a2012-04-18 14:31:32563 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
[email protected]8be45842012-04-13 19:49:29564 void OnPepperPluginHung(int plugin_child_id,
565 const FilePath& path,
566 bool is_hung);
[email protected]d0759f492012-04-19 22:50:50567 void OnWebUISend(const GURL& source_url,
568 const std::string& name,
569 const base::ListValue& args);
[email protected]d8415ad92012-08-23 14:40:50570 void OnRequestPpapiBrokerPermission(int request_id,
571 const GURL& url,
572 const FilePath& plugin_path);
[email protected]7a846df2012-09-20 19:17:39573 void OnBrowserPluginNavigateGuest(int instance_id,
574 int64 frame_id,
575 const std::string& src,
576 const gfx::Size& size);
[email protected]0dd3a0ab2011-02-18 08:17:44577
578 // Changes the IsLoading state and notifies delegate as needed
579 // |details| is used to provide details on the load that just finished
580 // (but can be null if not applicable). Can be overridden.
581 void SetIsLoading(bool is_loading,
[email protected]09d31d52012-03-11 22:30:27582 content::LoadNotificationDetails* details);
[email protected]0dd3a0ab2011-02-18 08:17:44583
[email protected]0dd3a0ab2011-02-18 08:17:44584 // Called by derived classes to indicate that we're no longer waiting for a
585 // response. This won't actually update the throbber, but it will get picked
586 // up at the next animation step if the throbber is going.
587 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
588
[email protected]0dd3a0ab2011-02-18 08:17:44589 // Navigation helpers --------------------------------------------------------
590 //
591 // These functions are helpers for Navigate() and DidNavigate().
592
593 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
594 // committed to the navigation controller. Note that the navigation entry is
595 // not provided since it may be invalid/changed after being committed. The
596 // current navigation entry is in the NavigationController at this point.
597 void DidNavigateMainFramePostCommit(
[email protected]8286f51a2011-05-31 17:39:13598 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44599 const ViewHostMsg_FrameNavigate_Params& params);
600 void DidNavigateAnyFramePostCommit(
[email protected]eaabba22012-03-07 15:02:11601 content::RenderViewHost* render_view_host,
[email protected]8286f51a2011-05-31 17:39:13602 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44603 const ViewHostMsg_FrameNavigate_Params& params);
604
[email protected]74ce1ad2011-12-16 21:51:46605 // If our controller was restored, update the max page ID associated with the
606 // given RenderViewHost to be larger than the number of restored entries.
607 // This is called in CreateRenderView before any navigations in the RenderView
608 // have begun, to prevent any races in updating RenderView::next_page_id.
[email protected]eaabba22012-03-07 15:02:11609 void UpdateMaxPageIDIfNecessary(content::RenderViewHost* rvh);
[email protected]0dd3a0ab2011-02-18 08:17:44610
[email protected]0dd3a0ab2011-02-18 08:17:44611 // Saves the given title to the navigation entry and does associated work. It
612 // will update history and the view for the new title, and also synthesize
613 // titles for file URLs that have none (so we require that the URL of the
614 // entry already be set).
615 //
616 // This is used as the backend for state updates, which include a new title,
617 // or the dedicated set title message. It returns true if the new title is
618 // different and was therefore updated.
[email protected]10f417c52011-12-28 21:04:23619 bool UpdateTitleForEntry(content::NavigationEntryImpl* entry,
620 const string16& title);
[email protected]0dd3a0ab2011-02-18 08:17:44621
[email protected]b172aee2012-04-10 17:05:26622 // Causes the WebContentsImpl to navigate in the right renderer to |entry|,
623 // which must be already part of the entries in the navigation controller.
[email protected]0dd3a0ab2011-02-18 08:17:44624 // This does not change the NavigationController state.
[email protected]10f417c52011-12-28 21:04:23625 bool NavigateToEntry(const content::NavigationEntryImpl& entry,
[email protected]71fde352011-12-29 03:29:56626 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44627
[email protected]b172aee2012-04-10 17:05:26628 // Sets the history for this WebContentsImpl to |history_length| entries, and
[email protected]796931a92011-08-10 01:32:14629 // moves the current page_id to the last entry in the list if it's valid.
630 // This is mainly used when a prerendered page is swapped into the current
[email protected]9e1ad4b2011-08-14 16:49:19631 // tab. The method is virtual for testing.
[email protected]b6583592012-01-25 19:52:33632 virtual void SetHistoryLengthAndPrune(
633 const content::SiteInstance* site_instance,
634 int merge_history_length,
635 int32 minimum_page_id);
[email protected]796931a92011-08-10 01:32:14636
[email protected]14392a52012-05-02 20:28:44637 // Recursively creates swapped out RenderViews for this tab's opener chain
638 // (including this tab) in the given SiteInstance, allowing other tabs to send
639 // cross-process JavaScript calls to their opener(s). Returns the route ID of
640 // this tab's RenderView for |instance|.
641 int CreateOpenerRenderViews(content::SiteInstance* instance);
642
[email protected]bafe6cd2012-05-23 23:09:50643 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
644 void CreateNewWidget(int route_id,
645 bool is_fullscreen,
646 WebKit::WebPopupType popup_type);
647
648 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
649 void ShowCreatedWidget(int route_id,
650 bool is_fullscreen,
651 const gfx::Rect& initial_pos);
652
653 // Finds the new RenderWidgetHost and returns it. Note that this can only be
654 // called once as this call also removes it from the internal map.
655 content::RenderWidgetHostView* GetCreatedWidget(int route_id);
656
657 // Finds the new WebContentsImpl by route_id, initializes it for
658 // renderer-initiated creation, and returns it. Note that this can only be
659 // called once as this call also removes it from the internal map.
660 WebContentsImpl* GetCreatedWindow(int route_id);
661
[email protected]0dd3a0ab2011-02-18 08:17:44662 // Misc non-view stuff -------------------------------------------------------
663
664 // Helper functions for sending notifications.
665 void NotifySwapped();
666 void NotifyConnected();
667 void NotifyDisconnected();
668
[email protected]be1f56ab2011-12-22 06:55:31669 void SetEncoding(const std::string& encoding);
670
[email protected]27678b2a2012-02-04 22:09:14671 // Save a URL to the local filesystem.
[email protected]20b433a2012-05-15 21:23:46672 void SaveURL(const GURL& url,
673 const content::Referrer& referrer,
674 bool is_main_frame);
[email protected]27678b2a2012-02-04 22:09:14675
[email protected]eaabba22012-03-07 15:02:11676 content::RenderViewHostImpl* GetRenderViewHostImpl();
[email protected]9f76c1e2012-03-05 15:15:58677
[email protected]7900bfdb2012-05-24 19:31:24678 void GetBrowserPluginEmbedderInfo(content::RenderViewHost* render_view_host,
679 std::string* embedder_channel_name,
680 int* embedder_container_id);
681
[email protected]7a846df2012-09-20 19:17:39682 // Removes browser plugin embedder if there is one.
683 void RemoveBrowserPluginEmbedder();
684
[email protected]0dd3a0ab2011-02-18 08:17:44685 // Data for core operation ---------------------------------------------------
686
687 // Delegate for notifying our owner about stuff. Not owned by us.
[email protected]674bc592011-12-20 23:00:42688 content::WebContentsDelegate* delegate_;
[email protected]0dd3a0ab2011-02-18 08:17:44689
690 // Handles the back/forward list and loading.
[email protected]d202a7c2012-01-04 07:53:47691 NavigationControllerImpl controller_;
[email protected]0dd3a0ab2011-02-18 08:17:44692
693 // The corresponding view.
[email protected]8643e6d2012-01-18 20:26:10694 scoped_ptr<content::WebContentsView> view_;
[email protected]0dd3a0ab2011-02-18 08:17:44695
[email protected]5a3bdf52012-05-24 15:12:57696 // The view of the RVHD. Usually this is our WebContentsView implementation,
697 // but if an embedder uses a different WebContentsView, they'll need to
698 // provide this.
699 content::RenderViewHostDelegateView* render_view_host_delegate_view_;
700
[email protected]bafe6cd2012-05-23 23:09:50701 // Tracks created WebContentsImpl objects that have not been shown yet. They
702 // are identified by the route ID passed to CreateNewWindow.
703 typedef std::map<int, WebContentsImpl*> PendingContents;
704 PendingContents pending_contents_;
705
706 // These maps hold on to the widgets that we created on behalf of the renderer
707 // that haven't shown yet.
708 typedef std::map<int, content::RenderWidgetHostView*> PendingWidgetViews;
709 PendingWidgetViews pending_widget_views_;
710
[email protected]996042972011-11-08 22:43:59711 // A list of observers notified when page state changes. Weak references.
712 // This MUST be listed above render_manager_ since at destruction time the
713 // latter might cause RenderViewHost's destructor to call us and we might use
714 // the observer list then.
[email protected]d8c660432011-12-22 20:51:25715 ObserverList<content::WebContentsObserver> observers_;
[email protected]996042972011-11-08 22:43:59716
[email protected]14392a52012-05-02 20:28:44717 // The tab that opened this tab, if any. Will be set to null if the opener
718 // is closed.
719 WebContentsImpl* opener_;
720
[email protected]0dd3a0ab2011-02-18 08:17:44721 // Helper classes ------------------------------------------------------------
722
723 // Manages creation and swapping of render views.
724 RenderViewHostManager render_manager_;
725
[email protected]483623eb2011-10-25 09:30:00726 // Manages injecting Java objects into all RenderViewHosts associated with
[email protected]b172aee2012-04-10 17:05:26727 // this WebContentsImpl.
[email protected]483623eb2011-10-25 09:30:00728 scoped_ptr<JavaBridgeDispatcherHostManager>
729 java_bridge_dispatcher_host_manager_;
730
[email protected]dd26779c2012-08-08 01:50:28731 // TODO(fsamuel): Remove this once upstreaming of the new browser plugin
[email protected]7a846df2012-09-20 19:17:39732 // implementation is complete.
[email protected]172cf712012-05-23 15:07:39733 // Manages the browser plugin instances hosted by this WebContents.
[email protected]dd26779c2012-08-08 01:50:28734 scoped_ptr<content::old::BrowserPluginHost> old_browser_plugin_host_;
[email protected]172cf712012-05-23 15:07:39735
[email protected]c7dd2f62011-07-18 15:57:59736 // SavePackage, lazily created.
737 scoped_refptr<SavePackage> save_package_;
738
[email protected]0dd3a0ab2011-02-18 08:17:44739 // Data for loading state ----------------------------------------------------
740
741 // Indicates whether we're currently loading a resource.
742 bool is_loading_;
743
744 // Indicates if the tab is considered crashed.
745 base::TerminationStatus crashed_status_;
746 int crashed_error_code_;
747
[email protected]ca13a442012-04-17 14:00:12748 // Whether this WebContents is waiting for a first-response for the
[email protected]be1f56ab2011-12-22 06:55:31749 // main resource of the page. This controls whether the throbber state is
750 // "waiting" or "loading."
[email protected]0dd3a0ab2011-02-18 08:17:44751 bool waiting_for_response_;
752
[email protected]74ce1ad2011-12-16 21:51:46753 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
754 // to a given tab and SiteInstance, and must be valid for the lifetime of the
[email protected]b172aee2012-04-10 17:05:26755 // WebContentsImpl.
[email protected]74ce1ad2011-12-16 21:51:46756 std::map<int32, int32> max_page_ids_;
[email protected]0dd3a0ab2011-02-18 08:17:44757
758 // System time at which the current load was started.
759 base::TimeTicks current_load_start_;
760
761 // The current load state and the URL associated with it.
[email protected]9c235f042011-08-10 22:28:21762 net::LoadStateWithParam load_state_;
[email protected]0dd3a0ab2011-02-18 08:17:44763 string16 load_state_host_;
764 // Upload progress, for displaying in the status bar.
765 // Set to zero when there is no significant upload happening.
766 uint64 upload_size_;
767 uint64 upload_position_;
768
769 // Data for current page -----------------------------------------------------
770
[email protected]987fc3a2011-05-26 14:18:09771 // When a title cannot be taken from any entry, this title will be used.
772 string16 page_title_when_no_navigation_entry_;
773
[email protected]0dd3a0ab2011-02-18 08:17:44774 // When a navigation occurs, we record its contents MIME type. It can be
775 // used to check whether we can do something for some special contents.
776 std::string contents_mime_type_;
777
778 // Character encoding.
779 std::string encoding_;
780
[email protected]0dd3a0ab2011-02-18 08:17:44781 // True if this is a secure page which displayed insecure content.
782 bool displayed_insecure_content_;
783
[email protected]0dd3a0ab2011-02-18 08:17:44784 // Data for misc internal state ----------------------------------------------
785
[email protected]ca13a442012-04-17 14:00:12786 // Whether the WebContents is currently being screenshotted.
[email protected]0dd3a0ab2011-02-18 08:17:44787 bool capturing_contents_;
788
789 // See getter above.
790 bool is_being_destroyed_;
791
792 // Indicates whether we should notify about disconnection of this
[email protected]b172aee2012-04-10 17:05:26793 // WebContentsImpl. This is used to ensure disconnection notifications only
[email protected]0dd3a0ab2011-02-18 08:17:44794 // happen if a connection notification has happened and that they happen only
795 // once.
796 bool notify_disconnection_;
797
[email protected]2e5b90c2011-08-16 21:11:55798 // Pointer to the JavaScript dialog creator, lazily assigned. Used because the
[email protected]b172aee2012-04-10 17:05:26799 // delegate of this WebContentsImpl is nulled before its destructor is called.
[email protected]2e5b90c2011-08-16 21:11:55800 content::JavaScriptDialogCreator* dialog_creator_;
801
[email protected]0dd3a0ab2011-02-18 08:17:44802#if defined(OS_WIN)
803 // Handle to an event that's set when the page is showing a message box (or
804 // equivalent constrained window). Plugin processes check this to know if
805 // they should pump messages then.
806 base::win::ScopedHandle message_box_active_;
807#endif
808
[email protected]0dd3a0ab2011-02-18 08:17:44809 // Set to true when there is an active "before unload" dialog. When true,
810 // we've forced the throbber to start in Navigate, and we need to remember to
811 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
812 bool is_showing_before_unload_dialog_;
813
[email protected]0dd3a0ab2011-02-18 08:17:44814 // Settings that get passed to the renderer process.
[email protected]daf82f82011-10-31 22:35:31815 content::RendererPreferences renderer_preferences_;
[email protected]0dd3a0ab2011-02-18 08:17:44816
817 // If this tab was created from a renderer using window.open, this will be
818 // non-NULL and represent the WebUI of the opening renderer.
[email protected]01ec4ec2012-01-18 04:13:47819 content::WebUI::TypeID opener_web_ui_type_;
[email protected]0dd3a0ab2011-02-18 08:17:44820
821 // The time that we started to create the new tab page.
822 base::TimeTicks new_tab_start_time_;
823
[email protected]3bbacc5b2012-04-17 17:46:15824 // The time that we started to close this WebContents.
825 base::TimeTicks close_start_time_;
[email protected]0dd3a0ab2011-02-18 08:17:44826
[email protected]feaded02012-09-25 19:12:55827 // The time when onbeforeunload ended.
828 base::TimeTicks before_unload_end_time_;
829
[email protected]0dd3a0ab2011-02-18 08:17:44830 // The time that this tab was last selected.
831 base::TimeTicks last_selected_time_;
832
[email protected]0dd3a0ab2011-02-18 08:17:44833 // See description above setter.
834 bool closed_by_user_gesture_;
835
836 // Minimum/maximum zoom percent.
837 int minimum_zoom_percent_;
838 int maximum_zoom_percent_;
839 // If true, the default zoom limits have been overriden for this tab, in which
840 // case we don't want saved settings to apply to it and we don't want to
841 // remember it.
842 bool temporary_zoom_settings_;
843
[email protected]bcd2815602012-01-14 18:17:23844 // The intrinsic size of the page.
845 gfx::Size preferred_size_;
846
[email protected]0dd3a0ab2011-02-18 08:17:44847 // Content restrictions, used to disable print/copy etc based on content's
848 // (full-page plugins for now only) permissions.
849 int content_restrictions_;
850
[email protected]da8543762012-03-20 08:52:20851 // Color chooser that was opened by this tab.
852 content::ColorChooser* color_chooser_;
853
[email protected]7a846df2012-09-20 19:17:39854 // Manages the embedder state for browser plugins, if this WebContents is an
855 // embedder; NULL otherwise.
856 scoped_ptr<content::BrowserPluginEmbedder> browser_plugin_embedder_;
857 // Manages the guest state for browser plugin, if this WebContents is a guest;
858 // NULL otherwise.
859 scoped_ptr<content::BrowserPluginGuest> browser_plugin_guest_;
860
[email protected]f53a9f872012-05-24 02:07:06861 // This must be at the end, or else we might get notifications and use other
862 // member variables that are gone.
863 content::NotificationRegistrar registrar_;
864
[email protected]7bb761892012-07-20 09:32:47865 // Used during IPC message dispatching so that the handlers can get a pointer
866 // to the RVH through which the message was received.
867 content::RenderViewHost* message_source_;
868
[email protected]b24b68a2012-09-24 21:57:26869 // All live RenderWidgetHostImpls that are created by this object and may
870 // outlive it.
871 std::set<content::RenderWidgetHostImpl*> created_widgets_;
872
[email protected]b172aee2012-04-10 17:05:26873 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
[email protected]0dd3a0ab2011-02-18 08:17:44874};
875
[email protected]93ddb3c2012-04-11 21:44:29876#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_