blob: 876eb8451369a2951e829d64ba0d3ea91a36be30 [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>
9#include <string>
[email protected]0dd3a0ab2011-02-18 08:17:4410
[email protected]01d65172011-12-25 04:39:3011#include "base/compiler_specific.h"
[email protected]0dd3a0ab2011-02-18 08:17:4412#include "base/gtest_prod_util.h"
[email protected]3b63f8f42011-03-28 01:54:1513#include "base/memory/scoped_ptr.h"
[email protected]6eac57a2011-07-12 21:15:0914#include "base/observer_list.h"
[email protected]cc510d7e2012-08-08 04:40:1015#include "content/browser/browser_plugin/old/old_browser_plugin_host.h"
[email protected]07161902011-11-11 09:57:4216#include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager.h"
[email protected]2e3bf992012-05-24 17:36:2417#include "content/browser/renderer_host/render_view_host_delegate.h"
[email protected]4ca76c02012-05-16 16:19:0518#include "content/browser/renderer_host/render_widget_host_delegate.h"
[email protected]f9e4dae2012-04-10 21:26:3719#include "content/browser/web_contents/navigation_controller_impl.h"
[email protected]0c4e92e62012-04-11 15:19:0020#include "content/browser/web_contents/render_view_host_manager.h"
[email protected]8d128d62011-09-13 22:11:5721#include "content/common/content_export.h"
[email protected]14392a52012-05-02 20:28:4422#include "content/public/browser/notification_observer.h"
23#include "content/public/browser/notification_registrar.h"
[email protected]58f5d562011-12-20 17:13:0324#include "content/public/browser/web_contents.h"
[email protected]daf82f82011-10-31 22:35:3125#include "content/public/common/renderer_preferences.h"
[email protected]0dd3a0ab2011-02-18 08:17:4426#include "net/base/load_states.h"
[email protected]59363fc92012-09-05 03:46:3127#include "ui/gfx/rect_f.h"
[email protected]bcd2815602012-01-14 18:17:2328#include "ui/gfx/size.h"
[email protected]70435962011-08-02 20:13:2829#include "webkit/glue/resource_type.h"
[email protected]0dd3a0ab2011-02-18 08:17:4430
31#if defined(OS_WIN)
32#include "base/win/scoped_handle.h"
33#endif
34
[email protected]cadaec52012-02-08 21:53:1335class InterstitialPageImpl;
[email protected]a53209b2012-01-20 16:48:1636class SavePackage;
[email protected]adbfb8df2012-02-24 01:19:4337class SessionStorageNamespaceImpl;
[email protected]f66df822012-05-18 16:52:1738class WebContentsImpl;
[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]da8543762012-03-20 08:52:2042class ColorChooser;
[email protected]e582fdd2011-12-20 16:48:1743class DownloadItem;
[email protected]51da7e32012-01-30 19:24:5244class JavaScriptDialogCreator;
[email protected]eaabba22012-03-07 15:02:1145class RenderViewHost;
[email protected]5a3bdf52012-05-24 15:12:5746class RenderViewHostDelegateView;
[email protected]eaabba22012-03-07 15:02:1147class RenderViewHostImpl;
[email protected]09d31d52012-03-11 22:30:2748class SiteInstance;
[email protected]80e776ae2012-03-23 16:17:2049class TestWebContents;
[email protected]674bc592011-12-20 23:00:4250class WebContentsDelegate;
[email protected]51da7e32012-01-30 19:24:5251class WebContentsObserver;
[email protected]8643e6d2012-01-18 20:26:1052class WebContentsView;
[email protected]f66df822012-05-18 16:52:1753class WebContentsViewDelegate;
[email protected]09d31d52012-03-11 22:30:2754struct LoadNotificationDetails;
[email protected]f66df822012-05-18 16:52:1755
56// Factory function for the implementations that content knows about. Takes
57// ownership of |delegate|.
[email protected]5a3bdf52012-05-24 15:12:5758WebContentsView* CreateWebContentsView(
59 WebContentsImpl* web_contents,
60 WebContentsViewDelegate* delegate,
61 RenderViewHostDelegateView** render_view_host_delegate_view);
[email protected]97714c82012-06-06 10:15:1362
63} // namespace content
[email protected]e582fdd2011-12-20 16:48:1764
[email protected]daf82f82011-10-31 22:35:3165namespace webkit_glue {
66struct WebIntentData;
[email protected]3a3b75a2012-06-01 08:38:3667struct WebIntentServiceData;
[email protected]daf82f82011-10-31 22:35:3168}
[email protected]0dd3a0ab2011-02-18 08:17:4469
[email protected]b172aee2012-04-10 17:05:2670class CONTENT_EXPORT WebContentsImpl
[email protected]01d65172011-12-25 04:39:3071 : public NON_EXPORTED_BASE(content::WebContents),
[email protected]b0b67cf2012-01-18 21:59:5772 public content::RenderViewHostDelegate,
[email protected]4ca76c02012-05-16 16:19:0573 public content::RenderWidgetHostDelegate,
[email protected]14392a52012-05-02 20:28:4474 public RenderViewHostManager::Delegate,
75 public content::NotificationObserver {
[email protected]0dd3a0ab2011-02-18 08:17:4476 public:
[email protected]b172aee2012-04-10 17:05:2677 virtual ~WebContentsImpl();
[email protected]0dd3a0ab2011-02-18 08:17:4478
[email protected]d1198fd2012-08-13 22:50:1979 static WebContentsImpl* Create(
80 content::BrowserContext* browser_context,
81 content::SiteInstance* site_instance,
82 int routing_id,
83 const WebContentsImpl* base_web_contents);
84
85 static WebContentsImpl* CreateWithOpener(
86 content::BrowserContext* browser_context,
87 content::SiteInstance* site_instance,
88 int routing_id,
89 const WebContentsImpl* base_web_contents,
90 WebContentsImpl* opener);
91
[email protected]64d69de42012-02-06 00:19:5492 // Returns the content specific prefs for the given RVH.
[email protected]6717bf272012-05-11 23:31:2593 static webkit_glue::WebPreferences GetWebkitPrefs(
[email protected]eaabba22012-03-07 15:02:1194 content::RenderViewHost* rvh, const GURL& url);
[email protected]64d69de42012-02-06 00:19:5495
[email protected]d1198fd2012-08-13 22:50:1996 // Complex initialization here. Specifically needed to avoid having
97 // members call back into our virtual functions in the constructor.
98 virtual void Init(content::BrowserContext* browser_context,
99 content::SiteInstance* site_instance,
100 int routing_id,
101 const content::WebContents* base_web_contents);
102
[email protected]c7dd2f62011-07-18 15:57:59103 // Returns the SavePackage which manages the page saving job. May be NULL.
104 SavePackage* save_package() const { return save_package_.get(); }
105
[email protected]b172aee2012-04-10 17:05:26106 // Updates the max page ID for the current SiteInstance in this
107 // WebContentsImpl to be at least |page_id|.
[email protected]0dd3a0ab2011-02-18 08:17:44108 void UpdateMaxPageID(int32 page_id);
109
[email protected]b172aee2012-04-10 17:05:26110 // Updates the max page ID for the given SiteInstance in this WebContentsImpl
[email protected]74ce1ad2011-12-16 21:51:46111 // to be at least |page_id|.
[email protected]b6583592012-01-25 19:52:33112 void UpdateMaxPageIDForSiteInstance(content::SiteInstance* site_instance,
[email protected]74ce1ad2011-12-16 21:51:46113 int32 page_id);
114
[email protected]91854cd2012-01-10 19:43:57115 // Copy the current map of SiteInstance ID to max page ID from another tab.
116 // This is necessary when this tab adopts the NavigationEntries from
[email protected]b172aee2012-04-10 17:05:26117 // |web_contents|.
118 void CopyMaxPageIDsFrom(WebContentsImpl* web_contents);
[email protected]91854cd2012-01-10 19:43:57119
[email protected]b172aee2012-04-10 17:05:26120 // Called by the NavigationController to cause the WebContentsImpl to navigate
121 // to the current pending entry. The NavigationController should be called
122 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
[email protected]9a7e68c2011-05-26 17:35:50123 // The callbacks can be inside of this function, or at some future time.
[email protected]0dd3a0ab2011-02-18 08:17:44124 //
125 // The entry has a PageID of -1 if newly created (corresponding to navigation
126 // to a new URL).
127 //
128 // If this method returns false, then the navigation is discarded (equivalent
129 // to calling DiscardPendingEntry on the NavigationController).
[email protected]0bfbf882011-12-22 18:19:27130 bool NavigateToPendingEntry(
[email protected]71fde352011-12-29 03:29:56131 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44132
[email protected]ba45bfd2012-05-22 21:51:44133 // Called by InterstitialPageImpl when it creates a RenderViewHost.
134 void RenderViewForInterstitialPageCreated(
135 content::RenderViewHost* render_view_host);
136
[email protected]0dd3a0ab2011-02-18 08:17:44137 // Sets the passed passed interstitial as the currently showing interstitial.
138 // |interstitial_page| should be non NULL (use the remove_interstitial_page
139 // method to unset the interstitial) and no interstitial page should be set
140 // when there is already a non NULL interstitial page set.
[email protected]cadaec52012-02-08 21:53:13141 void set_interstitial_page(InterstitialPageImpl* interstitial_page) {
[email protected]0dd3a0ab2011-02-18 08:17:44142 render_manager_.set_interstitial_page(interstitial_page);
143 }
144
145 // Unsets the currently showing interstitial.
146 void remove_interstitial_page() {
147 render_manager_.remove_interstitial_page();
148 }
149
[email protected]01ec4ec2012-01-18 04:13:47150 void set_opener_web_ui_type(content::WebUI::TypeID opener_web_ui_type) {
[email protected]0dd3a0ab2011-02-18 08:17:44151 opener_web_ui_type_ = opener_web_ui_type;
152 }
153
[email protected]276b37a22011-11-08 20:45:46154 JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const {
155 return java_bridge_dispatcher_host_manager_.get();
156 }
157
[email protected]dd26779c2012-08-08 01:50:28158 content::old::BrowserPluginHost* old_browser_plugin_host() const {
159 return old_browser_plugin_host_.get();
[email protected]172cf712012-05-23 15:07:39160 }
161
[email protected]765187182012-01-11 23:59:28162 // Expose the render manager for testing.
163 RenderViewHostManager* GetRenderManagerForTesting();
164
[email protected]58f5d562011-12-20 17:13:03165 // content::WebContents ------------------------------------------------------
[email protected]674bc592011-12-20 23:00:42166 virtual content::WebContentsDelegate* GetDelegate() OVERRIDE;
167 virtual void SetDelegate(content::WebContentsDelegate* delegate) OVERRIDE;
[email protected]d1198fd2012-08-13 22:50:19168 virtual NavigationControllerImpl& GetController() OVERRIDE;
169 virtual const NavigationControllerImpl& GetController() const OVERRIDE;
[email protected]627e0512011-12-21 22:55:30170 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
[email protected]f5fa20e2011-12-21 22:35:56171 virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11172 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE;
[email protected]6b618e62012-08-16 12:59:18173 virtual int GetRoutingID() const OVERRIDE;
[email protected]5626b0892012-02-20 14:46:58174 virtual content::RenderWidgetHostView*
175 GetRenderWidgetHostView() const OVERRIDE;
[email protected]8643e6d2012-01-18 20:26:10176 virtual content::WebContentsView* GetView() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47177 virtual content::WebUI* CreateWebUI(const GURL& url) OVERRIDE;
178 virtual content::WebUI* GetWebUI() const OVERRIDE;
179 virtual content::WebUI* GetCommittedWebUI() const OVERRIDE;
[email protected]86ef6a392012-05-11 22:03:11180 virtual void SetUserAgentOverride(const std::string& override) OVERRIDE;
181 virtual const std::string& GetUserAgentOverride() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31182 virtual const string16& GetTitle() const OVERRIDE;
183 virtual int32 GetMaxPageID() OVERRIDE;
184 virtual int32 GetMaxPageIDForSiteInstance(
[email protected]b6583592012-01-25 19:52:33185 content::SiteInstance* site_instance) OVERRIDE;
186 virtual content::SiteInstance* GetSiteInstance() const OVERRIDE;
187 virtual content::SiteInstance* GetPendingSiteInstance() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31188 virtual bool IsLoading() const OVERRIDE;
189 virtual bool IsWaitingForResponse() const OVERRIDE;
190 virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE;
191 virtual const string16& GetLoadStateHost() const OVERRIDE;
192 virtual uint64 GetUploadSize() const OVERRIDE;
193 virtual uint64 GetUploadPosition() const OVERRIDE;
194 virtual const std::string& GetEncoding() const OVERRIDE;
195 virtual bool DisplayedInsecureContent() const OVERRIDE;
196 virtual void SetCapturingContents(bool cap) OVERRIDE;
197 virtual bool IsCrashed() const OVERRIDE;
198 virtual void SetIsCrashed(base::TerminationStatus status,
199 int error_code) OVERRIDE;
200 virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE;
201 virtual bool IsBeingDestroyed() const OVERRIDE;
202 virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31203 virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE;
[email protected]9e2e4632012-07-27 16:38:41204 virtual void WasShown() OVERRIDE;
[email protected]3e324142012-06-25 18:26:33205 virtual void WasHidden() OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31206 virtual bool NeedToFireBeforeUnload() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27207 virtual void Stop() OVERRIDE;
[email protected]d9083482012-01-06 00:38:46208 virtual content::WebContents* Clone() OVERRIDE;
[email protected]2a6bc3e2011-12-28 23:51:33209 virtual void AddNewContents(content::WebContents* new_contents,
[email protected]0bfbf882011-12-22 18:19:27210 WindowOpenDisposition disposition,
211 const gfx::Rect& initial_pos,
212 bool user_gesture) OVERRIDE;
213 virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
214 virtual gfx::NativeView GetNativeView() const OVERRIDE;
215 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE;
216 virtual void Focus() OVERRIDE;
217 virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE;
218 virtual bool ShowingInterstitialPage() const OVERRIDE;
[email protected]cadaec52012-02-08 21:53:13219 virtual content::InterstitialPage* GetInterstitialPage() const OVERRIDE;
[email protected]a53209b2012-01-20 16:48:16220 virtual bool IsSavable() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27221 virtual void OnSavePage() OVERRIDE;
222 virtual bool SavePage(const FilePath& main_file,
223 const FilePath& dir_path,
[email protected]a53209b2012-01-20 16:48:16224 content::SavePageType save_type) OVERRIDE;
[email protected]aa4f3972012-03-01 18:12:12225 virtual void GenerateMHTML(
226 const FilePath& file,
227 const base::Callback<void(const FilePath&, int64)>& callback) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27228 virtual bool IsActiveEntry(int32 page_id) OVERRIDE;
229
230 virtual const std::string& GetContentsMimeType() const OVERRIDE;
231 virtual bool WillNotifyDisconnection() const OVERRIDE;
232 virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE;
233 virtual void ResetOverrideEncoding() OVERRIDE;
234 virtual content::RendererPreferences* GetMutableRendererPrefs() OVERRIDE;
235 virtual void SetNewTabStartTime(const base::TimeTicks& time) OVERRIDE;
236 virtual base::TimeTicks GetNewTabStartTime() const OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47237 virtual void Close() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27238 virtual void OnCloseStarted() OVERRIDE;
239 virtual bool ShouldAcceptDragAndDrop() const OVERRIDE;
240 virtual void SystemDragEnded() OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47241 virtual void UserGestureDone() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27242 virtual void SetClosedByUserGesture(bool value) OVERRIDE;
243 virtual bool GetClosedByUserGesture() const OVERRIDE;
244 virtual double GetZoomLevel() const OVERRIDE;
245 virtual int GetZoomPercent(bool* enable_increment,
246 bool* enable_decrement) OVERRIDE;
247 virtual void ViewSource() OVERRIDE;
248 virtual void ViewFrameSource(const GURL& url,
249 const std::string& content_state) OVERRIDE;
250 virtual int GetMinimumZoomPercent() const OVERRIDE;
251 virtual int GetMaximumZoomPercent() const OVERRIDE;
[email protected]bcd2815602012-01-14 18:17:23252 virtual gfx::Size GetPreferredSize() const OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27253 virtual int GetContentRestrictions() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47254 virtual content::WebUI::TypeID GetWebUITypeForCurrentState() OVERRIDE;
255 virtual content::WebUI* GetWebUIForCurrentState() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27256 virtual bool GotResponseToLockMouseRequest(bool allowed) OVERRIDE;
[email protected]a0358d72012-03-09 14:06:50257 virtual bool HasOpener() const OVERRIDE;
[email protected]da8543762012-03-20 08:52:20258 virtual void DidChooseColorInColorChooser(int color_chooser_id,
[email protected]55578b0a2012-04-18 14:31:32259 SkColor color) OVERRIDE;
[email protected]da8543762012-03-20 08:52:20260 virtual void DidEndColorChooser(int color_chooser_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27261
262 // Implementation of PageNavigator.
[email protected]e5d549d2011-12-28 01:29:20263 virtual content::WebContents* OpenURL(
264 const content::OpenURLParams& params) OVERRIDE;
[email protected]151a63d2011-12-20 22:32:52265
[email protected]6b618e62012-08-16 12:59:18266 // Implementation of IPC::Sender.
267 virtual bool Send(IPC::Message* message) OVERRIDE;
268
[email protected]952a68e2011-11-17 00:36:10269 // RenderViewHostDelegate ----------------------------------------------------
270
[email protected]5a3bdf52012-05-24 15:12:57271 virtual content::RenderViewHostDelegateView* GetDelegateView() OVERRIDE;
[email protected]b0b67cf2012-01-18 21:59:57272 virtual content::RenderViewHostDelegate::RendererManagement*
[email protected]952a68e2011-11-17 00:36:10273 GetRendererManagementDelegate() OVERRIDE;
[email protected]7bb761892012-07-20 09:32:47274 virtual bool OnMessageReceived(content::RenderViewHost* render_view_host,
275 const IPC::Message& message) OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31276 virtual const GURL& GetURL() const OVERRIDE;
[email protected]d1198fd2012-08-13 22:50:19277 virtual content::WebContents* GetAsWebContents() OVERRIDE;
[email protected]b7a756d42012-01-23 18:08:17278 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11279 virtual void RenderViewCreated(
280 content::RenderViewHost* render_view_host) OVERRIDE;
281 virtual void RenderViewReady(
282 content::RenderViewHost* render_view_host) OVERRIDE;
283 virtual void RenderViewGone(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10284 base::TerminationStatus status,
285 int error_code) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11286 virtual void RenderViewDeleted(
287 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57288 virtual void DidStartProvisionalLoadForFrame(
289 content::RenderViewHost* render_view_host,
290 int64 frame_id,
291 bool main_frame,
292 const GURL& opener_url,
293 const GURL& url) OVERRIDE;
[email protected]400992b2012-06-14 00:03:54294 virtual void DidRedirectProvisionalLoad(
295 content::RenderViewHost* render_view_host,
296 int32 page_id,
297 const GURL& opener_url,
298 const GURL& source_url,
299 const GURL& target_url) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57300 virtual void DidFailProvisionalLoadWithError(
301 content::RenderViewHost* render_view_host,
302 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params)
303 OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10304 virtual void DidNavigate(
[email protected]eaabba22012-03-07 15:02:11305 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10306 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11307 virtual void UpdateState(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10308 int32 page_id,
309 const std::string& state) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11310 virtual void UpdateTitle(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10311 int32 page_id,
312 const string16& title,
313 base::i18n::TextDirection title_direction) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11314 virtual void UpdateEncoding(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10315 const std::string& encoding) OVERRIDE;
316 virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11317 virtual void Close(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10318 virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11319 virtual void SwappedOut(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]89793072012-07-23 22:25:29320 virtual void DidStartLoading(
321 content::RenderViewHost* render_view_host) OVERRIDE;
322 virtual void DidStopLoading(
323 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10324 virtual void DidCancelLoading() OVERRIDE;
325 virtual void DidChangeLoadProgress(double progress) OVERRIDE;
[email protected]0720b532012-08-28 19:23:37326 virtual void DidUpdateFrameTree(content::RenderViewHost* rvh) OVERRIDE;
[email protected]87717d0e2012-04-26 02:58:43327 virtual void DocumentAvailableInMainFrame(
328 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10329 virtual void DocumentOnLoadCompletedInMainFrame(
[email protected]eaabba22012-03-07 15:02:11330 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10331 int32 page_id) OVERRIDE;
[email protected]196159d2012-05-04 17:26:54332 virtual void RequestOpenURL(content::RenderViewHost* rvh,
333 const GURL& url,
[email protected]445e1042011-12-03 21:03:15334 const content::Referrer& referrer,
[email protected]952a68e2011-11-17 00:36:10335 WindowOpenDisposition disposition,
336 int64 source_frame_id) OVERRIDE;
[email protected]4ad5d77d2011-12-03 02:00:48337 virtual void RequestTransferURL(
338 const GURL& url,
[email protected]bce1f1c2011-12-05 15:11:58339 const content::Referrer& referrer,
[email protected]4ad5d77d2011-12-03 02:00:48340 WindowOpenDisposition disposition,
341 int64 source_frame_id,
[email protected]e5d549d2011-12-28 01:29:20342 const content::GlobalRequestID& transferred_global_request_id) OVERRIDE;
[email protected]e1c3a552012-05-04 20:51:32343 virtual void RouteCloseEvent(content::RenderViewHost* rvh) OVERRIDE;
[email protected]f546640b2012-05-15 00:03:49344 virtual void RouteMessageEvent(
345 content::RenderViewHost* rvh,
346 const ViewMsg_PostMessage_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11347 virtual void RunJavaScriptMessage(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10348 const string16& message,
349 const string16& default_prompt,
350 const GURL& frame_url,
[email protected]be2510c02012-05-28 14:52:14351 content::JavaScriptMessageType type,
[email protected]952a68e2011-11-17 00:36:10352 IPC::Message* reply_msg,
353 bool* did_suppress_message) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11354 virtual void RunBeforeUnloadConfirm(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10355 const string16& message,
[email protected]3b3301f62012-02-29 04:32:32356 bool is_reload,
[email protected]952a68e2011-11-17 00:36:10357 IPC::Message* reply_msg) OVERRIDE;
[email protected]a796f202012-05-30 14:14:25358 virtual bool AddMessageToConsole(int32 level,
359 const string16& message,
360 int32 line_no,
361 const string16& source_id) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10362 virtual content::RendererPreferences GetRendererPrefs(
363 content::BrowserContext* browser_context) const OVERRIDE;
[email protected]6717bf272012-05-11 23:31:25364 virtual webkit_glue::WebPreferences GetWebkitPrefs() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10365 virtual void OnUserGesture() OVERRIDE;
366 virtual void OnIgnoredUIEvent() OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11367 virtual void RendererUnresponsive(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10368 bool is_during_unload) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11369 virtual void RendererResponsive(
370 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10371 virtual void LoadStateChanged(const GURL& url,
372 const net::LoadStateWithParam& load_state,
373 uint64 upload_position,
374 uint64 upload_size) OVERRIDE;
375 virtual void WorkerCrashed() OVERRIDE;
376 virtual void Activate() OVERRIDE;
377 virtual void Deactivate() OVERRIDE;
378 virtual void LostCapture() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10379 virtual void HandleMouseDown() OVERRIDE;
380 virtual void HandleMouseUp() OVERRIDE;
[email protected]590a634e2012-07-19 16:38:23381 virtual void HandlePointerActivate() OVERRIDE;
382 virtual void HandleGestureBegin() OVERRIDE;
383 virtual void HandleGestureEnd() OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38384 virtual void RunFileChooser(
[email protected]eaabba22012-03-07 15:02:11385 content::RenderViewHost* render_view_host,
[email protected]8caadeb2011-11-22 02:45:23386 const content::FileChooserParams& params) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10387 virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
388 virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
389 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
[email protected]61e2b3cc2012-03-02 16:13:34390 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
[email protected]a9c81f02012-06-01 00:15:44391 virtual void RequestToLockMouse(bool user_gesture,
392 bool last_unlocked_by_target) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10393 virtual void LostMouseLock() OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50394 virtual void CreateNewWindow(
395 int route_id,
[email protected]97714c82012-06-06 10:15:13396 const ViewHostMsg_CreateWindow_Params& params,
397 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50398 virtual void CreateNewWidget(int route_id,
399 WebKit::WebPopupType popup_type) OVERRIDE;
400 virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
401 virtual void ShowCreatedWindow(int route_id,
402 WindowOpenDisposition disposition,
403 const gfx::Rect& initial_pos,
404 bool user_gesture) OVERRIDE;
405 virtual void ShowCreatedWidget(int route_id,
406 const gfx::Rect& initial_pos) OVERRIDE;
407 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
408 virtual void ShowContextMenu(
409 const content::ContextMenuParams& params) OVERRIDE;
[email protected]f13b4202012-06-12 23:53:23410 virtual void RequestMediaAccessPermission(
411 const content::MediaStreamRequest* request,
412 const content::MediaResponseCallback& callback) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10413
[email protected]16383382012-09-05 23:57:26414#if defined(OS_ANDROID)
415 virtual void AttachLayer(WebKit::WebLayer* layer) OVERRIDE;
416 virtual void RemoveLayer(WebKit::WebLayer* layer) OVERRIDE;
417#endif
418
[email protected]4ca76c02012-05-16 16:19:05419 // RenderWidgetHostDelegate --------------------------------------------------
420
[email protected]b87ee522012-05-18 15:16:54421 virtual bool PreHandleKeyboardEvent(
422 const content::NativeWebKeyboardEvent& event,
423 bool* is_keyboard_shortcut) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05424 virtual void HandleKeyboardEvent(
[email protected]b87ee522012-05-18 15:16:54425 const content::NativeWebKeyboardEvent& event) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05426
[email protected]0bfbf882011-12-22 18:19:27427 // RenderViewHostManager::Delegate -------------------------------------------
428
429 virtual bool CreateRenderViewForRenderManager(
[email protected]14392a52012-05-02 20:28:44430 content::RenderViewHost* render_view_host, int opener_route_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27431 virtual void BeforeUnloadFiredFromRenderManager(
432 bool proceed,
433 bool* proceed_to_fire_unload) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27434 virtual void RenderViewGoneFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11435 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27436 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
437 virtual void NotifySwappedFromRenderManager() OVERRIDE;
[email protected]14392a52012-05-02 20:28:44438 virtual int CreateOpenerRenderViewsForRenderManager(
439 content::SiteInstance* instance) OVERRIDE;
[email protected]d202a7c2012-01-04 07:53:47440 virtual NavigationControllerImpl& GetControllerForRenderManager() OVERRIDE;
[email protected]d2353452012-01-19 19:53:56441 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
[email protected]ad23a092011-12-28 07:02:04442 virtual content::NavigationEntry*
[email protected]0bfbf882011-12-22 18:19:27443 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
444 virtual bool FocusLocationBarByDefault() OVERRIDE;
445 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11446 virtual void CreateViewAndSetSizeForRVH(
447 content::RenderViewHost* rvh) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27448
[email protected]14392a52012-05-02 20:28:44449 // content::NotificationObserver ---------------------------------------------
450
451 virtual void Observe(int type,
452 const content::NotificationSource& source,
453 const content::NotificationDetails& details) OVERRIDE;
454
[email protected]553602e12011-04-05 17:01:18455
[email protected]0dd3a0ab2011-02-18 08:17:44456 private:
[email protected]d202a7c2012-01-04 07:53:47457 friend class NavigationControllerImpl;
[email protected]d1198fd2012-08-13 22:50:19458 friend class content::WebContentsObserver;
459 friend class content::WebContents; // To implement factory methods.
[email protected]0dd3a0ab2011-02-18 08:17:44460
[email protected]2db9bd72012-04-13 20:20:56461 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
462 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
463 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
464 CrossSiteCantPreemptAfterUnload);
[email protected]0dd3a0ab2011-02-18 08:17:44465 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
466 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
467 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
468
[email protected]cadaec52012-02-08 21:53:13469 // So InterstitialPageImpl can access SetIsLoading.
470 friend class InterstitialPageImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44471
[email protected]80e776ae2012-03-23 16:17:20472 // TODO(brettw) TestWebContents shouldn't exist!
473 friend class content::TestWebContents;
[email protected]0dd3a0ab2011-02-18 08:17:44474
[email protected]d1198fd2012-08-13 22:50:19475 // See WebContents::Create for a description of these parameters.
476 WebContentsImpl(content::BrowserContext* browser_context,
477 WebContentsImpl* opener);
478
479 // Add and remove observers for page navigation notifications. Adding or
480 // removing multiple times has no effect. The order in which notifications
481 // are sent to observers is undefined. Clients must be sure to remove the
482 // observer before they go away.
483 void AddObserver(content::WebContentsObserver* observer);
484 void RemoveObserver(content::WebContentsObserver* observer);
485
[email protected]14392a52012-05-02 20:28:44486 // Clears this tab's opener if it has been closed.
487 void OnWebContentsDestroyed(content::WebContents* web_contents);
488
[email protected]51da7e32012-01-30 19:24:52489 // Callback function when showing JS dialogs.
[email protected]eaabba22012-03-07 15:02:11490 void OnDialogClosed(content::RenderViewHost* rvh,
[email protected]51da7e32012-01-30 19:24:52491 IPC::Message* reply_msg,
492 bool success,
493 const string16& user_input);
494
[email protected]d8415ad92012-08-23 14:40:50495 // Callback function when requesting permission to access the PPAPI broker.
496 // |result| is true if permission was granted.
497 void OnPpapiBrokerPermissionResult(int request_id, bool result);
498
[email protected]d0759f492012-04-19 22:50:50499 // IPC message handlers.
[email protected]3a3b75a2012-06-01 08:38:36500 void OnRegisterIntentService(const webkit_glue::WebIntentServiceData& data,
501 bool user_gesture);
[email protected]678105012011-12-09 04:01:21502 void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
[email protected]63c239322011-10-31 23:56:30503 int intent_id);
[email protected]0dd3a0ab2011-02-18 08:17:44504 void OnDidLoadResourceFromMemoryCache(const GURL& url,
[email protected]70435962011-08-02 20:13:28505 const std::string& security_info,
506 const std::string& http_request,
[email protected]6d6cfb3a2012-05-23 22:53:18507 const std::string& mime_type,
[email protected]70435962011-08-02 20:13:28508 ResourceType::Type resource_type);
[email protected]0dd3a0ab2011-02-18 08:17:44509 void OnDidDisplayInsecureContent();
510 void OnDidRunInsecureContent(const std::string& security_origin,
511 const GURL& target_url);
512 void OnDocumentLoadedInFrame(int64 frame_id);
[email protected]1a55c5be2011-11-29 11:36:31513 void OnDidFinishLoad(int64 frame_id,
514 const GURL& validated_url,
515 bool is_main_frame);
516 void OnDidFailLoadWithError(int64 frame_id,
517 const GURL& validated_url,
518 bool is_main_frame,
519 int error_code,
520 const string16& error_description);
[email protected]0dd3a0ab2011-02-18 08:17:44521 void OnUpdateContentRestrictions(int restrictions);
[email protected]0dd3a0ab2011-02-18 08:17:44522 void OnGoToEntryAtOffset(int offset);
[email protected]216813952011-05-19 22:21:26523 void OnUpdateZoomLimits(int minimum_percent,
524 int maximum_percent,
525 bool remember);
[email protected]20b433a2012-05-15 21:23:46526 void OnSaveURL(const GURL& url, const content::Referrer& referrer);
[email protected]3a29a6e2011-08-24 18:26:21527 void OnEnumerateDirectory(int request_id, const FilePath& path);
[email protected]7d189022011-08-25 22:54:20528 void OnJSOutOfMemory();
[email protected]b7a756d42012-01-23 18:08:17529
[email protected]7d189022011-08-25 22:54:20530 void OnRegisterProtocolHandler(const std::string& protocol,
531 const GURL& url,
[email protected]3a3b75a2012-06-01 08:38:36532 const string16& title,
533 bool user_gesture);
[email protected]59363fc92012-09-05 03:46:31534 void OnFindReply(int request_id,
535 int number_of_matches,
536 const gfx::Rect& selection_rect,
537 int active_match_ordinal,
[email protected]b888919c2011-09-02 00:32:16538 bool final_update);
[email protected]59363fc92012-09-05 03:46:31539#if defined(OS_ANDROID)
540 void OnFindMatchRectsReply(int version,
541 const std::vector<gfx::RectF>& rects,
542 const gfx::RectF& active_rect);
543#endif
[email protected]d952a052011-09-06 18:42:45544 void OnCrashedPlugin(const FilePath& plugin_path);
[email protected]7fc4bbb2011-09-08 21:23:10545 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
[email protected]55578b0a2012-04-18 14:31:32546 void OnOpenColorChooser(int color_chooser_id, SkColor color);
[email protected]da8543762012-03-20 08:52:20547 void OnEndColorChooser(int color_chooser_id);
[email protected]55578b0a2012-04-18 14:31:32548 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
[email protected]8be45842012-04-13 19:49:29549 void OnPepperPluginHung(int plugin_child_id,
550 const FilePath& path,
551 bool is_hung);
[email protected]d0759f492012-04-19 22:50:50552 void OnWebUISend(const GURL& source_url,
553 const std::string& name,
554 const base::ListValue& args);
[email protected]d8415ad92012-08-23 14:40:50555 void OnRequestPpapiBrokerPermission(int request_id,
556 const GURL& url,
557 const FilePath& plugin_path);
[email protected]0dd3a0ab2011-02-18 08:17:44558
559 // Changes the IsLoading state and notifies delegate as needed
560 // |details| is used to provide details on the load that just finished
561 // (but can be null if not applicable). Can be overridden.
562 void SetIsLoading(bool is_loading,
[email protected]09d31d52012-03-11 22:30:27563 content::LoadNotificationDetails* details);
[email protected]0dd3a0ab2011-02-18 08:17:44564
[email protected]0dd3a0ab2011-02-18 08:17:44565 // Called by derived classes to indicate that we're no longer waiting for a
566 // response. This won't actually update the throbber, but it will get picked
567 // up at the next animation step if the throbber is going.
568 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
569
[email protected]0dd3a0ab2011-02-18 08:17:44570 // Navigation helpers --------------------------------------------------------
571 //
572 // These functions are helpers for Navigate() and DidNavigate().
573
574 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
575 // committed to the navigation controller. Note that the navigation entry is
576 // not provided since it may be invalid/changed after being committed. The
577 // current navigation entry is in the NavigationController at this point.
578 void DidNavigateMainFramePostCommit(
[email protected]8286f51a2011-05-31 17:39:13579 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44580 const ViewHostMsg_FrameNavigate_Params& params);
581 void DidNavigateAnyFramePostCommit(
[email protected]eaabba22012-03-07 15:02:11582 content::RenderViewHost* render_view_host,
[email protected]8286f51a2011-05-31 17:39:13583 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44584 const ViewHostMsg_FrameNavigate_Params& params);
585
[email protected]74ce1ad2011-12-16 21:51:46586 // If our controller was restored, update the max page ID associated with the
587 // given RenderViewHost to be larger than the number of restored entries.
588 // This is called in CreateRenderView before any navigations in the RenderView
589 // have begun, to prevent any races in updating RenderView::next_page_id.
[email protected]eaabba22012-03-07 15:02:11590 void UpdateMaxPageIDIfNecessary(content::RenderViewHost* rvh);
[email protected]0dd3a0ab2011-02-18 08:17:44591
[email protected]0dd3a0ab2011-02-18 08:17:44592 // Saves the given title to the navigation entry and does associated work. It
593 // will update history and the view for the new title, and also synthesize
594 // titles for file URLs that have none (so we require that the URL of the
595 // entry already be set).
596 //
597 // This is used as the backend for state updates, which include a new title,
598 // or the dedicated set title message. It returns true if the new title is
599 // different and was therefore updated.
[email protected]10f417c52011-12-28 21:04:23600 bool UpdateTitleForEntry(content::NavigationEntryImpl* entry,
601 const string16& title);
[email protected]0dd3a0ab2011-02-18 08:17:44602
[email protected]b172aee2012-04-10 17:05:26603 // Causes the WebContentsImpl to navigate in the right renderer to |entry|,
604 // which must be already part of the entries in the navigation controller.
[email protected]0dd3a0ab2011-02-18 08:17:44605 // This does not change the NavigationController state.
[email protected]10f417c52011-12-28 21:04:23606 bool NavigateToEntry(const content::NavigationEntryImpl& entry,
[email protected]71fde352011-12-29 03:29:56607 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44608
[email protected]b172aee2012-04-10 17:05:26609 // Sets the history for this WebContentsImpl to |history_length| entries, and
[email protected]796931a92011-08-10 01:32:14610 // moves the current page_id to the last entry in the list if it's valid.
611 // This is mainly used when a prerendered page is swapped into the current
[email protected]9e1ad4b2011-08-14 16:49:19612 // tab. The method is virtual for testing.
[email protected]b6583592012-01-25 19:52:33613 virtual void SetHistoryLengthAndPrune(
614 const content::SiteInstance* site_instance,
615 int merge_history_length,
616 int32 minimum_page_id);
[email protected]796931a92011-08-10 01:32:14617
[email protected]14392a52012-05-02 20:28:44618 // Recursively creates swapped out RenderViews for this tab's opener chain
619 // (including this tab) in the given SiteInstance, allowing other tabs to send
620 // cross-process JavaScript calls to their opener(s). Returns the route ID of
621 // this tab's RenderView for |instance|.
622 int CreateOpenerRenderViews(content::SiteInstance* instance);
623
[email protected]bafe6cd2012-05-23 23:09:50624 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
625 void CreateNewWidget(int route_id,
626 bool is_fullscreen,
627 WebKit::WebPopupType popup_type);
628
629 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
630 void ShowCreatedWidget(int route_id,
631 bool is_fullscreen,
632 const gfx::Rect& initial_pos);
633
634 // Finds the new RenderWidgetHost and returns it. Note that this can only be
635 // called once as this call also removes it from the internal map.
636 content::RenderWidgetHostView* GetCreatedWidget(int route_id);
637
638 // Finds the new WebContentsImpl by route_id, initializes it for
639 // renderer-initiated creation, and returns it. Note that this can only be
640 // called once as this call also removes it from the internal map.
641 WebContentsImpl* GetCreatedWindow(int route_id);
642
[email protected]0dd3a0ab2011-02-18 08:17:44643 // Misc non-view stuff -------------------------------------------------------
644
645 // Helper functions for sending notifications.
646 void NotifySwapped();
647 void NotifyConnected();
648 void NotifyDisconnected();
649
[email protected]be1f56ab2011-12-22 06:55:31650 void SetEncoding(const std::string& encoding);
651
[email protected]27678b2a2012-02-04 22:09:14652 // Save a URL to the local filesystem.
[email protected]20b433a2012-05-15 21:23:46653 void SaveURL(const GURL& url,
654 const content::Referrer& referrer,
655 bool is_main_frame);
[email protected]27678b2a2012-02-04 22:09:14656
[email protected]eaabba22012-03-07 15:02:11657 content::RenderViewHostImpl* GetRenderViewHostImpl();
[email protected]9f76c1e2012-03-05 15:15:58658
[email protected]7900bfdb2012-05-24 19:31:24659 void GetBrowserPluginEmbedderInfo(content::RenderViewHost* render_view_host,
660 std::string* embedder_channel_name,
661 int* embedder_container_id);
662
[email protected]0dd3a0ab2011-02-18 08:17:44663 // Data for core operation ---------------------------------------------------
664
665 // Delegate for notifying our owner about stuff. Not owned by us.
[email protected]674bc592011-12-20 23:00:42666 content::WebContentsDelegate* delegate_;
[email protected]0dd3a0ab2011-02-18 08:17:44667
668 // Handles the back/forward list and loading.
[email protected]d202a7c2012-01-04 07:53:47669 NavigationControllerImpl controller_;
[email protected]0dd3a0ab2011-02-18 08:17:44670
671 // The corresponding view.
[email protected]8643e6d2012-01-18 20:26:10672 scoped_ptr<content::WebContentsView> view_;
[email protected]0dd3a0ab2011-02-18 08:17:44673
[email protected]5a3bdf52012-05-24 15:12:57674 // The view of the RVHD. Usually this is our WebContentsView implementation,
675 // but if an embedder uses a different WebContentsView, they'll need to
676 // provide this.
677 content::RenderViewHostDelegateView* render_view_host_delegate_view_;
678
[email protected]bafe6cd2012-05-23 23:09:50679 // Tracks created WebContentsImpl objects that have not been shown yet. They
680 // are identified by the route ID passed to CreateNewWindow.
681 typedef std::map<int, WebContentsImpl*> PendingContents;
682 PendingContents pending_contents_;
683
684 // These maps hold on to the widgets that we created on behalf of the renderer
685 // that haven't shown yet.
686 typedef std::map<int, content::RenderWidgetHostView*> PendingWidgetViews;
687 PendingWidgetViews pending_widget_views_;
688
[email protected]996042972011-11-08 22:43:59689 // A list of observers notified when page state changes. Weak references.
690 // This MUST be listed above render_manager_ since at destruction time the
691 // latter might cause RenderViewHost's destructor to call us and we might use
692 // the observer list then.
[email protected]d8c660432011-12-22 20:51:25693 ObserverList<content::WebContentsObserver> observers_;
[email protected]996042972011-11-08 22:43:59694
[email protected]14392a52012-05-02 20:28:44695 // The tab that opened this tab, if any. Will be set to null if the opener
696 // is closed.
697 WebContentsImpl* opener_;
698
[email protected]0dd3a0ab2011-02-18 08:17:44699 // Helper classes ------------------------------------------------------------
700
701 // Manages creation and swapping of render views.
702 RenderViewHostManager render_manager_;
703
[email protected]483623eb2011-10-25 09:30:00704 // Manages injecting Java objects into all RenderViewHosts associated with
[email protected]b172aee2012-04-10 17:05:26705 // this WebContentsImpl.
[email protected]483623eb2011-10-25 09:30:00706 scoped_ptr<JavaBridgeDispatcherHostManager>
707 java_bridge_dispatcher_host_manager_;
708
[email protected]dd26779c2012-08-08 01:50:28709 // TODO(fsamuel): Remove this once upstreaming of the new browser plugin
710 // implmentation is complete.
[email protected]172cf712012-05-23 15:07:39711 // Manages the browser plugin instances hosted by this WebContents.
[email protected]dd26779c2012-08-08 01:50:28712 scoped_ptr<content::old::BrowserPluginHost> old_browser_plugin_host_;
[email protected]172cf712012-05-23 15:07:39713
[email protected]c7dd2f62011-07-18 15:57:59714 // SavePackage, lazily created.
715 scoped_refptr<SavePackage> save_package_;
716
[email protected]0dd3a0ab2011-02-18 08:17:44717 // Data for loading state ----------------------------------------------------
718
719 // Indicates whether we're currently loading a resource.
720 bool is_loading_;
721
722 // Indicates if the tab is considered crashed.
723 base::TerminationStatus crashed_status_;
724 int crashed_error_code_;
725
[email protected]ca13a442012-04-17 14:00:12726 // Whether this WebContents is waiting for a first-response for the
[email protected]be1f56ab2011-12-22 06:55:31727 // main resource of the page. This controls whether the throbber state is
728 // "waiting" or "loading."
[email protected]0dd3a0ab2011-02-18 08:17:44729 bool waiting_for_response_;
730
[email protected]74ce1ad2011-12-16 21:51:46731 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
732 // to a given tab and SiteInstance, and must be valid for the lifetime of the
[email protected]b172aee2012-04-10 17:05:26733 // WebContentsImpl.
[email protected]74ce1ad2011-12-16 21:51:46734 std::map<int32, int32> max_page_ids_;
[email protected]0dd3a0ab2011-02-18 08:17:44735
736 // System time at which the current load was started.
737 base::TimeTicks current_load_start_;
738
739 // The current load state and the URL associated with it.
[email protected]9c235f042011-08-10 22:28:21740 net::LoadStateWithParam load_state_;
[email protected]0dd3a0ab2011-02-18 08:17:44741 string16 load_state_host_;
742 // Upload progress, for displaying in the status bar.
743 // Set to zero when there is no significant upload happening.
744 uint64 upload_size_;
745 uint64 upload_position_;
746
747 // Data for current page -----------------------------------------------------
748
[email protected]987fc3a2011-05-26 14:18:09749 // When a title cannot be taken from any entry, this title will be used.
750 string16 page_title_when_no_navigation_entry_;
751
[email protected]0dd3a0ab2011-02-18 08:17:44752 // When a navigation occurs, we record its contents MIME type. It can be
753 // used to check whether we can do something for some special contents.
754 std::string contents_mime_type_;
755
756 // Character encoding.
757 std::string encoding_;
758
[email protected]0dd3a0ab2011-02-18 08:17:44759 // True if this is a secure page which displayed insecure content.
760 bool displayed_insecure_content_;
761
[email protected]0dd3a0ab2011-02-18 08:17:44762 // Data for misc internal state ----------------------------------------------
763
[email protected]ca13a442012-04-17 14:00:12764 // Whether the WebContents is currently being screenshotted.
[email protected]0dd3a0ab2011-02-18 08:17:44765 bool capturing_contents_;
766
767 // See getter above.
768 bool is_being_destroyed_;
769
770 // Indicates whether we should notify about disconnection of this
[email protected]b172aee2012-04-10 17:05:26771 // WebContentsImpl. This is used to ensure disconnection notifications only
[email protected]0dd3a0ab2011-02-18 08:17:44772 // happen if a connection notification has happened and that they happen only
773 // once.
774 bool notify_disconnection_;
775
[email protected]2e5b90c2011-08-16 21:11:55776 // Pointer to the JavaScript dialog creator, lazily assigned. Used because the
[email protected]b172aee2012-04-10 17:05:26777 // delegate of this WebContentsImpl is nulled before its destructor is called.
[email protected]2e5b90c2011-08-16 21:11:55778 content::JavaScriptDialogCreator* dialog_creator_;
779
[email protected]0dd3a0ab2011-02-18 08:17:44780#if defined(OS_WIN)
781 // Handle to an event that's set when the page is showing a message box (or
782 // equivalent constrained window). Plugin processes check this to know if
783 // they should pump messages then.
784 base::win::ScopedHandle message_box_active_;
785#endif
786
[email protected]0dd3a0ab2011-02-18 08:17:44787 // Set to true when there is an active "before unload" dialog. When true,
788 // we've forced the throbber to start in Navigate, and we need to remember to
789 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
790 bool is_showing_before_unload_dialog_;
791
[email protected]0dd3a0ab2011-02-18 08:17:44792 // Settings that get passed to the renderer process.
[email protected]daf82f82011-10-31 22:35:31793 content::RendererPreferences renderer_preferences_;
[email protected]0dd3a0ab2011-02-18 08:17:44794
795 // If this tab was created from a renderer using window.open, this will be
796 // non-NULL and represent the WebUI of the opening renderer.
[email protected]01ec4ec2012-01-18 04:13:47797 content::WebUI::TypeID opener_web_ui_type_;
[email protected]0dd3a0ab2011-02-18 08:17:44798
799 // The time that we started to create the new tab page.
800 base::TimeTicks new_tab_start_time_;
801
[email protected]3bbacc5b2012-04-17 17:46:15802 // The time that we started to close this WebContents.
803 base::TimeTicks close_start_time_;
[email protected]0dd3a0ab2011-02-18 08:17:44804
805 // The time that this tab was last selected.
806 base::TimeTicks last_selected_time_;
807
[email protected]0dd3a0ab2011-02-18 08:17:44808 // See description above setter.
809 bool closed_by_user_gesture_;
810
811 // Minimum/maximum zoom percent.
812 int minimum_zoom_percent_;
813 int maximum_zoom_percent_;
814 // If true, the default zoom limits have been overriden for this tab, in which
815 // case we don't want saved settings to apply to it and we don't want to
816 // remember it.
817 bool temporary_zoom_settings_;
818
[email protected]bcd2815602012-01-14 18:17:23819 // The intrinsic size of the page.
820 gfx::Size preferred_size_;
821
[email protected]0dd3a0ab2011-02-18 08:17:44822 // Content restrictions, used to disable print/copy etc based on content's
823 // (full-page plugins for now only) permissions.
824 int content_restrictions_;
825
[email protected]da8543762012-03-20 08:52:20826 // Color chooser that was opened by this tab.
827 content::ColorChooser* color_chooser_;
828
[email protected]f53a9f872012-05-24 02:07:06829 // This must be at the end, or else we might get notifications and use other
830 // member variables that are gone.
831 content::NotificationRegistrar registrar_;
832
[email protected]7bb761892012-07-20 09:32:47833 // Used during IPC message dispatching so that the handlers can get a pointer
834 // to the RVH through which the message was received.
835 content::RenderViewHost* message_source_;
836
[email protected]b172aee2012-04-10 17:05:26837 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
[email protected]0dd3a0ab2011-02-18 08:17:44838};
839
[email protected]93ddb3c2012-04-11 21:44:29840#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_