blob: 024e872571b98984b0e1cbd014fe79b2098770dd [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]4ca76c02012-05-16 16:19:05414 // RenderWidgetHostDelegate --------------------------------------------------
415
[email protected]b87ee522012-05-18 15:16:54416 virtual bool PreHandleKeyboardEvent(
417 const content::NativeWebKeyboardEvent& event,
418 bool* is_keyboard_shortcut) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05419 virtual void HandleKeyboardEvent(
[email protected]b87ee522012-05-18 15:16:54420 const content::NativeWebKeyboardEvent& event) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05421
[email protected]0bfbf882011-12-22 18:19:27422 // RenderViewHostManager::Delegate -------------------------------------------
423
424 virtual bool CreateRenderViewForRenderManager(
[email protected]14392a52012-05-02 20:28:44425 content::RenderViewHost* render_view_host, int opener_route_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27426 virtual void BeforeUnloadFiredFromRenderManager(
427 bool proceed,
428 bool* proceed_to_fire_unload) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27429 virtual void RenderViewGoneFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11430 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27431 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
432 virtual void NotifySwappedFromRenderManager() OVERRIDE;
[email protected]14392a52012-05-02 20:28:44433 virtual int CreateOpenerRenderViewsForRenderManager(
434 content::SiteInstance* instance) OVERRIDE;
[email protected]d202a7c2012-01-04 07:53:47435 virtual NavigationControllerImpl& GetControllerForRenderManager() OVERRIDE;
[email protected]d2353452012-01-19 19:53:56436 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
[email protected]ad23a092011-12-28 07:02:04437 virtual content::NavigationEntry*
[email protected]0bfbf882011-12-22 18:19:27438 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
439 virtual bool FocusLocationBarByDefault() OVERRIDE;
440 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11441 virtual void CreateViewAndSetSizeForRVH(
442 content::RenderViewHost* rvh) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27443
[email protected]14392a52012-05-02 20:28:44444 // content::NotificationObserver ---------------------------------------------
445
446 virtual void Observe(int type,
447 const content::NotificationSource& source,
448 const content::NotificationDetails& details) OVERRIDE;
449
[email protected]553602e12011-04-05 17:01:18450
[email protected]0dd3a0ab2011-02-18 08:17:44451 private:
[email protected]d202a7c2012-01-04 07:53:47452 friend class NavigationControllerImpl;
[email protected]d1198fd2012-08-13 22:50:19453 friend class content::WebContentsObserver;
454 friend class content::WebContents; // To implement factory methods.
[email protected]0dd3a0ab2011-02-18 08:17:44455
[email protected]2db9bd72012-04-13 20:20:56456 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
457 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
458 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
459 CrossSiteCantPreemptAfterUnload);
[email protected]0dd3a0ab2011-02-18 08:17:44460 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
461 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
462 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
463
[email protected]cadaec52012-02-08 21:53:13464 // So InterstitialPageImpl can access SetIsLoading.
465 friend class InterstitialPageImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44466
[email protected]80e776ae2012-03-23 16:17:20467 // TODO(brettw) TestWebContents shouldn't exist!
468 friend class content::TestWebContents;
[email protected]0dd3a0ab2011-02-18 08:17:44469
[email protected]d1198fd2012-08-13 22:50:19470 // See WebContents::Create for a description of these parameters.
471 WebContentsImpl(content::BrowserContext* browser_context,
472 WebContentsImpl* opener);
473
474 // Add and remove observers for page navigation notifications. Adding or
475 // removing multiple times has no effect. The order in which notifications
476 // are sent to observers is undefined. Clients must be sure to remove the
477 // observer before they go away.
478 void AddObserver(content::WebContentsObserver* observer);
479 void RemoveObserver(content::WebContentsObserver* observer);
480
[email protected]14392a52012-05-02 20:28:44481 // Clears this tab's opener if it has been closed.
482 void OnWebContentsDestroyed(content::WebContents* web_contents);
483
[email protected]51da7e32012-01-30 19:24:52484 // Callback function when showing JS dialogs.
[email protected]eaabba22012-03-07 15:02:11485 void OnDialogClosed(content::RenderViewHost* rvh,
[email protected]51da7e32012-01-30 19:24:52486 IPC::Message* reply_msg,
487 bool success,
488 const string16& user_input);
489
[email protected]d8415ad92012-08-23 14:40:50490 // Callback function when requesting permission to access the PPAPI broker.
491 // |result| is true if permission was granted.
492 void OnPpapiBrokerPermissionResult(int request_id, bool result);
493
[email protected]d0759f492012-04-19 22:50:50494 // IPC message handlers.
[email protected]3a3b75a2012-06-01 08:38:36495 void OnRegisterIntentService(const webkit_glue::WebIntentServiceData& data,
496 bool user_gesture);
[email protected]678105012011-12-09 04:01:21497 void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
[email protected]63c239322011-10-31 23:56:30498 int intent_id);
[email protected]0dd3a0ab2011-02-18 08:17:44499 void OnDidLoadResourceFromMemoryCache(const GURL& url,
[email protected]70435962011-08-02 20:13:28500 const std::string& security_info,
501 const std::string& http_request,
[email protected]6d6cfb3a2012-05-23 22:53:18502 const std::string& mime_type,
[email protected]70435962011-08-02 20:13:28503 ResourceType::Type resource_type);
[email protected]0dd3a0ab2011-02-18 08:17:44504 void OnDidDisplayInsecureContent();
505 void OnDidRunInsecureContent(const std::string& security_origin,
506 const GURL& target_url);
507 void OnDocumentLoadedInFrame(int64 frame_id);
[email protected]1a55c5be2011-11-29 11:36:31508 void OnDidFinishLoad(int64 frame_id,
509 const GURL& validated_url,
510 bool is_main_frame);
511 void OnDidFailLoadWithError(int64 frame_id,
512 const GURL& validated_url,
513 bool is_main_frame,
514 int error_code,
515 const string16& error_description);
[email protected]0dd3a0ab2011-02-18 08:17:44516 void OnUpdateContentRestrictions(int restrictions);
[email protected]0dd3a0ab2011-02-18 08:17:44517 void OnGoToEntryAtOffset(int offset);
[email protected]216813952011-05-19 22:21:26518 void OnUpdateZoomLimits(int minimum_percent,
519 int maximum_percent,
520 bool remember);
[email protected]20b433a2012-05-15 21:23:46521 void OnSaveURL(const GURL& url, const content::Referrer& referrer);
[email protected]3a29a6e2011-08-24 18:26:21522 void OnEnumerateDirectory(int request_id, const FilePath& path);
[email protected]7d189022011-08-25 22:54:20523 void OnJSOutOfMemory();
[email protected]b7a756d42012-01-23 18:08:17524
[email protected]7d189022011-08-25 22:54:20525 void OnRegisterProtocolHandler(const std::string& protocol,
526 const GURL& url,
[email protected]3a3b75a2012-06-01 08:38:36527 const string16& title,
528 bool user_gesture);
[email protected]59363fc92012-09-05 03:46:31529 void OnFindReply(int request_id,
530 int number_of_matches,
531 const gfx::Rect& selection_rect,
532 int active_match_ordinal,
[email protected]b888919c2011-09-02 00:32:16533 bool final_update);
[email protected]59363fc92012-09-05 03:46:31534#if defined(OS_ANDROID)
535 void OnFindMatchRectsReply(int version,
536 const std::vector<gfx::RectF>& rects,
537 const gfx::RectF& active_rect);
538#endif
[email protected]d952a052011-09-06 18:42:45539 void OnCrashedPlugin(const FilePath& plugin_path);
[email protected]7fc4bbb2011-09-08 21:23:10540 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
[email protected]55578b0a2012-04-18 14:31:32541 void OnOpenColorChooser(int color_chooser_id, SkColor color);
[email protected]da8543762012-03-20 08:52:20542 void OnEndColorChooser(int color_chooser_id);
[email protected]55578b0a2012-04-18 14:31:32543 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
[email protected]8be45842012-04-13 19:49:29544 void OnPepperPluginHung(int plugin_child_id,
545 const FilePath& path,
546 bool is_hung);
[email protected]d0759f492012-04-19 22:50:50547 void OnWebUISend(const GURL& source_url,
548 const std::string& name,
549 const base::ListValue& args);
[email protected]d8415ad92012-08-23 14:40:50550 void OnRequestPpapiBrokerPermission(int request_id,
551 const GURL& url,
552 const FilePath& plugin_path);
[email protected]0dd3a0ab2011-02-18 08:17:44553
554 // Changes the IsLoading state and notifies delegate as needed
555 // |details| is used to provide details on the load that just finished
556 // (but can be null if not applicable). Can be overridden.
557 void SetIsLoading(bool is_loading,
[email protected]09d31d52012-03-11 22:30:27558 content::LoadNotificationDetails* details);
[email protected]0dd3a0ab2011-02-18 08:17:44559
[email protected]0dd3a0ab2011-02-18 08:17:44560 // Called by derived classes to indicate that we're no longer waiting for a
561 // response. This won't actually update the throbber, but it will get picked
562 // up at the next animation step if the throbber is going.
563 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
564
[email protected]0dd3a0ab2011-02-18 08:17:44565 // Navigation helpers --------------------------------------------------------
566 //
567 // These functions are helpers for Navigate() and DidNavigate().
568
569 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
570 // committed to the navigation controller. Note that the navigation entry is
571 // not provided since it may be invalid/changed after being committed. The
572 // current navigation entry is in the NavigationController at this point.
573 void DidNavigateMainFramePostCommit(
[email protected]8286f51a2011-05-31 17:39:13574 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44575 const ViewHostMsg_FrameNavigate_Params& params);
576 void DidNavigateAnyFramePostCommit(
[email protected]eaabba22012-03-07 15:02:11577 content::RenderViewHost* render_view_host,
[email protected]8286f51a2011-05-31 17:39:13578 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44579 const ViewHostMsg_FrameNavigate_Params& params);
580
[email protected]74ce1ad2011-12-16 21:51:46581 // If our controller was restored, update the max page ID associated with the
582 // given RenderViewHost to be larger than the number of restored entries.
583 // This is called in CreateRenderView before any navigations in the RenderView
584 // have begun, to prevent any races in updating RenderView::next_page_id.
[email protected]eaabba22012-03-07 15:02:11585 void UpdateMaxPageIDIfNecessary(content::RenderViewHost* rvh);
[email protected]0dd3a0ab2011-02-18 08:17:44586
[email protected]0dd3a0ab2011-02-18 08:17:44587 // Saves the given title to the navigation entry and does associated work. It
588 // will update history and the view for the new title, and also synthesize
589 // titles for file URLs that have none (so we require that the URL of the
590 // entry already be set).
591 //
592 // This is used as the backend for state updates, which include a new title,
593 // or the dedicated set title message. It returns true if the new title is
594 // different and was therefore updated.
[email protected]10f417c52011-12-28 21:04:23595 bool UpdateTitleForEntry(content::NavigationEntryImpl* entry,
596 const string16& title);
[email protected]0dd3a0ab2011-02-18 08:17:44597
[email protected]b172aee2012-04-10 17:05:26598 // Causes the WebContentsImpl to navigate in the right renderer to |entry|,
599 // which must be already part of the entries in the navigation controller.
[email protected]0dd3a0ab2011-02-18 08:17:44600 // This does not change the NavigationController state.
[email protected]10f417c52011-12-28 21:04:23601 bool NavigateToEntry(const content::NavigationEntryImpl& entry,
[email protected]71fde352011-12-29 03:29:56602 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44603
[email protected]b172aee2012-04-10 17:05:26604 // Sets the history for this WebContentsImpl to |history_length| entries, and
[email protected]796931a92011-08-10 01:32:14605 // moves the current page_id to the last entry in the list if it's valid.
606 // This is mainly used when a prerendered page is swapped into the current
[email protected]9e1ad4b2011-08-14 16:49:19607 // tab. The method is virtual for testing.
[email protected]b6583592012-01-25 19:52:33608 virtual void SetHistoryLengthAndPrune(
609 const content::SiteInstance* site_instance,
610 int merge_history_length,
611 int32 minimum_page_id);
[email protected]796931a92011-08-10 01:32:14612
[email protected]14392a52012-05-02 20:28:44613 // Recursively creates swapped out RenderViews for this tab's opener chain
614 // (including this tab) in the given SiteInstance, allowing other tabs to send
615 // cross-process JavaScript calls to their opener(s). Returns the route ID of
616 // this tab's RenderView for |instance|.
617 int CreateOpenerRenderViews(content::SiteInstance* instance);
618
[email protected]bafe6cd2012-05-23 23:09:50619 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
620 void CreateNewWidget(int route_id,
621 bool is_fullscreen,
622 WebKit::WebPopupType popup_type);
623
624 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
625 void ShowCreatedWidget(int route_id,
626 bool is_fullscreen,
627 const gfx::Rect& initial_pos);
628
629 // Finds the new RenderWidgetHost and returns it. Note that this can only be
630 // called once as this call also removes it from the internal map.
631 content::RenderWidgetHostView* GetCreatedWidget(int route_id);
632
633 // Finds the new WebContentsImpl by route_id, initializes it for
634 // renderer-initiated creation, and returns it. Note that this can only be
635 // called once as this call also removes it from the internal map.
636 WebContentsImpl* GetCreatedWindow(int route_id);
637
[email protected]0dd3a0ab2011-02-18 08:17:44638 // Misc non-view stuff -------------------------------------------------------
639
640 // Helper functions for sending notifications.
641 void NotifySwapped();
642 void NotifyConnected();
643 void NotifyDisconnected();
644
[email protected]be1f56ab2011-12-22 06:55:31645 void SetEncoding(const std::string& encoding);
646
[email protected]27678b2a2012-02-04 22:09:14647 // Save a URL to the local filesystem.
[email protected]20b433a2012-05-15 21:23:46648 void SaveURL(const GURL& url,
649 const content::Referrer& referrer,
650 bool is_main_frame);
[email protected]27678b2a2012-02-04 22:09:14651
[email protected]eaabba22012-03-07 15:02:11652 content::RenderViewHostImpl* GetRenderViewHostImpl();
[email protected]9f76c1e2012-03-05 15:15:58653
[email protected]7900bfdb2012-05-24 19:31:24654 void GetBrowserPluginEmbedderInfo(content::RenderViewHost* render_view_host,
655 std::string* embedder_channel_name,
656 int* embedder_container_id);
657
[email protected]0dd3a0ab2011-02-18 08:17:44658 // Data for core operation ---------------------------------------------------
659
660 // Delegate for notifying our owner about stuff. Not owned by us.
[email protected]674bc592011-12-20 23:00:42661 content::WebContentsDelegate* delegate_;
[email protected]0dd3a0ab2011-02-18 08:17:44662
663 // Handles the back/forward list and loading.
[email protected]d202a7c2012-01-04 07:53:47664 NavigationControllerImpl controller_;
[email protected]0dd3a0ab2011-02-18 08:17:44665
666 // The corresponding view.
[email protected]8643e6d2012-01-18 20:26:10667 scoped_ptr<content::WebContentsView> view_;
[email protected]0dd3a0ab2011-02-18 08:17:44668
[email protected]5a3bdf52012-05-24 15:12:57669 // The view of the RVHD. Usually this is our WebContentsView implementation,
670 // but if an embedder uses a different WebContentsView, they'll need to
671 // provide this.
672 content::RenderViewHostDelegateView* render_view_host_delegate_view_;
673
[email protected]bafe6cd2012-05-23 23:09:50674 // Tracks created WebContentsImpl objects that have not been shown yet. They
675 // are identified by the route ID passed to CreateNewWindow.
676 typedef std::map<int, WebContentsImpl*> PendingContents;
677 PendingContents pending_contents_;
678
679 // These maps hold on to the widgets that we created on behalf of the renderer
680 // that haven't shown yet.
681 typedef std::map<int, content::RenderWidgetHostView*> PendingWidgetViews;
682 PendingWidgetViews pending_widget_views_;
683
[email protected]996042972011-11-08 22:43:59684 // A list of observers notified when page state changes. Weak references.
685 // This MUST be listed above render_manager_ since at destruction time the
686 // latter might cause RenderViewHost's destructor to call us and we might use
687 // the observer list then.
[email protected]d8c660432011-12-22 20:51:25688 ObserverList<content::WebContentsObserver> observers_;
[email protected]996042972011-11-08 22:43:59689
[email protected]14392a52012-05-02 20:28:44690 // The tab that opened this tab, if any. Will be set to null if the opener
691 // is closed.
692 WebContentsImpl* opener_;
693
[email protected]0dd3a0ab2011-02-18 08:17:44694 // Helper classes ------------------------------------------------------------
695
696 // Manages creation and swapping of render views.
697 RenderViewHostManager render_manager_;
698
[email protected]483623eb2011-10-25 09:30:00699 // Manages injecting Java objects into all RenderViewHosts associated with
[email protected]b172aee2012-04-10 17:05:26700 // this WebContentsImpl.
[email protected]483623eb2011-10-25 09:30:00701 scoped_ptr<JavaBridgeDispatcherHostManager>
702 java_bridge_dispatcher_host_manager_;
703
[email protected]dd26779c2012-08-08 01:50:28704 // TODO(fsamuel): Remove this once upstreaming of the new browser plugin
705 // implmentation is complete.
[email protected]172cf712012-05-23 15:07:39706 // Manages the browser plugin instances hosted by this WebContents.
[email protected]dd26779c2012-08-08 01:50:28707 scoped_ptr<content::old::BrowserPluginHost> old_browser_plugin_host_;
[email protected]172cf712012-05-23 15:07:39708
[email protected]c7dd2f62011-07-18 15:57:59709 // SavePackage, lazily created.
710 scoped_refptr<SavePackage> save_package_;
711
[email protected]0dd3a0ab2011-02-18 08:17:44712 // Data for loading state ----------------------------------------------------
713
714 // Indicates whether we're currently loading a resource.
715 bool is_loading_;
716
717 // Indicates if the tab is considered crashed.
718 base::TerminationStatus crashed_status_;
719 int crashed_error_code_;
720
[email protected]ca13a442012-04-17 14:00:12721 // Whether this WebContents is waiting for a first-response for the
[email protected]be1f56ab2011-12-22 06:55:31722 // main resource of the page. This controls whether the throbber state is
723 // "waiting" or "loading."
[email protected]0dd3a0ab2011-02-18 08:17:44724 bool waiting_for_response_;
725
[email protected]74ce1ad2011-12-16 21:51:46726 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
727 // to a given tab and SiteInstance, and must be valid for the lifetime of the
[email protected]b172aee2012-04-10 17:05:26728 // WebContentsImpl.
[email protected]74ce1ad2011-12-16 21:51:46729 std::map<int32, int32> max_page_ids_;
[email protected]0dd3a0ab2011-02-18 08:17:44730
731 // System time at which the current load was started.
732 base::TimeTicks current_load_start_;
733
734 // The current load state and the URL associated with it.
[email protected]9c235f042011-08-10 22:28:21735 net::LoadStateWithParam load_state_;
[email protected]0dd3a0ab2011-02-18 08:17:44736 string16 load_state_host_;
737 // Upload progress, for displaying in the status bar.
738 // Set to zero when there is no significant upload happening.
739 uint64 upload_size_;
740 uint64 upload_position_;
741
742 // Data for current page -----------------------------------------------------
743
[email protected]987fc3a2011-05-26 14:18:09744 // When a title cannot be taken from any entry, this title will be used.
745 string16 page_title_when_no_navigation_entry_;
746
[email protected]0dd3a0ab2011-02-18 08:17:44747 // When a navigation occurs, we record its contents MIME type. It can be
748 // used to check whether we can do something for some special contents.
749 std::string contents_mime_type_;
750
751 // Character encoding.
752 std::string encoding_;
753
[email protected]0dd3a0ab2011-02-18 08:17:44754 // True if this is a secure page which displayed insecure content.
755 bool displayed_insecure_content_;
756
[email protected]0dd3a0ab2011-02-18 08:17:44757 // Data for misc internal state ----------------------------------------------
758
[email protected]ca13a442012-04-17 14:00:12759 // Whether the WebContents is currently being screenshotted.
[email protected]0dd3a0ab2011-02-18 08:17:44760 bool capturing_contents_;
761
762 // See getter above.
763 bool is_being_destroyed_;
764
765 // Indicates whether we should notify about disconnection of this
[email protected]b172aee2012-04-10 17:05:26766 // WebContentsImpl. This is used to ensure disconnection notifications only
[email protected]0dd3a0ab2011-02-18 08:17:44767 // happen if a connection notification has happened and that they happen only
768 // once.
769 bool notify_disconnection_;
770
[email protected]2e5b90c2011-08-16 21:11:55771 // Pointer to the JavaScript dialog creator, lazily assigned. Used because the
[email protected]b172aee2012-04-10 17:05:26772 // delegate of this WebContentsImpl is nulled before its destructor is called.
[email protected]2e5b90c2011-08-16 21:11:55773 content::JavaScriptDialogCreator* dialog_creator_;
774
[email protected]0dd3a0ab2011-02-18 08:17:44775#if defined(OS_WIN)
776 // Handle to an event that's set when the page is showing a message box (or
777 // equivalent constrained window). Plugin processes check this to know if
778 // they should pump messages then.
779 base::win::ScopedHandle message_box_active_;
780#endif
781
[email protected]0dd3a0ab2011-02-18 08:17:44782 // Set to true when there is an active "before unload" dialog. When true,
783 // we've forced the throbber to start in Navigate, and we need to remember to
784 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
785 bool is_showing_before_unload_dialog_;
786
[email protected]0dd3a0ab2011-02-18 08:17:44787 // Settings that get passed to the renderer process.
[email protected]daf82f82011-10-31 22:35:31788 content::RendererPreferences renderer_preferences_;
[email protected]0dd3a0ab2011-02-18 08:17:44789
790 // If this tab was created from a renderer using window.open, this will be
791 // non-NULL and represent the WebUI of the opening renderer.
[email protected]01ec4ec2012-01-18 04:13:47792 content::WebUI::TypeID opener_web_ui_type_;
[email protected]0dd3a0ab2011-02-18 08:17:44793
794 // The time that we started to create the new tab page.
795 base::TimeTicks new_tab_start_time_;
796
[email protected]3bbacc5b2012-04-17 17:46:15797 // The time that we started to close this WebContents.
798 base::TimeTicks close_start_time_;
[email protected]0dd3a0ab2011-02-18 08:17:44799
800 // The time that this tab was last selected.
801 base::TimeTicks last_selected_time_;
802
[email protected]0dd3a0ab2011-02-18 08:17:44803 // See description above setter.
804 bool closed_by_user_gesture_;
805
806 // Minimum/maximum zoom percent.
807 int minimum_zoom_percent_;
808 int maximum_zoom_percent_;
809 // If true, the default zoom limits have been overriden for this tab, in which
810 // case we don't want saved settings to apply to it and we don't want to
811 // remember it.
812 bool temporary_zoom_settings_;
813
[email protected]bcd2815602012-01-14 18:17:23814 // The intrinsic size of the page.
815 gfx::Size preferred_size_;
816
[email protected]0dd3a0ab2011-02-18 08:17:44817 // Content restrictions, used to disable print/copy etc based on content's
818 // (full-page plugins for now only) permissions.
819 int content_restrictions_;
820
[email protected]da8543762012-03-20 08:52:20821 // Color chooser that was opened by this tab.
822 content::ColorChooser* color_chooser_;
823
[email protected]f53a9f872012-05-24 02:07:06824 // This must be at the end, or else we might get notifications and use other
825 // member variables that are gone.
826 content::NotificationRegistrar registrar_;
827
[email protected]7bb761892012-07-20 09:32:47828 // Used during IPC message dispatching so that the handlers can get a pointer
829 // to the RVH through which the message was received.
830 content::RenderViewHost* message_source_;
831
[email protected]b172aee2012-04-10 17:05:26832 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
[email protected]0dd3a0ab2011-02-18 08:17:44833};
834
[email protected]93ddb3c2012-04-11 21:44:29835#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_