blob: 1f5bc6095156bdd2e80f49cbaf68c877317a88d6 [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]fa20e002013-07-23 21:20:5416#include "base/process/process.h"
[email protected]738f57a2013-06-29 21:06:5417#include "base/values.h"
[email protected]d4a8ca482013-10-30 21:06:4018#include "content/browser/frame_host/frame_tree.h"
19#include "content/browser/frame_host/navigation_controller_delegate.h"
20#include "content/browser/frame_host/navigation_controller_impl.h"
21#include "content/browser/frame_host/render_view_host_manager.h"
[email protected]2e3bf992012-05-24 17:36:2422#include "content/browser/renderer_host/render_view_host_delegate.h"
[email protected]4ca76c02012-05-16 16:19:0523#include "content/browser/renderer_host/render_widget_host_delegate.h"
[email protected]8d128d62011-09-13 22:11:5724#include "content/common/content_export.h"
[email protected]14392a52012-05-02 20:28:4425#include "content/public/browser/notification_observer.h"
26#include "content/public/browser/notification_registrar.h"
[email protected]58f5d562011-12-20 17:13:0327#include "content/public/browser/web_contents.h"
[email protected]f8872902013-10-30 03:18:5728#include "content/public/common/page_transition_types.h"
[email protected]daf82f82011-10-31 22:35:3129#include "content/public/common/renderer_preferences.h"
[email protected]818915cd2012-11-20 13:14:1130#include "content/public/common/three_d_api_types.h"
[email protected]0dd3a0ab2011-02-18 08:17:4431#include "net/base/load_states.h"
[email protected]2255a9332013-06-17 05:12:3132#include "third_party/WebKit/public/web/WebDragOperation.h"
[email protected]59363fc92012-09-05 03:46:3133#include "ui/gfx/rect_f.h"
[email protected]bcd2815602012-01-14 18:17:2334#include "ui/gfx/size.h"
[email protected]d0fcff72013-07-23 02:45:4335#include "webkit/common/resource_type.h"
[email protected]0dd3a0ab2011-02-18 08:17:4436
[email protected]92a01cc2012-09-29 14:13:5937struct BrowserPluginHostMsg_ResizeGuest_Params;
[email protected]1ff427972013-02-07 21:14:0738struct ViewHostMsg_DateTimeDialogValue_Params;
[email protected]f546640b2012-05-15 00:03:4939struct ViewMsg_PostMessage_Params;
[email protected]daf82f82011-10-31 22:35:3140
[email protected]e582fdd2011-12-20 16:48:1741namespace content {
[email protected]7a846df2012-09-20 19:17:3942class BrowserPluginEmbedder;
43class BrowserPluginGuest;
[email protected]8eb04562013-03-06 03:41:1444class BrowserPluginGuestManager;
[email protected]da8543762012-03-20 08:52:2045class ColorChooser;
[email protected]583418cc2013-01-17 14:01:1046class DateTimeChooserAndroid;
[email protected]e582fdd2011-12-20 16:48:1747class DownloadItem;
[email protected]8ff00d72012-10-23 19:12:2148class InterstitialPageImpl;
[email protected]4cc1ab52013-01-21 19:24:3449class JavaBridgeDispatcherHostManager;
[email protected]71a88bb2013-02-01 22:05:1550class JavaScriptDialogManager;
[email protected]d9030b82013-07-19 08:26:0651class PowerSaveBlocker;
[email protected]eaabba22012-03-07 15:02:1152class RenderViewHost;
[email protected]5a3bdf52012-05-24 15:12:5753class RenderViewHostDelegateView;
[email protected]eaabba22012-03-07 15:02:1154class RenderViewHostImpl;
[email protected]b24b68a2012-09-24 21:57:2655class RenderWidgetHostImpl;
[email protected]f8497342013-02-05 22:15:0256class RenderWidgetHostViewPort;
[email protected]35869622012-10-26 23:23:5557class SavePackage;
[email protected]c2ab4202012-10-24 22:54:4658class SessionStorageNamespaceImpl;
[email protected]09d31d52012-03-11 22:30:2759class SiteInstance;
[email protected]80e776ae2012-03-23 16:17:2060class TestWebContents;
[email protected]674bc592011-12-20 23:00:4261class WebContentsDelegate;
[email protected]8ff00d72012-10-23 19:12:2162class WebContentsImpl;
[email protected]51da7e32012-01-30 19:24:5263class WebContentsObserver;
[email protected]60780f412013-02-25 16:34:1064class WebContentsViewPort;
[email protected]f66df822012-05-18 16:52:1765class WebContentsViewDelegate;
[email protected]795c28972012-12-06 06:13:3966struct FaviconURL;
[email protected]09d31d52012-03-11 22:30:2767struct LoadNotificationDetails;
[email protected]f66df822012-05-18 16:52:1768
69// Factory function for the implementations that content knows about. Takes
70// ownership of |delegate|.
[email protected]60780f412013-02-25 16:34:1071WebContentsViewPort* CreateWebContentsView(
[email protected]5a3bdf52012-05-24 15:12:5772 WebContentsImpl* web_contents,
73 WebContentsViewDelegate* delegate,
74 RenderViewHostDelegateView** render_view_host_delegate_view);
[email protected]97714c82012-06-06 10:15:1375
[email protected]b172aee2012-04-10 17:05:2676class CONTENT_EXPORT WebContentsImpl
[email protected]8ff00d72012-10-23 19:12:2177 : public NON_EXPORTED_BASE(WebContents),
78 public RenderViewHostDelegate,
79 public RenderWidgetHostDelegate,
[email protected]14392a52012-05-02 20:28:4480 public RenderViewHostManager::Delegate,
[email protected]ec6c05f2013-10-23 18:41:5781 public NotificationObserver,
82 public NON_EXPORTED_BASE(NavigationControllerDelegate) {
[email protected]0dd3a0ab2011-02-18 08:17:4483 public:
[email protected]b172aee2012-04-10 17:05:2684 virtual ~WebContentsImpl();
[email protected]0dd3a0ab2011-02-18 08:17:4485
[email protected]d1198fd2012-08-13 22:50:1986 static WebContentsImpl* CreateWithOpener(
[email protected]54944cde2012-12-09 09:24:5987 const WebContents::CreateParams& params,
[email protected]d1198fd2012-08-13 22:50:1988 WebContentsImpl* opener);
89
[email protected]3de10bb32013-01-08 21:57:3390 // Returns the opener WebContentsImpl, if any. This can be set to null if the
91 // opener is closed or the page clears its window.opener.
92 WebContentsImpl* opener() const { return opener_; }
93
[email protected]7a846df2012-09-20 19:17:3994 // Creates a WebContents to be used as a browser plugin guest.
[email protected]8eb04562013-03-06 03:41:1495 static BrowserPluginGuest* CreateGuest(
[email protected]dd8c8232012-11-03 00:49:3696 BrowserContext* browser_context,
[email protected]1bc28312012-11-08 08:31:5397 content::SiteInstance* site_instance,
[email protected]738f57a2013-06-29 21:06:5498 int guest_instance_id,
99 scoped_ptr<base::DictionaryValue> extra_params);
[email protected]7a846df2012-09-20 19:17:39100
[email protected]0eba810b2012-10-18 03:19:36101 // Creates a swapped out RenderView. This is used by the browser plugin to
102 // create a swapped out RenderView in the embedder render process for the
103 // guest, to expose the guest's window object to the embedder.
104 // This returns the routing ID of the newly created swapped out RenderView.
[email protected]8ff00d72012-10-23 19:12:21105 int CreateSwappedOutRenderView(SiteInstance* instance);
[email protected]0eba810b2012-10-18 03:19:36106
[email protected]d1198fd2012-08-13 22:50:19107 // Complex initialization here. Specifically needed to avoid having
108 // members call back into our virtual functions in the constructor.
[email protected]54944cde2012-12-09 09:24:59109 virtual void Init(const WebContents::CreateParams& params);
[email protected]d1198fd2012-08-13 22:50:19110
[email protected]c7dd2f62011-07-18 15:57:59111 // Returns the SavePackage which manages the page saving job. May be NULL.
112 SavePackage* save_package() const { return save_package_.get(); }
113
[email protected]c7654a232013-06-12 21:04:44114#if defined(OS_ANDROID)
[email protected]276b37a22011-11-08 20:45:46115 JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const {
116 return java_bridge_dispatcher_host_manager_.get();
117 }
[email protected]7d244f12013-08-22 21:41:51118
119 // In Android WebView, the RenderView needs created even there is no
120 // navigation entry, this allows Android WebViews to use
121 // javascript: URLs that load into the DOMWindow before the first page
122 // load. This is not safe to do in any context that a web page could get a
123 // reference to the DOMWindow before the first page load.
124 bool CreateRenderViewForInitialEmptyDocument();
[email protected]4cc1ab52013-01-21 19:24:34125#endif
[email protected]276b37a22011-11-08 20:45:46126
[email protected]765187182012-01-11 23:59:28127 // Expose the render manager for testing.
128 RenderViewHostManager* GetRenderManagerForTesting();
129
[email protected]7a846df2012-09-20 19:17:39130 // Returns guest browser plugin object, or NULL if this WebContents is not a
131 // guest.
[email protected]f8497342013-02-05 22:15:02132 BrowserPluginGuest* GetBrowserPluginGuest() const;
[email protected]738f57a2013-06-29 21:06:54133
134 // Sets a BrowserPluginGuest object for this WebContents. If this WebContents
135 // has a BrowserPluginGuest then that implies that it is being hosted by
136 // a BrowserPlugin object in an embedder renderer process.
137 void SetBrowserPluginGuest(BrowserPluginGuest* guest);
138
[email protected]7a846df2012-09-20 19:17:39139 // Returns embedder browser plugin object, or NULL if this WebContents is not
140 // an embedder.
[email protected]f8497342013-02-05 22:15:02141 BrowserPluginEmbedder* GetBrowserPluginEmbedder() const;
[email protected]738f57a2013-06-29 21:06:54142
[email protected]8eb04562013-03-06 03:41:14143 // Returns the BrowserPluginGuestManager object, or NULL if this web contents
144 // does not have a BrowserPluginGuestManager.
145 BrowserPluginGuestManager* GetBrowserPluginGuestManager() const;
[email protected]7a846df2012-09-20 19:17:39146
[email protected]44470a22013-01-24 01:21:54147 // Gets the current fullscreen render widget's routing ID. Returns
148 // MSG_ROUTING_NONE when there is no fullscreen render widget.
149 int GetFullscreenWidgetRoutingID() const;
150
[email protected]e67ebf32013-02-13 11:07:19151 // Invoked when visible SSL state (as defined by SSLStatus) changes.
152 void DidChangeVisibleSSLState();
153
[email protected]cf200a562013-05-03 16:24:29154 // Informs the render view host and the BrowserPluginEmbedder, if present, of
155 // a Drag Source End.
156 void DragSourceEndedAt(int client_x, int client_y, int screen_x,
157 int screen_y, WebKit::WebDragOperation operation);
158
159 // Informs the render view host and the BrowserPluginEmbedder, if present, of
160 // a Drag Source Move.
161 void DragSourceMovedTo(int client_x, int client_y,
162 int screen_x, int screen_y);
163
[email protected]8ff00d72012-10-23 19:12:21164 // WebContents ------------------------------------------------------
165 virtual WebContentsDelegate* GetDelegate() OVERRIDE;
166 virtual void SetDelegate(WebContentsDelegate* delegate) OVERRIDE;
[email protected]d1198fd2012-08-13 22:50:19167 virtual NavigationControllerImpl& GetController() OVERRIDE;
168 virtual const NavigationControllerImpl& GetController() const OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21169 virtual BrowserContext* GetBrowserContext() const OVERRIDE;
170 virtual RenderProcessHost* GetRenderProcessHost() const OVERRIDE;
171 virtual RenderViewHost* GetRenderViewHost() const OVERRIDE;
[email protected]a04c9d02012-11-14 21:04:34172 virtual void GetRenderViewHostAtPosition(
173 int x,
174 int y,
175 const GetRenderViewHostCallback& callback) OVERRIDE;
[email protected]bfcfa692013-02-07 06:17:02176 virtual WebContents* GetEmbedderWebContents() const OVERRIDE;
177 virtual int GetEmbeddedInstanceID() const OVERRIDE;
[email protected]6b618e62012-08-16 12:59:18178 virtual int GetRoutingID() const OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21179 virtual RenderWidgetHostView* GetRenderWidgetHostView() const OVERRIDE;
[email protected]4aebbca2013-09-17 22:26:49180 virtual RenderWidgetHostView* GetFullscreenRenderWidgetHostView() const
181 OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21182 virtual WebContentsView* GetView() const OVERRIDE;
183 virtual WebUI* CreateWebUI(const GURL& url) OVERRIDE;
184 virtual WebUI* GetWebUI() const OVERRIDE;
185 virtual WebUI* GetCommittedWebUI() const OVERRIDE;
[email protected]86ef6a392012-05-11 22:03:11186 virtual void SetUserAgentOverride(const std::string& override) OVERRIDE;
187 virtual const std::string& GetUserAgentOverride() const OVERRIDE;
[email protected]c73a2282013-04-29 21:10:41188#if defined(OS_WIN) && defined(USE_AURA)
189 virtual void SetParentNativeViewAccessible(
190 gfx::NativeViewAccessible accessible_parent) OVERRIDE;
191#endif
[email protected]be1f56ab2011-12-22 06:55:31192 virtual const string16& GetTitle() const OVERRIDE;
193 virtual int32 GetMaxPageID() OVERRIDE;
194 virtual int32 GetMaxPageIDForSiteInstance(
[email protected]8ff00d72012-10-23 19:12:21195 SiteInstance* site_instance) OVERRIDE;
196 virtual SiteInstance* GetSiteInstance() const OVERRIDE;
197 virtual SiteInstance* GetPendingSiteInstance() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31198 virtual bool IsLoading() const OVERRIDE;
199 virtual bool IsWaitingForResponse() const OVERRIDE;
200 virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE;
201 virtual const string16& GetLoadStateHost() const OVERRIDE;
202 virtual uint64 GetUploadSize() const OVERRIDE;
203 virtual uint64 GetUploadPosition() const OVERRIDE;
[email protected]1ae93fb2013-06-14 03:38:56204 virtual std::set<GURL> GetSitesInTab() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31205 virtual const std::string& GetEncoding() const OVERRIDE;
206 virtual bool DisplayedInsecureContent() const OVERRIDE;
[email protected]54597982013-02-06 01:59:55207 virtual void IncrementCapturerCount() OVERRIDE;
208 virtual void DecrementCapturerCount() OVERRIDE;
[email protected]f2bd40812013-07-20 04:30:44209 virtual int GetCapturerCount() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31210 virtual bool IsCrashed() const OVERRIDE;
211 virtual void SetIsCrashed(base::TerminationStatus status,
212 int error_code) OVERRIDE;
213 virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE;
214 virtual bool IsBeingDestroyed() const OVERRIDE;
215 virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31216 virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE;
[email protected]9e2e4632012-07-27 16:38:41217 virtual void WasShown() OVERRIDE;
[email protected]3e324142012-06-25 18:26:33218 virtual void WasHidden() OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31219 virtual bool NeedToFireBeforeUnload() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27220 virtual void Stop() OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21221 virtual WebContents* Clone() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27222 virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE;
223 virtual bool ShowingInterstitialPage() const OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21224 virtual InterstitialPage* GetInterstitialPage() const OVERRIDE;
[email protected]a53209b2012-01-20 16:48:16225 virtual bool IsSavable() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27226 virtual void OnSavePage() OVERRIDE;
[email protected]2dec8ec2013-02-07 19:20:34227 virtual bool SavePage(const base::FilePath& main_file,
228 const base::FilePath& dir_path,
[email protected]8ff00d72012-10-23 19:12:21229 SavePageType save_type) OVERRIDE;
[email protected]3c71576ce2013-07-23 02:00:01230 virtual void SaveFrame(const GURL& url,
231 const Referrer& referrer) OVERRIDE;
[email protected]aa4f3972012-03-01 18:12:12232 virtual void GenerateMHTML(
[email protected]2dec8ec2013-02-07 19:20:34233 const base::FilePath& file,
[email protected]18516cf92013-08-28 18:19:48234 const base::Callback<void(int64)>& callback)
[email protected]2dec8ec2013-02-07 19:20:34235 OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27236 virtual bool IsActiveEntry(int32 page_id) OVERRIDE;
237
238 virtual const std::string& GetContentsMimeType() const OVERRIDE;
239 virtual bool WillNotifyDisconnection() const OVERRIDE;
240 virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE;
241 virtual void ResetOverrideEncoding() OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21242 virtual RendererPreferences* GetMutableRendererPrefs() OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47243 virtual void Close() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27244 virtual void SystemDragEnded() OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47245 virtual void UserGestureDone() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27246 virtual void SetClosedByUserGesture(bool value) OVERRIDE;
247 virtual bool GetClosedByUserGesture() const OVERRIDE;
248 virtual double GetZoomLevel() const OVERRIDE;
249 virtual int GetZoomPercent(bool* enable_increment,
[email protected]9a8408902012-09-26 16:17:59250 bool* enable_decrement) const OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27251 virtual void ViewSource() OVERRIDE;
252 virtual void ViewFrameSource(const GURL& url,
[email protected]691aa2f2013-05-28 22:52:04253 const PageState& page_state) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27254 virtual int GetMinimumZoomPercent() const OVERRIDE;
255 virtual int GetMaximumZoomPercent() const OVERRIDE;
[email protected]bcd2815602012-01-14 18:17:23256 virtual gfx::Size GetPreferredSize() const OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27257 virtual bool GotResponseToLockMouseRequest(bool allowed) OVERRIDE;
[email protected]a0358d72012-03-09 14:06:50258 virtual bool HasOpener() const OVERRIDE;
[email protected]cb805452013-05-22 15:16:21259 virtual void DidChooseColorInColorChooser(SkColor color) OVERRIDE;
260 virtual void DidEndColorChooser() OVERRIDE;
[email protected]41225fe2013-03-29 05:32:02261 virtual int DownloadImage(const GURL& url,
262 bool is_favicon,
[email protected]263cb08f2013-09-18 00:26:30263 uint32_t max_bitmap_size,
[email protected]41225fe2013-03-29 05:32:02264 const ImageDownloadCallback& callback) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27265
266 // Implementation of PageNavigator.
[email protected]8ff00d72012-10-23 19:12:21267 virtual WebContents* OpenURL(const OpenURLParams& params) OVERRIDE;
[email protected]151a63d2011-12-20 22:32:52268
[email protected]6b618e62012-08-16 12:59:18269 // Implementation of IPC::Sender.
270 virtual bool Send(IPC::Message* message) OVERRIDE;
271
[email protected]952a68e2011-11-17 00:36:10272 // RenderViewHostDelegate ----------------------------------------------------
273
[email protected]8ff00d72012-10-23 19:12:21274 virtual RenderViewHostDelegateView* GetDelegateView() OVERRIDE;
275 virtual RenderViewHostDelegate::RendererManagement*
[email protected]952a68e2011-11-17 00:36:10276 GetRendererManagementDelegate() OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21277 virtual bool OnMessageReceived(RenderViewHost* render_view_host,
[email protected]7bb761892012-07-20 09:32:47278 const IPC::Message& message) OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31279 virtual const GURL& GetURL() const OVERRIDE;
[email protected]a093ce02013-07-22 20:53:14280 virtual const GURL& GetVisibleURL() const OVERRIDE;
[email protected]c854a7e2013-05-21 16:42:24281 virtual const GURL& GetLastCommittedURL() const OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21282 virtual WebContents* GetAsWebContents() OVERRIDE;
[email protected]b7a756d42012-01-23 18:08:17283 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21284 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
285 virtual void RenderViewReady(RenderViewHost* render_view_host) OVERRIDE;
[email protected]ec6a7eb2013-04-22 17:34:22286 virtual void RenderViewTerminated(RenderViewHost* render_view_host,
287 base::TerminationStatus status,
288 int error_code) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21289 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57290 virtual void DidStartProvisionalLoadForFrame(
[email protected]8ff00d72012-10-23 19:12:21291 RenderViewHost* render_view_host,
[email protected]54047eb52012-05-08 21:45:57292 int64 frame_id,
[email protected]d37c33e2012-10-12 13:35:13293 int64 parent_frame_id,
[email protected]54047eb52012-05-08 21:45:57294 bool main_frame,
[email protected]54047eb52012-05-08 21:45:57295 const GURL& url) OVERRIDE;
[email protected]400992b2012-06-14 00:03:54296 virtual void DidRedirectProvisionalLoad(
[email protected]8ff00d72012-10-23 19:12:21297 RenderViewHost* render_view_host,
[email protected]400992b2012-06-14 00:03:54298 int32 page_id,
[email protected]400992b2012-06-14 00:03:54299 const GURL& source_url,
300 const GURL& target_url) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57301 virtual void DidFailProvisionalLoadWithError(
[email protected]8ff00d72012-10-23 19:12:21302 RenderViewHost* render_view_host,
[email protected]54047eb52012-05-08 21:45:57303 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params)
304 OVERRIDE;
[email protected]b0f724c2013-09-05 04:21:13305 virtual void DidGetResourceResponseStart(
306 const ResourceRequestDetails& details) OVERRIDE;
307 virtual void DidGetRedirectForResourceRequest(
308 const ResourceRedirectDetails& details) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10309 virtual void DidNavigate(
[email protected]8ff00d72012-10-23 19:12:21310 RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10311 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21312 virtual void UpdateState(RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10313 int32 page_id,
[email protected]691aa2f2013-05-28 22:52:04314 const PageState& page_state) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21315 virtual void UpdateTitle(RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10316 int32 page_id,
317 const string16& title,
318 base::i18n::TextDirection title_direction) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21319 virtual void UpdateEncoding(RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10320 const std::string& encoding) OVERRIDE;
321 virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21322 virtual void Close(RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10323 virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21324 virtual void SwappedOut(RenderViewHost* render_view_host) OVERRIDE;
325 virtual void DidStartLoading(RenderViewHost* render_view_host) OVERRIDE;
326 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10327 virtual void DidCancelLoading() OVERRIDE;
328 virtual void DidChangeLoadProgress(double progress) OVERRIDE;
[email protected]7cc78902012-12-06 02:32:26329 virtual void DidDisownOpener(RenderViewHost* rvh) OVERRIDE;
[email protected]59167c22013-06-03 18:07:32330 virtual void DidAccessInitialDocument() OVERRIDE;
[email protected]87717d0e2012-04-26 02:58:43331 virtual void DocumentAvailableInMainFrame(
[email protected]8ff00d72012-10-23 19:12:21332 RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10333 virtual void DocumentOnLoadCompletedInMainFrame(
[email protected]8ff00d72012-10-23 19:12:21334 RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10335 int32 page_id) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21336 virtual void RequestOpenURL(RenderViewHost* rvh,
[email protected]196159d2012-05-04 17:26:54337 const GURL& url,
[email protected]8ff00d72012-10-23 19:12:21338 const Referrer& referrer,
[email protected]952a68e2011-11-17 00:36:10339 WindowOpenDisposition disposition,
[email protected]e2caa032012-11-15 23:29:18340 int64 source_frame_id,
[email protected]866fa2cc2013-07-22 22:19:52341 bool should_replace_current_entry,
[email protected]e7f2e7c2013-07-15 09:41:30342 bool user_gesture) OVERRIDE;
[email protected]4ad5d77d2011-12-03 02:00:48343 virtual void RequestTransferURL(
344 const GURL& url,
[email protected]f8872902013-10-30 03:18:57345 const std::vector<GURL>& redirect_chain,
[email protected]8ff00d72012-10-23 19:12:21346 const Referrer& referrer,
[email protected]f8872902013-10-30 03:18:57347 PageTransition page_transition,
[email protected]4ad5d77d2011-12-03 02:00:48348 WindowOpenDisposition disposition,
349 int64 source_frame_id,
[email protected]e2caa032012-11-15 23:29:18350 const GlobalRequestID& transferred_global_request_id,
[email protected]866fa2cc2013-07-22 22:19:52351 bool should_replace_current_entry,
[email protected]e7f2e7c2013-07-15 09:41:30352 bool user_gesture) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21353 virtual void RouteCloseEvent(RenderViewHost* rvh) OVERRIDE;
[email protected]f546640b2012-05-15 00:03:49354 virtual void RouteMessageEvent(
[email protected]8ff00d72012-10-23 19:12:21355 RenderViewHost* rvh,
[email protected]f546640b2012-05-15 00:03:49356 const ViewMsg_PostMessage_Params& params) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21357 virtual void RunJavaScriptMessage(RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10358 const string16& message,
359 const string16& default_prompt,
360 const GURL& frame_url,
[email protected]8ff00d72012-10-23 19:12:21361 JavaScriptMessageType type,
[email protected]952a68e2011-11-17 00:36:10362 IPC::Message* reply_msg,
363 bool* did_suppress_message) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21364 virtual void RunBeforeUnloadConfirm(RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10365 const string16& message,
[email protected]3b3301f62012-02-29 04:32:32366 bool is_reload,
[email protected]952a68e2011-11-17 00:36:10367 IPC::Message* reply_msg) OVERRIDE;
[email protected]a796f202012-05-30 14:14:25368 virtual bool AddMessageToConsole(int32 level,
369 const string16& message,
370 int32 line_no,
[email protected]88b50b62013-09-01 23:05:06371 const string16& source_id) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21372 virtual RendererPreferences GetRendererPrefs(
373 BrowserContext* browser_context) const OVERRIDE;
[email protected]3184f90b2013-05-01 18:17:53374 virtual WebPreferences GetWebkitPrefs() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10375 virtual void OnUserGesture() OVERRIDE;
376 virtual void OnIgnoredUIEvent() OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21377 virtual void RendererUnresponsive(RenderViewHost* render_view_host,
[email protected]2e9d79f2013-08-16 05:45:56378 bool is_during_beforeunload,
[email protected]952a68e2011-11-17 00:36:10379 bool is_during_unload) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21380 virtual void RendererResponsive(RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10381 virtual void LoadStateChanged(const GURL& url,
382 const net::LoadStateWithParam& load_state,
383 uint64 upload_position,
384 uint64 upload_size) OVERRIDE;
385 virtual void WorkerCrashed() OVERRIDE;
386 virtual void Activate() OVERRIDE;
387 virtual void Deactivate() OVERRIDE;
388 virtual void LostCapture() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10389 virtual void HandleMouseDown() OVERRIDE;
390 virtual void HandleMouseUp() OVERRIDE;
[email protected]590a634e2012-07-19 16:38:23391 virtual void HandlePointerActivate() OVERRIDE;
392 virtual void HandleGestureBegin() OVERRIDE;
393 virtual void HandleGestureEnd() OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38394 virtual void RunFileChooser(
[email protected]8ff00d72012-10-23 19:12:21395 RenderViewHost* render_view_host,
396 const FileChooserParams& params) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10397 virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
398 virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
399 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
[email protected]61e2b3cc2012-03-02 16:13:34400 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
[email protected]a9c81f02012-06-01 00:15:44401 virtual void RequestToLockMouse(bool user_gesture,
402 bool last_unlocked_by_target) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10403 virtual void LostMouseLock() OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50404 virtual void CreateNewWindow(
405 int route_id,
[email protected]227692c52013-05-31 22:43:04406 int main_frame_route_id,
[email protected]97714c82012-06-06 10:15:13407 const ViewHostMsg_CreateWindow_Params& params,
[email protected]8ff00d72012-10-23 19:12:21408 SessionStorageNamespace* session_storage_namespace) OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50409 virtual void CreateNewWidget(int route_id,
410 WebKit::WebPopupType popup_type) OVERRIDE;
411 virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
412 virtual void ShowCreatedWindow(int route_id,
413 WindowOpenDisposition disposition,
414 const gfx::Rect& initial_pos,
415 bool user_gesture) OVERRIDE;
416 virtual void ShowCreatedWidget(int route_id,
417 const gfx::Rect& initial_pos) OVERRIDE;
418 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
[email protected]f56c7872013-06-18 12:31:57419 virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE;
[email protected]f13b4202012-06-12 23:53:23420 virtual void RequestMediaAccessPermission(
[email protected]33662e52013-01-07 21:31:09421 const MediaStreamRequest& request,
[email protected]8ff00d72012-10-23 19:12:21422 const MediaResponseCallback& callback) OVERRIDE;
[email protected]cc9200432013-07-23 23:02:40423 virtual SessionStorageNamespace* GetSessionStorageNamespace(
424 SiteInstance* instance) OVERRIDE;
[email protected]9b159a52013-10-03 17:24:55425 virtual FrameTree* GetFrameTree() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10426
[email protected]4ca76c02012-05-16 16:19:05427 // RenderWidgetHostDelegate --------------------------------------------------
428
[email protected]b24b68a2012-09-24 21:57:26429 virtual void RenderWidgetDeleted(
[email protected]8ff00d72012-10-23 19:12:21430 RenderWidgetHostImpl* render_widget_host) OVERRIDE;
[email protected]b87ee522012-05-18 15:16:54431 virtual bool PreHandleKeyboardEvent(
[email protected]8ff00d72012-10-23 19:12:21432 const NativeWebKeyboardEvent& event,
[email protected]b87ee522012-05-18 15:16:54433 bool* is_keyboard_shortcut) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05434 virtual void HandleKeyboardEvent(
[email protected]8ff00d72012-10-23 19:12:21435 const NativeWebKeyboardEvent& event) OVERRIDE;
[email protected]fb3f066e2013-02-12 19:12:52436 virtual bool PreHandleWheelEvent(
437 const WebKit::WebMouseWheelEvent& event) OVERRIDE;
[email protected]32deec62013-05-15 23:55:04438 virtual void DidSendScreenRects(RenderWidgetHostImpl* rwh) OVERRIDE;
[email protected]c73a2282013-04-29 21:10:41439#if defined(OS_WIN) && defined(USE_AURA)
440 virtual gfx::NativeViewAccessible GetParentNativeViewAccessible() OVERRIDE;
441#endif
[email protected]4ca76c02012-05-16 16:19:05442
[email protected]0bfbf882011-12-22 18:19:27443 // RenderViewHostManager::Delegate -------------------------------------------
444
445 virtual bool CreateRenderViewForRenderManager(
[email protected]8ff00d72012-10-23 19:12:21446 RenderViewHost* render_view_host, int opener_route_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27447 virtual void BeforeUnloadFiredFromRenderManager(
[email protected]feaded02012-09-25 19:12:55448 bool proceed, const base::TimeTicks& proceed_time,
[email protected]0bfbf882011-12-22 18:19:27449 bool* proceed_to_fire_unload) OVERRIDE;
[email protected]58d5cfe2013-07-10 02:40:52450 virtual void RenderProcessGoneFromRenderManager(
[email protected]8ff00d72012-10-23 19:12:21451 RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27452 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
[email protected]af905902013-10-01 21:38:51453 virtual void CancelModalDialogsForRenderManager() OVERRIDE;
[email protected]35e0e0792012-11-30 02:35:48454 virtual void NotifySwappedFromRenderManager(
[email protected]7b712ee22013-10-03 00:57:28455 RenderViewHost* old_host, RenderViewHost* new_host) OVERRIDE;
[email protected]14392a52012-05-02 20:28:44456 virtual int CreateOpenerRenderViewsForRenderManager(
[email protected]8ff00d72012-10-23 19:12:21457 SiteInstance* instance) OVERRIDE;
458 virtual NavigationControllerImpl&
459 GetControllerForRenderManager() OVERRIDE;
[email protected]d2353452012-01-19 19:53:56460 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21461 virtual NavigationEntry*
[email protected]0bfbf882011-12-22 18:19:27462 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
463 virtual bool FocusLocationBarByDefault() OVERRIDE;
464 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
[email protected]8ff00d72012-10-23 19:12:21465 virtual void CreateViewAndSetSizeForRVH(RenderViewHost* rvh) OVERRIDE;
[email protected]1ac10dca2013-08-20 20:47:04466 virtual bool IsHidden() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27467
[email protected]8ff00d72012-10-23 19:12:21468 // NotificationObserver ------------------------------------------------------
[email protected]14392a52012-05-02 20:28:44469
470 virtual void Observe(int type,
[email protected]8ff00d72012-10-23 19:12:21471 const NotificationSource& source,
472 const NotificationDetails& details) OVERRIDE;
[email protected]14392a52012-05-02 20:28:44473
[email protected]ec6c05f2013-10-23 18:41:57474 // NavigationControllerDelegate ----------------------------------------------
475
476 virtual WebContents* GetWebContents() OVERRIDE;
477 virtual void NotifyNavigationEntryCommitted(
478 const LoadCommittedDetails& load_details) OVERRIDE;
479
480 // Invoked before a form repost warning is shown.
481 virtual void NotifyBeforeFormRepostWarningShow() OVERRIDE;
482
483 // Activate this WebContents and show a form repost warning.
484 virtual void ActivateAndShowRepostFormWarningDialog() OVERRIDE;
485
486 // Updates the max page ID for the current SiteInstance in this
487 // WebContentsImpl to be at least |page_id|.
488 virtual void UpdateMaxPageID(int32 page_id) OVERRIDE;
489
490 // Updates the max page ID for the given SiteInstance in this WebContentsImpl
491 // to be at least |page_id|.
492 virtual void UpdateMaxPageIDForSiteInstance(SiteInstance* site_instance,
493 int32 page_id) OVERRIDE;
494
495 // Copy the current map of SiteInstance ID to max page ID from another tab.
496 // This is necessary when this tab adopts the NavigationEntries from
497 // |web_contents|.
498 virtual void CopyMaxPageIDsFrom(WebContents* web_contents) OVERRIDE;
499
500 // Called by the NavigationController to cause the WebContentsImpl to navigate
501 // to the current pending entry. The NavigationController should be called
502 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
503 // The callbacks can be inside of this function, or at some future time.
504 //
505 // The entry has a PageID of -1 if newly created (corresponding to navigation
506 // to a new URL).
507 //
508 // If this method returns false, then the navigation is discarded (equivalent
509 // to calling DiscardPendingEntry on the NavigationController).
510 virtual bool NavigateToPendingEntry(
511 NavigationController::ReloadType reload_type) OVERRIDE;
512
513 // Sets the history for this WebContentsImpl to |history_length| entries, and
514 // moves the current page_id to the last entry in the list if it's valid.
515 // This is mainly used when a prerendered page is swapped into the current
516 // tab. The method is virtual for testing.
517 virtual void SetHistoryLengthAndPrune(
518 const SiteInstance* site_instance,
519 int merge_history_length,
520 int32 minimum_page_id) OVERRIDE;
[email protected]553602e12011-04-05 17:01:18521
[email protected]561628ce2013-10-25 00:56:47522 // Called by InterstitialPageImpl when it creates a RenderViewHost.
523 virtual void RenderViewForInterstitialPageCreated(
524 RenderViewHost* render_view_host) OVERRIDE;
525
526 // Sets the passed interstitial as the currently showing interstitial.
527 // No interstitial page should already be attached.
528 virtual void AttachInterstitialPage(
529 InterstitialPageImpl* interstitial_page) OVERRIDE;
530
531 // Unsets the currently showing interstitial.
532 virtual void DetachInterstitialPage() OVERRIDE;
533
534 // Changes the IsLoading state and notifies the delegate as needed.
535 // |details| is used to provide details on the load that just finished
536 // (but can be null if not applicable).
537 virtual void SetIsLoading(RenderViewHost* render_view_host,
538 bool is_loading,
539 LoadNotificationDetails* details) OVERRIDE;
540
541
[email protected]0dd3a0ab2011-02-18 08:17:44542 private:
[email protected]d202a7c2012-01-04 07:53:47543 friend class NavigationControllerImpl;
[email protected]8ff00d72012-10-23 19:12:21544 friend class WebContentsObserver;
545 friend class WebContents; // To implement factory methods.
[email protected]0dd3a0ab2011-02-18 08:17:44546
[email protected]2db9bd72012-04-13 20:20:56547 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
548 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
[email protected]45a22ad2013-02-21 03:25:00549 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FindOpenerRVHWhenPending);
[email protected]2db9bd72012-04-13 20:20:56550 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
551 CrossSiteCantPreemptAfterUnload);
[email protected]ceee8cd2013-03-08 04:59:51552 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, PendingContents);
[email protected]50904452013-05-09 02:05:12553 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FrameTreeShape);
[email protected]0dd3a0ab2011-02-18 08:17:44554 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
555 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
556 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
557
[email protected]cadaec52012-02-08 21:53:13558 // So InterstitialPageImpl can access SetIsLoading.
559 friend class InterstitialPageImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44560
[email protected]80e776ae2012-03-23 16:17:20561 // TODO(brettw) TestWebContents shouldn't exist!
[email protected]8ff00d72012-10-23 19:12:21562 friend class TestWebContents;
[email protected]0dd3a0ab2011-02-18 08:17:44563
[email protected]7fff43e2013-05-21 20:21:10564 class DestructionObserver;
565
[email protected]d1198fd2012-08-13 22:50:19566 // See WebContents::Create for a description of these parameters.
[email protected]8ff00d72012-10-23 19:12:21567 WebContentsImpl(BrowserContext* browser_context,
[email protected]d1198fd2012-08-13 22:50:19568 WebContentsImpl* opener);
569
570 // Add and remove observers for page navigation notifications. Adding or
571 // removing multiple times has no effect. The order in which notifications
572 // are sent to observers is undefined. Clients must be sure to remove the
573 // observer before they go away.
[email protected]8ff00d72012-10-23 19:12:21574 void AddObserver(WebContentsObserver* observer);
575 void RemoveObserver(WebContentsObserver* observer);
[email protected]d1198fd2012-08-13 22:50:19576
[email protected]14392a52012-05-02 20:28:44577 // Clears this tab's opener if it has been closed.
[email protected]7fff43e2013-05-21 20:21:10578 void OnWebContentsDestroyed(WebContentsImpl* web_contents);
579
580 // Creates and adds to the map a destruction observer watching |web_contents|.
581 // No-op if such an observer already exists.
582 void AddDestructionObserver(WebContentsImpl* web_contents);
583
584 // Deletes and removes from the map a destruction observer
585 // watching |web_contents|. No-op if there is no such observer.
586 void RemoveDestructionObserver(WebContentsImpl* web_contents);
[email protected]14392a52012-05-02 20:28:44587
[email protected]51da7e32012-01-30 19:24:52588 // Callback function when showing JS dialogs.
[email protected]8ff00d72012-10-23 19:12:21589 void OnDialogClosed(RenderViewHost* rvh,
[email protected]51da7e32012-01-30 19:24:52590 IPC::Message* reply_msg,
591 bool success,
592 const string16& user_input);
593
[email protected]d8415ad92012-08-23 14:40:50594 // Callback function when requesting permission to access the PPAPI broker.
595 // |result| is true if permission was granted.
[email protected]ea0309c2013-08-06 19:35:44596 void OnPpapiBrokerPermissionResult(int routing_id, bool result);
[email protected]d8415ad92012-08-23 14:40:50597
[email protected]d0759f492012-04-19 22:50:50598 // IPC message handlers.
[email protected]0dd3a0ab2011-02-18 08:17:44599 void OnDidLoadResourceFromMemoryCache(const GURL& url,
[email protected]70435962011-08-02 20:13:28600 const std::string& security_info,
601 const std::string& http_request,
[email protected]6d6cfb3a2012-05-23 22:53:18602 const std::string& mime_type,
[email protected]70435962011-08-02 20:13:28603 ResourceType::Type resource_type);
[email protected]0dd3a0ab2011-02-18 08:17:44604 void OnDidDisplayInsecureContent();
605 void OnDidRunInsecureContent(const std::string& security_origin,
606 const GURL& target_url);
607 void OnDocumentLoadedInFrame(int64 frame_id);
[email protected]1a55c5be2011-11-29 11:36:31608 void OnDidFinishLoad(int64 frame_id,
[email protected]b502ed462013-01-08 08:20:06609 const GURL& url,
[email protected]1a55c5be2011-11-29 11:36:31610 bool is_main_frame);
611 void OnDidFailLoadWithError(int64 frame_id,
[email protected]b502ed462013-01-08 08:20:06612 const GURL& url,
[email protected]1a55c5be2011-11-29 11:36:31613 bool is_main_frame,
614 int error_code,
615 const string16& error_description);
[email protected]0dd3a0ab2011-02-18 08:17:44616 void OnGoToEntryAtOffset(int offset);
[email protected]216813952011-05-19 22:21:26617 void OnUpdateZoomLimits(int minimum_percent,
618 int maximum_percent,
619 bool remember);
[email protected]2dec8ec2013-02-07 19:20:34620 void OnEnumerateDirectory(int request_id, const base::FilePath& path);
[email protected]7d189022011-08-25 22:54:20621 void OnJSOutOfMemory();
[email protected]b7a756d42012-01-23 18:08:17622
[email protected]7d189022011-08-25 22:54:20623 void OnRegisterProtocolHandler(const std::string& protocol,
624 const GURL& url,
[email protected]3a3b75a2012-06-01 08:38:36625 const string16& title,
626 bool user_gesture);
[email protected]59363fc92012-09-05 03:46:31627 void OnFindReply(int request_id,
628 int number_of_matches,
629 const gfx::Rect& selection_rect,
630 int active_match_ordinal,
[email protected]b888919c2011-09-02 00:32:16631 bool final_update);
[email protected]59363fc92012-09-05 03:46:31632#if defined(OS_ANDROID)
633 void OnFindMatchRectsReply(int version,
634 const std::vector<gfx::RectF>& rects,
635 const gfx::RectF& active_rect);
[email protected]583418cc2013-01-17 14:01:10636
[email protected]1ff427972013-02-07 21:14:07637 void OnOpenDateTimeDialog(
638 const ViewHostMsg_DateTimeDialogValue_Params& value);
[email protected]a794f3a2013-10-30 17:00:32639 void OnJavaBridgeGetChannelHandle(IPC::Message* reply_msg);
[email protected]59363fc92012-09-05 03:46:31640#endif
[email protected]2dec8ec2013-02-07 19:20:34641 void OnCrashedPlugin(const base::FilePath& plugin_path,
642 base::ProcessId plugin_pid);
[email protected]7fc4bbb2011-09-08 21:23:10643 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
[email protected]55578b0a2012-04-18 14:31:32644 void OnOpenColorChooser(int color_chooser_id, SkColor color);
[email protected]da8543762012-03-20 08:52:20645 void OnEndColorChooser(int color_chooser_id);
[email protected]55578b0a2012-04-18 14:31:32646 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
[email protected]8be45842012-04-13 19:49:29647 void OnPepperPluginHung(int plugin_child_id,
[email protected]2dec8ec2013-02-07 19:20:34648 const base::FilePath& path,
[email protected]8be45842012-04-13 19:49:29649 bool is_hung);
[email protected]d0759f492012-04-19 22:50:50650 void OnWebUISend(const GURL& source_url,
651 const std::string& name,
652 const base::ListValue& args);
[email protected]ea0309c2013-08-06 19:35:44653 void OnRequestPpapiBrokerPermission(int routing_id,
[email protected]d8415ad92012-08-23 14:40:50654 const GURL& url,
[email protected]2dec8ec2013-02-07 19:20:34655 const base::FilePath& plugin_path);
[email protected]c4538072013-03-18 02:17:55656 void OnBrowserPluginMessage(const IPC::Message& message);
[email protected]41225fe2013-03-29 05:32:02657 void OnDidDownloadImage(int id,
[email protected]749fadd2013-05-15 08:37:48658 int http_status_code,
[email protected]41225fe2013-03-29 05:32:02659 const GURL& image_url,
[email protected]263cb08f2013-09-18 00:26:30660 const std::vector<SkBitmap>& bitmaps,
661 const std::vector<gfx::Size>& original_bitmap_sizes);
[email protected]795c28972012-12-06 06:13:39662 void OnUpdateFaviconURL(int32 page_id,
663 const std::vector<FaviconURL>& candidates);
[email protected]9f268072013-11-07 00:02:15664 void OnFirstVisuallyNonEmptyPaint(int32 page_id);
[email protected]d9030b82013-07-19 08:26:06665 void OnMediaNotification(int64 player_cookie,
666 bool has_video,
667 bool has_audio,
668 bool is_playing);
669
[email protected]0dd3a0ab2011-02-18 08:17:44670 // Called by derived classes to indicate that we're no longer waiting for a
671 // response. This won't actually update the throbber, but it will get picked
672 // up at the next animation step if the throbber is going.
673 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
674
[email protected]0dd3a0ab2011-02-18 08:17:44675 // Navigation helpers --------------------------------------------------------
676 //
677 // These functions are helpers for Navigate() and DidNavigate().
678
679 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
680 // committed to the navigation controller. Note that the navigation entry is
681 // not provided since it may be invalid/changed after being committed. The
682 // current navigation entry is in the NavigationController at this point.
683 void DidNavigateMainFramePostCommit(
[email protected]8ff00d72012-10-23 19:12:21684 const LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44685 const ViewHostMsg_FrameNavigate_Params& params);
686 void DidNavigateAnyFramePostCommit(
[email protected]8ff00d72012-10-23 19:12:21687 RenderViewHost* render_view_host,
688 const LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44689 const ViewHostMsg_FrameNavigate_Params& params);
690
[email protected]2f7b3c5a2013-06-21 04:59:25691 // Specifies whether the passed in URL should be assigned as the site of the
692 // current SiteInstance, if it does not yet have a site.
693 bool ShouldAssignSiteForURL(const GURL& url);
694
[email protected]74ce1ad2011-12-16 21:51:46695 // If our controller was restored, update the max page ID associated with the
696 // given RenderViewHost to be larger than the number of restored entries.
697 // This is called in CreateRenderView before any navigations in the RenderView
698 // have begun, to prevent any races in updating RenderView::next_page_id.
[email protected]8ff00d72012-10-23 19:12:21699 void UpdateMaxPageIDIfNecessary(RenderViewHost* rvh);
[email protected]0dd3a0ab2011-02-18 08:17:44700
[email protected]0dd3a0ab2011-02-18 08:17:44701 // Saves the given title to the navigation entry and does associated work. It
702 // will update history and the view for the new title, and also synthesize
703 // titles for file URLs that have none (so we require that the URL of the
704 // entry already be set).
705 //
706 // This is used as the backend for state updates, which include a new title,
707 // or the dedicated set title message. It returns true if the new title is
708 // different and was therefore updated.
[email protected]8ff00d72012-10-23 19:12:21709 bool UpdateTitleForEntry(NavigationEntryImpl* entry,
[email protected]10f417c52011-12-28 21:04:23710 const string16& title);
[email protected]0dd3a0ab2011-02-18 08:17:44711
[email protected]b172aee2012-04-10 17:05:26712 // Causes the WebContentsImpl to navigate in the right renderer to |entry|,
713 // which must be already part of the entries in the navigation controller.
[email protected]0dd3a0ab2011-02-18 08:17:44714 // This does not change the NavigationController state.
[email protected]8ff00d72012-10-23 19:12:21715 bool NavigateToEntry(const NavigationEntryImpl& entry,
716 NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44717
[email protected]14392a52012-05-02 20:28:44718 // Recursively creates swapped out RenderViews for this tab's opener chain
719 // (including this tab) in the given SiteInstance, allowing other tabs to send
720 // cross-process JavaScript calls to their opener(s). Returns the route ID of
721 // this tab's RenderView for |instance|.
[email protected]8ff00d72012-10-23 19:12:21722 int CreateOpenerRenderViews(SiteInstance* instance);
[email protected]14392a52012-05-02 20:28:44723
[email protected]bafe6cd2012-05-23 23:09:50724 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
725 void CreateNewWidget(int route_id,
726 bool is_fullscreen,
727 WebKit::WebPopupType popup_type);
728
729 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
730 void ShowCreatedWidget(int route_id,
731 bool is_fullscreen,
732 const gfx::Rect& initial_pos);
733
734 // Finds the new RenderWidgetHost and returns it. Note that this can only be
735 // called once as this call also removes it from the internal map.
[email protected]8ff00d72012-10-23 19:12:21736 RenderWidgetHostView* GetCreatedWidget(int route_id);
[email protected]bafe6cd2012-05-23 23:09:50737
738 // Finds the new WebContentsImpl by route_id, initializes it for
739 // renderer-initiated creation, and returns it. Note that this can only be
740 // called once as this call also removes it from the internal map.
741 WebContentsImpl* GetCreatedWindow(int route_id);
742
[email protected]f8497342013-02-05 22:15:02743 // Returns the RenderWidgetHostView that is associated with a native window
744 // and can be used in showing created widgets.
745 // If this WebContents belongs to a browser plugin guest, there is no native
746 // window 'view' associated with this WebContents. This method returns the
747 // 'view' of the embedder instead.
748 RenderWidgetHostViewPort* GetRenderWidgetHostViewPort() const;
749
[email protected]0dd3a0ab2011-02-18 08:17:44750 // Misc non-view stuff -------------------------------------------------------
751
752 // Helper functions for sending notifications.
[email protected]7b712ee22013-10-03 00:57:28753 void NotifySwapped(RenderViewHost* old_host, RenderViewHost* new_host);
[email protected]0dd3a0ab2011-02-18 08:17:44754 void NotifyDisconnected();
755
[email protected]be1f56ab2011-12-22 06:55:31756 void SetEncoding(const std::string& encoding);
757
[email protected]8ff00d72012-10-23 19:12:21758 RenderViewHostImpl* GetRenderViewHostImpl();
[email protected]9f76c1e2012-03-05 15:15:58759
[email protected]7a846df2012-09-20 19:17:39760 // Removes browser plugin embedder if there is one.
761 void RemoveBrowserPluginEmbedder();
762
[email protected]d9030b82013-07-19 08:26:06763 // Clear |render_view_host|'s PowerSaveBlockers.
764 void ClearPowerSaveBlockers(RenderViewHost* render_view_host);
765
766 // Clear all PowerSaveBlockers, leave power_save_blocker_ empty.
767 void ClearAllPowerSaveBlockers();
768
[email protected]dc0fd432013-08-27 15:29:21769 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView().
770 gfx::Size GetSizeForNewRenderView() const;
771
[email protected]9b159a52013-10-03 17:24:55772 void OnFrameRemoved(RenderViewHostImpl* render_view_host, int64 frame_id);
773
[email protected]0dd3a0ab2011-02-18 08:17:44774 // Data for core operation ---------------------------------------------------
775
776 // Delegate for notifying our owner about stuff. Not owned by us.
[email protected]8ff00d72012-10-23 19:12:21777 WebContentsDelegate* delegate_;
[email protected]0dd3a0ab2011-02-18 08:17:44778
779 // Handles the back/forward list and loading.
[email protected]d202a7c2012-01-04 07:53:47780 NavigationControllerImpl controller_;
[email protected]0dd3a0ab2011-02-18 08:17:44781
782 // The corresponding view.
[email protected]60780f412013-02-25 16:34:10783 scoped_ptr<WebContentsViewPort> view_;
[email protected]0dd3a0ab2011-02-18 08:17:44784
[email protected]5a3bdf52012-05-24 15:12:57785 // The view of the RVHD. Usually this is our WebContentsView implementation,
786 // but if an embedder uses a different WebContentsView, they'll need to
787 // provide this.
[email protected]8ff00d72012-10-23 19:12:21788 RenderViewHostDelegateView* render_view_host_delegate_view_;
[email protected]5a3bdf52012-05-24 15:12:57789
[email protected]bafe6cd2012-05-23 23:09:50790 // Tracks created WebContentsImpl objects that have not been shown yet. They
791 // are identified by the route ID passed to CreateNewWindow.
792 typedef std::map<int, WebContentsImpl*> PendingContents;
793 PendingContents pending_contents_;
794
795 // These maps hold on to the widgets that we created on behalf of the renderer
796 // that haven't shown yet.
[email protected]8ff00d72012-10-23 19:12:21797 typedef std::map<int, RenderWidgetHostView*> PendingWidgetViews;
[email protected]bafe6cd2012-05-23 23:09:50798 PendingWidgetViews pending_widget_views_;
799
[email protected]7fff43e2013-05-21 20:21:10800 typedef std::map<WebContentsImpl*, DestructionObserver*> DestructionObservers;
801 DestructionObservers destruction_observers_;
802
[email protected]996042972011-11-08 22:43:59803 // A list of observers notified when page state changes. Weak references.
804 // This MUST be listed above render_manager_ since at destruction time the
805 // latter might cause RenderViewHost's destructor to call us and we might use
806 // the observer list then.
[email protected]8ff00d72012-10-23 19:12:21807 ObserverList<WebContentsObserver> observers_;
[email protected]996042972011-11-08 22:43:59808
[email protected]14392a52012-05-02 20:28:44809 // The tab that opened this tab, if any. Will be set to null if the opener
810 // is closed.
811 WebContentsImpl* opener_;
812
[email protected]c73a2282013-04-29 21:10:41813#if defined(OS_WIN) && defined(USE_AURA)
814 gfx::NativeViewAccessible accessible_parent_;
815#endif
816
[email protected]0dd3a0ab2011-02-18 08:17:44817 // Helper classes ------------------------------------------------------------
818
[email protected]d9030b82013-07-19 08:26:06819 // Maps the RenderViewHost to its media_player_cookie and PowerSaveBlocker
820 // pairs. Key is the RenderViewHost, value is the map which maps player_cookie
821 // on to PowerSaveBlocker.
822 typedef std::map<RenderViewHost*, std::map<int64, PowerSaveBlocker*> >
823 PowerSaveBlockerMap;
824 PowerSaveBlockerMap power_save_blockers_;
825
[email protected]0dd3a0ab2011-02-18 08:17:44826 // Manages creation and swapping of render views.
827 RenderViewHostManager render_manager_;
828
[email protected]9b159a52013-10-03 17:24:55829 // The frame tree structure of the current page.
830 FrameTree frame_tree_;
831
[email protected]c7654a232013-06-12 21:04:44832#if defined(OS_ANDROID)
[email protected]483623eb2011-10-25 09:30:00833 // Manages injecting Java objects into all RenderViewHosts associated with
[email protected]b172aee2012-04-10 17:05:26834 // this WebContentsImpl.
[email protected]483623eb2011-10-25 09:30:00835 scoped_ptr<JavaBridgeDispatcherHostManager>
836 java_bridge_dispatcher_host_manager_;
[email protected]4cc1ab52013-01-21 19:24:34837#endif
[email protected]483623eb2011-10-25 09:30:00838
[email protected]c7dd2f62011-07-18 15:57:59839 // SavePackage, lazily created.
840 scoped_refptr<SavePackage> save_package_;
841
[email protected]0dd3a0ab2011-02-18 08:17:44842 // Data for loading state ----------------------------------------------------
843
844 // Indicates whether we're currently loading a resource.
845 bool is_loading_;
846
847 // Indicates if the tab is considered crashed.
848 base::TerminationStatus crashed_status_;
849 int crashed_error_code_;
850
[email protected]ca13a442012-04-17 14:00:12851 // Whether this WebContents is waiting for a first-response for the
[email protected]be1f56ab2011-12-22 06:55:31852 // main resource of the page. This controls whether the throbber state is
853 // "waiting" or "loading."
[email protected]0dd3a0ab2011-02-18 08:17:44854 bool waiting_for_response_;
855
[email protected]74ce1ad2011-12-16 21:51:46856 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
857 // to a given tab and SiteInstance, and must be valid for the lifetime of the
[email protected]b172aee2012-04-10 17:05:26858 // WebContentsImpl.
[email protected]74ce1ad2011-12-16 21:51:46859 std::map<int32, int32> max_page_ids_;
[email protected]0dd3a0ab2011-02-18 08:17:44860
861 // System time at which the current load was started.
862 base::TimeTicks current_load_start_;
863
864 // The current load state and the URL associated with it.
[email protected]9c235f042011-08-10 22:28:21865 net::LoadStateWithParam load_state_;
[email protected]0dd3a0ab2011-02-18 08:17:44866 string16 load_state_host_;
867 // Upload progress, for displaying in the status bar.
868 // Set to zero when there is no significant upload happening.
869 uint64 upload_size_;
870 uint64 upload_position_;
871
872 // Data for current page -----------------------------------------------------
873
[email protected]987fc3a2011-05-26 14:18:09874 // When a title cannot be taken from any entry, this title will be used.
875 string16 page_title_when_no_navigation_entry_;
876
[email protected]0dd3a0ab2011-02-18 08:17:44877 // When a navigation occurs, we record its contents MIME type. It can be
878 // used to check whether we can do something for some special contents.
879 std::string contents_mime_type_;
880
881 // Character encoding.
882 std::string encoding_;
883
[email protected]0dd3a0ab2011-02-18 08:17:44884 // True if this is a secure page which displayed insecure content.
885 bool displayed_insecure_content_;
886
[email protected]0dd3a0ab2011-02-18 08:17:44887 // Data for misc internal state ----------------------------------------------
888
[email protected]54597982013-02-06 01:59:55889 // When > 0, the WebContents is currently being captured (e.g., for
890 // screenshots or mirroring); and the underlying RenderWidgetHost should not
891 // be told it is hidden.
892 int capturer_count_;
893
894 // Tracks whether RWHV should be visible once capturer_count_ becomes zero.
895 bool should_normally_be_visible_;
[email protected]0dd3a0ab2011-02-18 08:17:44896
897 // See getter above.
898 bool is_being_destroyed_;
899
900 // Indicates whether we should notify about disconnection of this
[email protected]b172aee2012-04-10 17:05:26901 // WebContentsImpl. This is used to ensure disconnection notifications only
[email protected]0dd3a0ab2011-02-18 08:17:44902 // happen if a connection notification has happened and that they happen only
903 // once.
904 bool notify_disconnection_;
905
[email protected]71a88bb2013-02-01 22:05:15906 // Pointer to the JavaScript dialog manager, lazily assigned. Used because the
[email protected]b172aee2012-04-10 17:05:26907 // delegate of this WebContentsImpl is nulled before its destructor is called.
[email protected]71a88bb2013-02-01 22:05:15908 JavaScriptDialogManager* dialog_manager_;
[email protected]2e5b90c2011-08-16 21:11:55909
[email protected]0dd3a0ab2011-02-18 08:17:44910 // Set to true when there is an active "before unload" dialog. When true,
911 // we've forced the throbber to start in Navigate, and we need to remember to
912 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
913 bool is_showing_before_unload_dialog_;
914
[email protected]0dd3a0ab2011-02-18 08:17:44915 // Settings that get passed to the renderer process.
[email protected]8ff00d72012-10-23 19:12:21916 RendererPreferences renderer_preferences_;
[email protected]0dd3a0ab2011-02-18 08:17:44917
[email protected]0dd3a0ab2011-02-18 08:17:44918 // The time that this tab was last selected.
919 base::TimeTicks last_selected_time_;
920
[email protected]0dd3a0ab2011-02-18 08:17:44921 // See description above setter.
922 bool closed_by_user_gesture_;
923
924 // Minimum/maximum zoom percent.
925 int minimum_zoom_percent_;
926 int maximum_zoom_percent_;
927 // If true, the default zoom limits have been overriden for this tab, in which
928 // case we don't want saved settings to apply to it and we don't want to
929 // remember it.
930 bool temporary_zoom_settings_;
931
[email protected]bcd2815602012-01-14 18:17:23932 // The intrinsic size of the page.
933 gfx::Size preferred_size_;
934
[email protected]583418cc2013-01-17 14:01:10935#if defined(OS_ANDROID)
936 // Date time chooser opened by this tab.
937 // Only used in Android since all other platforms use a multi field UI.
938 scoped_ptr<DateTimeChooserAndroid> date_time_chooser_;
939#endif
940
[email protected]da8543762012-03-20 08:52:20941 // Color chooser that was opened by this tab.
[email protected]cb805452013-05-22 15:16:21942 scoped_ptr<ColorChooser> color_chooser_;
943
944 // A unique identifier for the current color chooser. Identifiers are unique
945 // across a renderer process. This avoids race conditions in synchronizing
946 // the browser and renderer processes. For example, if a renderer closes one
947 // chooser and opens another, and simultaneously the user picks a color in the
948 // first chooser, the IDs can be used to drop the "chose a color" message
949 // rather than erroneously tell the renderer that the user picked a color in
950 // the second chooser.
951 int color_chooser_identifier_;
[email protected]da8543762012-03-20 08:52:20952
[email protected]7a846df2012-09-20 19:17:39953 // Manages the embedder state for browser plugins, if this WebContents is an
954 // embedder; NULL otherwise.
[email protected]8ff00d72012-10-23 19:12:21955 scoped_ptr<BrowserPluginEmbedder> browser_plugin_embedder_;
[email protected]7a846df2012-09-20 19:17:39956 // Manages the guest state for browser plugin, if this WebContents is a guest;
957 // NULL otherwise.
[email protected]8ff00d72012-10-23 19:12:21958 scoped_ptr<BrowserPluginGuest> browser_plugin_guest_;
[email protected]7a846df2012-09-20 19:17:39959
[email protected]f53a9f872012-05-24 02:07:06960 // This must be at the end, or else we might get notifications and use other
961 // member variables that are gone.
[email protected]8ff00d72012-10-23 19:12:21962 NotificationRegistrar registrar_;
[email protected]f53a9f872012-05-24 02:07:06963
[email protected]7bb761892012-07-20 09:32:47964 // Used during IPC message dispatching so that the handlers can get a pointer
965 // to the RVH through which the message was received.
[email protected]8ff00d72012-10-23 19:12:21966 RenderViewHost* message_source_;
[email protected]7bb761892012-07-20 09:32:47967
[email protected]b24b68a2012-09-24 21:57:26968 // All live RenderWidgetHostImpls that are created by this object and may
969 // outlive it.
[email protected]8ff00d72012-10-23 19:12:21970 std::set<RenderWidgetHostImpl*> created_widgets_;
[email protected]b24b68a2012-09-24 21:57:26971
[email protected]44470a22013-01-24 01:21:54972 // Routing id of the shown fullscreen widget or MSG_ROUTING_NONE otherwise.
973 int fullscreen_widget_routing_id_;
974
[email protected]41225fe2013-03-29 05:32:02975 // Maps the ids of pending image downloads to their callbacks
976 typedef std::map<int, ImageDownloadCallback> ImageDownloadMap;
977 ImageDownloadMap image_download_map_;
[email protected]795c28972012-12-06 06:13:39978
[email protected]b172aee2012-04-10 17:05:26979 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
[email protected]0dd3a0ab2011-02-18 08:17:44980};
981
[email protected]8ff00d72012-10-23 19:12:21982} // namespace content
983
[email protected]93ddb3c2012-04-11 21:44:29984#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_