blob: b9320aed69ec0249a25201e11d8e3332633fd307 [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]45644f62011-11-23 00:58:2315#include "base/property_bag.h"
[email protected]cc510d7e2012-08-08 04:40:1016#include "content/browser/browser_plugin/old/old_browser_plugin_host.h"
[email protected]07161902011-11-11 09:57:4217#include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager.h"
[email protected]2e3bf992012-05-24 17:36:2418#include "content/browser/renderer_host/render_view_host_delegate.h"
[email protected]4ca76c02012-05-16 16:19:0519#include "content/browser/renderer_host/render_widget_host_delegate.h"
[email protected]f9e4dae2012-04-10 21:26:3720#include "content/browser/web_contents/navigation_controller_impl.h"
[email protected]0c4e92e62012-04-11 15:19:0021#include "content/browser/web_contents/render_view_host_manager.h"
[email protected]8d128d62011-09-13 22:11:5722#include "content/common/content_export.h"
[email protected]14392a52012-05-02 20:28:4423#include "content/public/browser/notification_observer.h"
24#include "content/public/browser/notification_registrar.h"
[email protected]58f5d562011-12-20 17:13:0325#include "content/public/browser/web_contents.h"
[email protected]daf82f82011-10-31 22:35:3126#include "content/public/common/renderer_preferences.h"
[email protected]0dd3a0ab2011-02-18 08:17:4427#include "net/base/load_states.h"
[email protected]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]6934a702011-12-20 00:04:51166 virtual const base::PropertyBag* GetPropertyBag() const OVERRIDE;
167 virtual base::PropertyBag* GetPropertyBag() OVERRIDE;
[email protected]674bc592011-12-20 23:00:42168 virtual content::WebContentsDelegate* GetDelegate() OVERRIDE;
169 virtual void SetDelegate(content::WebContentsDelegate* delegate) OVERRIDE;
[email protected]d1198fd2012-08-13 22:50:19170 virtual NavigationControllerImpl& GetController() OVERRIDE;
171 virtual const NavigationControllerImpl& GetController() const OVERRIDE;
[email protected]627e0512011-12-21 22:55:30172 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
[email protected]f5fa20e2011-12-21 22:35:56173 virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11174 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE;
[email protected]6b618e62012-08-16 12:59:18175 virtual int GetRoutingID() const OVERRIDE;
[email protected]5626b0892012-02-20 14:46:58176 virtual content::RenderWidgetHostView*
177 GetRenderWidgetHostView() const OVERRIDE;
[email protected]8643e6d2012-01-18 20:26:10178 virtual content::WebContentsView* GetView() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47179 virtual content::WebUI* CreateWebUI(const GURL& url) OVERRIDE;
180 virtual content::WebUI* GetWebUI() const OVERRIDE;
181 virtual content::WebUI* GetCommittedWebUI() const OVERRIDE;
[email protected]86ef6a392012-05-11 22:03:11182 virtual void SetUserAgentOverride(const std::string& override) OVERRIDE;
183 virtual const std::string& GetUserAgentOverride() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31184 virtual const string16& GetTitle() const OVERRIDE;
185 virtual int32 GetMaxPageID() OVERRIDE;
186 virtual int32 GetMaxPageIDForSiteInstance(
[email protected]b6583592012-01-25 19:52:33187 content::SiteInstance* site_instance) OVERRIDE;
188 virtual content::SiteInstance* GetSiteInstance() const OVERRIDE;
189 virtual content::SiteInstance* GetPendingSiteInstance() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31190 virtual bool IsLoading() const OVERRIDE;
191 virtual bool IsWaitingForResponse() const OVERRIDE;
192 virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE;
193 virtual const string16& GetLoadStateHost() const OVERRIDE;
194 virtual uint64 GetUploadSize() const OVERRIDE;
195 virtual uint64 GetUploadPosition() const OVERRIDE;
196 virtual const std::string& GetEncoding() const OVERRIDE;
197 virtual bool DisplayedInsecureContent() const OVERRIDE;
198 virtual void SetCapturingContents(bool cap) OVERRIDE;
199 virtual bool IsCrashed() const OVERRIDE;
200 virtual void SetIsCrashed(base::TerminationStatus status,
201 int error_code) OVERRIDE;
202 virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE;
203 virtual bool IsBeingDestroyed() const OVERRIDE;
204 virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31205 virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE;
[email protected]9e2e4632012-07-27 16:38:41206 virtual void WasShown() OVERRIDE;
[email protected]3e324142012-06-25 18:26:33207 virtual void WasHidden() OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31208 virtual bool NeedToFireBeforeUnload() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27209 virtual void Stop() OVERRIDE;
[email protected]d9083482012-01-06 00:38:46210 virtual content::WebContents* Clone() OVERRIDE;
[email protected]2a6bc3e2011-12-28 23:51:33211 virtual void AddNewContents(content::WebContents* new_contents,
[email protected]0bfbf882011-12-22 18:19:27212 WindowOpenDisposition disposition,
213 const gfx::Rect& initial_pos,
214 bool user_gesture) OVERRIDE;
215 virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
216 virtual gfx::NativeView GetNativeView() const OVERRIDE;
217 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE;
218 virtual void Focus() OVERRIDE;
219 virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE;
220 virtual bool ShowingInterstitialPage() const OVERRIDE;
[email protected]cadaec52012-02-08 21:53:13221 virtual content::InterstitialPage* GetInterstitialPage() const OVERRIDE;
[email protected]a53209b2012-01-20 16:48:16222 virtual bool IsSavable() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27223 virtual void OnSavePage() OVERRIDE;
224 virtual bool SavePage(const FilePath& main_file,
225 const FilePath& dir_path,
[email protected]a53209b2012-01-20 16:48:16226 content::SavePageType save_type) OVERRIDE;
[email protected]aa4f3972012-03-01 18:12:12227 virtual void GenerateMHTML(
228 const FilePath& file,
229 const base::Callback<void(const FilePath&, int64)>& callback) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27230 virtual bool IsActiveEntry(int32 page_id) OVERRIDE;
231
232 virtual const std::string& GetContentsMimeType() const OVERRIDE;
233 virtual bool WillNotifyDisconnection() const OVERRIDE;
234 virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE;
235 virtual void ResetOverrideEncoding() OVERRIDE;
236 virtual content::RendererPreferences* GetMutableRendererPrefs() OVERRIDE;
237 virtual void SetNewTabStartTime(const base::TimeTicks& time) OVERRIDE;
238 virtual base::TimeTicks GetNewTabStartTime() const OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47239 virtual void Close() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27240 virtual void OnCloseStarted() OVERRIDE;
241 virtual bool ShouldAcceptDragAndDrop() const OVERRIDE;
242 virtual void SystemDragEnded() OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47243 virtual void UserGestureDone() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27244 virtual void SetClosedByUserGesture(bool value) OVERRIDE;
245 virtual bool GetClosedByUserGesture() const OVERRIDE;
246 virtual double GetZoomLevel() const OVERRIDE;
247 virtual int GetZoomPercent(bool* enable_increment,
248 bool* enable_decrement) OVERRIDE;
249 virtual void ViewSource() OVERRIDE;
250 virtual void ViewFrameSource(const GURL& url,
251 const std::string& content_state) OVERRIDE;
252 virtual int GetMinimumZoomPercent() const OVERRIDE;
253 virtual int GetMaximumZoomPercent() const OVERRIDE;
[email protected]bcd2815602012-01-14 18:17:23254 virtual gfx::Size GetPreferredSize() const OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27255 virtual int GetContentRestrictions() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47256 virtual content::WebUI::TypeID GetWebUITypeForCurrentState() OVERRIDE;
257 virtual content::WebUI* GetWebUIForCurrentState() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27258 virtual bool GotResponseToLockMouseRequest(bool allowed) OVERRIDE;
[email protected]a0358d72012-03-09 14:06:50259 virtual bool HasOpener() const OVERRIDE;
[email protected]da8543762012-03-20 08:52:20260 virtual void DidChooseColorInColorChooser(int color_chooser_id,
[email protected]55578b0a2012-04-18 14:31:32261 SkColor color) OVERRIDE;
[email protected]da8543762012-03-20 08:52:20262 virtual void DidEndColorChooser(int color_chooser_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27263
264 // Implementation of PageNavigator.
[email protected]e5d549d2011-12-28 01:29:20265 virtual content::WebContents* OpenURL(
266 const content::OpenURLParams& params) OVERRIDE;
[email protected]151a63d2011-12-20 22:32:52267
[email protected]6b618e62012-08-16 12:59:18268 // Implementation of IPC::Sender.
269 virtual bool Send(IPC::Message* message) OVERRIDE;
270
[email protected]952a68e2011-11-17 00:36:10271 // RenderViewHostDelegate ----------------------------------------------------
272
[email protected]5a3bdf52012-05-24 15:12:57273 virtual content::RenderViewHostDelegateView* GetDelegateView() OVERRIDE;
[email protected]b0b67cf2012-01-18 21:59:57274 virtual content::RenderViewHostDelegate::RendererManagement*
[email protected]952a68e2011-11-17 00:36:10275 GetRendererManagementDelegate() OVERRIDE;
[email protected]7bb761892012-07-20 09:32:47276 virtual bool OnMessageReceived(content::RenderViewHost* render_view_host,
277 const IPC::Message& message) OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31278 virtual const GURL& GetURL() const OVERRIDE;
[email protected]d1198fd2012-08-13 22:50:19279 virtual content::WebContents* GetAsWebContents() OVERRIDE;
[email protected]b7a756d42012-01-23 18:08:17280 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11281 virtual void RenderViewCreated(
282 content::RenderViewHost* render_view_host) OVERRIDE;
283 virtual void RenderViewReady(
284 content::RenderViewHost* render_view_host) OVERRIDE;
285 virtual void RenderViewGone(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10286 base::TerminationStatus status,
287 int error_code) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11288 virtual void RenderViewDeleted(
289 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57290 virtual void DidStartProvisionalLoadForFrame(
291 content::RenderViewHost* render_view_host,
292 int64 frame_id,
293 bool main_frame,
294 const GURL& opener_url,
295 const GURL& url) OVERRIDE;
[email protected]400992b2012-06-14 00:03:54296 virtual void DidRedirectProvisionalLoad(
297 content::RenderViewHost* render_view_host,
298 int32 page_id,
299 const GURL& opener_url,
300 const GURL& source_url,
301 const GURL& target_url) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57302 virtual void DidFailProvisionalLoadWithError(
303 content::RenderViewHost* render_view_host,
304 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params)
305 OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10306 virtual void DidNavigate(
[email protected]eaabba22012-03-07 15:02:11307 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10308 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11309 virtual void UpdateState(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10310 int32 page_id,
311 const std::string& state) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11312 virtual void UpdateTitle(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10313 int32 page_id,
314 const string16& title,
315 base::i18n::TextDirection title_direction) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11316 virtual void UpdateEncoding(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10317 const std::string& encoding) OVERRIDE;
318 virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11319 virtual void Close(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10320 virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11321 virtual void SwappedOut(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]89793072012-07-23 22:25:29322 virtual void DidStartLoading(
323 content::RenderViewHost* render_view_host) OVERRIDE;
324 virtual void DidStopLoading(
325 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10326 virtual void DidCancelLoading() OVERRIDE;
327 virtual void DidChangeLoadProgress(double progress) OVERRIDE;
[email protected]87717d0e2012-04-26 02:58:43328 virtual void DocumentAvailableInMainFrame(
329 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10330 virtual void DocumentOnLoadCompletedInMainFrame(
[email protected]eaabba22012-03-07 15:02:11331 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10332 int32 page_id) OVERRIDE;
[email protected]196159d2012-05-04 17:26:54333 virtual void RequestOpenURL(content::RenderViewHost* rvh,
334 const GURL& url,
[email protected]445e1042011-12-03 21:03:15335 const content::Referrer& referrer,
[email protected]952a68e2011-11-17 00:36:10336 WindowOpenDisposition disposition,
337 int64 source_frame_id) OVERRIDE;
[email protected]4ad5d77d2011-12-03 02:00:48338 virtual void RequestTransferURL(
339 const GURL& url,
[email protected]bce1f1c2011-12-05 15:11:58340 const content::Referrer& referrer,
[email protected]4ad5d77d2011-12-03 02:00:48341 WindowOpenDisposition disposition,
342 int64 source_frame_id,
[email protected]e5d549d2011-12-28 01:29:20343 const content::GlobalRequestID& transferred_global_request_id) OVERRIDE;
[email protected]e1c3a552012-05-04 20:51:32344 virtual void RouteCloseEvent(content::RenderViewHost* rvh) OVERRIDE;
[email protected]f546640b2012-05-15 00:03:49345 virtual void RouteMessageEvent(
346 content::RenderViewHost* rvh,
347 const ViewMsg_PostMessage_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11348 virtual void RunJavaScriptMessage(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10349 const string16& message,
350 const string16& default_prompt,
351 const GURL& frame_url,
[email protected]be2510c02012-05-28 14:52:14352 content::JavaScriptMessageType type,
[email protected]952a68e2011-11-17 00:36:10353 IPC::Message* reply_msg,
354 bool* did_suppress_message) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11355 virtual void RunBeforeUnloadConfirm(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10356 const string16& message,
[email protected]3b3301f62012-02-29 04:32:32357 bool is_reload,
[email protected]952a68e2011-11-17 00:36:10358 IPC::Message* reply_msg) OVERRIDE;
[email protected]a796f202012-05-30 14:14:25359 virtual bool AddMessageToConsole(int32 level,
360 const string16& message,
361 int32 line_no,
362 const string16& source_id) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10363 virtual content::RendererPreferences GetRendererPrefs(
364 content::BrowserContext* browser_context) const OVERRIDE;
[email protected]6717bf272012-05-11 23:31:25365 virtual webkit_glue::WebPreferences GetWebkitPrefs() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10366 virtual void OnUserGesture() OVERRIDE;
367 virtual void OnIgnoredUIEvent() OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11368 virtual void RendererUnresponsive(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10369 bool is_during_unload) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11370 virtual void RendererResponsive(
371 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10372 virtual void LoadStateChanged(const GURL& url,
373 const net::LoadStateWithParam& load_state,
374 uint64 upload_position,
375 uint64 upload_size) OVERRIDE;
376 virtual void WorkerCrashed() OVERRIDE;
377 virtual void Activate() OVERRIDE;
378 virtual void Deactivate() OVERRIDE;
379 virtual void LostCapture() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10380 virtual void HandleMouseDown() OVERRIDE;
381 virtual void HandleMouseUp() OVERRIDE;
[email protected]590a634e2012-07-19 16:38:23382 virtual void HandlePointerActivate() OVERRIDE;
383 virtual void HandleGestureBegin() OVERRIDE;
384 virtual void HandleGestureEnd() OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38385 virtual void RunFileChooser(
[email protected]eaabba22012-03-07 15:02:11386 content::RenderViewHost* render_view_host,
[email protected]8caadeb2011-11-22 02:45:23387 const content::FileChooserParams& params) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10388 virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
389 virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
390 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
[email protected]61e2b3cc2012-03-02 16:13:34391 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
[email protected]a9c81f02012-06-01 00:15:44392 virtual void RequestToLockMouse(bool user_gesture,
393 bool last_unlocked_by_target) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10394 virtual void LostMouseLock() OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50395 virtual void CreateNewWindow(
396 int route_id,
[email protected]97714c82012-06-06 10:15:13397 const ViewHostMsg_CreateWindow_Params& params,
398 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50399 virtual void CreateNewWidget(int route_id,
400 WebKit::WebPopupType popup_type) OVERRIDE;
401 virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
402 virtual void ShowCreatedWindow(int route_id,
403 WindowOpenDisposition disposition,
404 const gfx::Rect& initial_pos,
405 bool user_gesture) OVERRIDE;
406 virtual void ShowCreatedWidget(int route_id,
407 const gfx::Rect& initial_pos) OVERRIDE;
408 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
409 virtual void ShowContextMenu(
410 const content::ContextMenuParams& params) OVERRIDE;
[email protected]f13b4202012-06-12 23:53:23411 virtual void RequestMediaAccessPermission(
412 const content::MediaStreamRequest* request,
413 const content::MediaResponseCallback& callback) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10414
[email protected]4ca76c02012-05-16 16:19:05415 // RenderWidgetHostDelegate --------------------------------------------------
416
[email protected]b87ee522012-05-18 15:16:54417 virtual bool PreHandleKeyboardEvent(
418 const content::NativeWebKeyboardEvent& event,
419 bool* is_keyboard_shortcut) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05420 virtual void HandleKeyboardEvent(
[email protected]b87ee522012-05-18 15:16:54421 const content::NativeWebKeyboardEvent& event) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05422
[email protected]0bfbf882011-12-22 18:19:27423 // RenderViewHostManager::Delegate -------------------------------------------
424
425 virtual bool CreateRenderViewForRenderManager(
[email protected]14392a52012-05-02 20:28:44426 content::RenderViewHost* render_view_host, int opener_route_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27427 virtual void BeforeUnloadFiredFromRenderManager(
428 bool proceed,
429 bool* proceed_to_fire_unload) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27430 virtual void RenderViewGoneFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11431 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27432 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
433 virtual void NotifySwappedFromRenderManager() OVERRIDE;
[email protected]14392a52012-05-02 20:28:44434 virtual int CreateOpenerRenderViewsForRenderManager(
435 content::SiteInstance* instance) OVERRIDE;
[email protected]d202a7c2012-01-04 07:53:47436 virtual NavigationControllerImpl& GetControllerForRenderManager() OVERRIDE;
[email protected]d2353452012-01-19 19:53:56437 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
[email protected]ad23a092011-12-28 07:02:04438 virtual content::NavigationEntry*
[email protected]0bfbf882011-12-22 18:19:27439 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
440 virtual bool FocusLocationBarByDefault() OVERRIDE;
441 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11442 virtual void CreateViewAndSetSizeForRVH(
443 content::RenderViewHost* rvh) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27444
[email protected]14392a52012-05-02 20:28:44445 // content::NotificationObserver ---------------------------------------------
446
447 virtual void Observe(int type,
448 const content::NotificationSource& source,
449 const content::NotificationDetails& details) OVERRIDE;
450
[email protected]553602e12011-04-05 17:01:18451
[email protected]0dd3a0ab2011-02-18 08:17:44452 private:
[email protected]d202a7c2012-01-04 07:53:47453 friend class NavigationControllerImpl;
[email protected]d1198fd2012-08-13 22:50:19454 friend class content::WebContentsObserver;
455 friend class content::WebContents; // To implement factory methods.
[email protected]0dd3a0ab2011-02-18 08:17:44456
[email protected]2db9bd72012-04-13 20:20:56457 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
458 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
459 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
460 CrossSiteCantPreemptAfterUnload);
[email protected]0dd3a0ab2011-02-18 08:17:44461 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
462 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
463 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
464
[email protected]cadaec52012-02-08 21:53:13465 // So InterstitialPageImpl can access SetIsLoading.
466 friend class InterstitialPageImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44467
[email protected]80e776ae2012-03-23 16:17:20468 // TODO(brettw) TestWebContents shouldn't exist!
469 friend class content::TestWebContents;
[email protected]0dd3a0ab2011-02-18 08:17:44470
[email protected]d1198fd2012-08-13 22:50:19471 // See WebContents::Create for a description of these parameters.
472 WebContentsImpl(content::BrowserContext* browser_context,
473 WebContentsImpl* opener);
474
475 // Add and remove observers for page navigation notifications. Adding or
476 // removing multiple times has no effect. The order in which notifications
477 // are sent to observers is undefined. Clients must be sure to remove the
478 // observer before they go away.
479 void AddObserver(content::WebContentsObserver* observer);
480 void RemoveObserver(content::WebContentsObserver* observer);
481
[email protected]14392a52012-05-02 20:28:44482 // Clears this tab's opener if it has been closed.
483 void OnWebContentsDestroyed(content::WebContents* web_contents);
484
[email protected]51da7e32012-01-30 19:24:52485 // Callback function when showing JS dialogs.
[email protected]eaabba22012-03-07 15:02:11486 void OnDialogClosed(content::RenderViewHost* rvh,
[email protected]51da7e32012-01-30 19:24:52487 IPC::Message* reply_msg,
488 bool success,
489 const string16& user_input);
490
[email protected]d0759f492012-04-19 22:50:50491 // IPC message handlers.
[email protected]3a3b75a2012-06-01 08:38:36492 void OnRegisterIntentService(const webkit_glue::WebIntentServiceData& data,
493 bool user_gesture);
[email protected]678105012011-12-09 04:01:21494 void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
[email protected]63c239322011-10-31 23:56:30495 int intent_id);
[email protected]0dd3a0ab2011-02-18 08:17:44496 void OnDidLoadResourceFromMemoryCache(const GURL& url,
[email protected]70435962011-08-02 20:13:28497 const std::string& security_info,
498 const std::string& http_request,
[email protected]6d6cfb3a2012-05-23 22:53:18499 const std::string& mime_type,
[email protected]70435962011-08-02 20:13:28500 ResourceType::Type resource_type);
[email protected]0dd3a0ab2011-02-18 08:17:44501 void OnDidDisplayInsecureContent();
502 void OnDidRunInsecureContent(const std::string& security_origin,
503 const GURL& target_url);
504 void OnDocumentLoadedInFrame(int64 frame_id);
[email protected]1a55c5be2011-11-29 11:36:31505 void OnDidFinishLoad(int64 frame_id,
506 const GURL& validated_url,
507 bool is_main_frame);
508 void OnDidFailLoadWithError(int64 frame_id,
509 const GURL& validated_url,
510 bool is_main_frame,
511 int error_code,
512 const string16& error_description);
[email protected]0dd3a0ab2011-02-18 08:17:44513 void OnUpdateContentRestrictions(int restrictions);
[email protected]0dd3a0ab2011-02-18 08:17:44514 void OnGoToEntryAtOffset(int offset);
[email protected]216813952011-05-19 22:21:26515 void OnUpdateZoomLimits(int minimum_percent,
516 int maximum_percent,
517 bool remember);
[email protected]20b433a2012-05-15 21:23:46518 void OnSaveURL(const GURL& url, const content::Referrer& referrer);
[email protected]3a29a6e2011-08-24 18:26:21519 void OnEnumerateDirectory(int request_id, const FilePath& path);
[email protected]7d189022011-08-25 22:54:20520 void OnJSOutOfMemory();
[email protected]b7a756d42012-01-23 18:08:17521
[email protected]7d189022011-08-25 22:54:20522 void OnRegisterProtocolHandler(const std::string& protocol,
523 const GURL& url,
[email protected]3a3b75a2012-06-01 08:38:36524 const string16& title,
525 bool user_gesture);
[email protected]b888919c2011-09-02 00:32:16526 void OnFindReply(int request_id, int number_of_matches,
527 const gfx::Rect& selection_rect, int active_match_ordinal,
528 bool final_update);
[email protected]d952a052011-09-06 18:42:45529 void OnCrashedPlugin(const FilePath& plugin_path);
[email protected]7fc4bbb2011-09-08 21:23:10530 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
[email protected]55578b0a2012-04-18 14:31:32531 void OnOpenColorChooser(int color_chooser_id, SkColor color);
[email protected]da8543762012-03-20 08:52:20532 void OnEndColorChooser(int color_chooser_id);
[email protected]55578b0a2012-04-18 14:31:32533 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
[email protected]8be45842012-04-13 19:49:29534 void OnPepperPluginHung(int plugin_child_id,
535 const FilePath& path,
536 bool is_hung);
[email protected]d0759f492012-04-19 22:50:50537 void OnWebUISend(const GURL& source_url,
538 const std::string& name,
539 const base::ListValue& args);
[email protected]0dd3a0ab2011-02-18 08:17:44540
541 // Changes the IsLoading state and notifies delegate as needed
542 // |details| is used to provide details on the load that just finished
543 // (but can be null if not applicable). Can be overridden.
544 void SetIsLoading(bool is_loading,
[email protected]09d31d52012-03-11 22:30:27545 content::LoadNotificationDetails* details);
[email protected]0dd3a0ab2011-02-18 08:17:44546
[email protected]0dd3a0ab2011-02-18 08:17:44547 // Called by derived classes to indicate that we're no longer waiting for a
548 // response. This won't actually update the throbber, but it will get picked
549 // up at the next animation step if the throbber is going.
550 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
551
[email protected]0dd3a0ab2011-02-18 08:17:44552 // Navigation helpers --------------------------------------------------------
553 //
554 // These functions are helpers for Navigate() and DidNavigate().
555
556 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
557 // committed to the navigation controller. Note that the navigation entry is
558 // not provided since it may be invalid/changed after being committed. The
559 // current navigation entry is in the NavigationController at this point.
560 void DidNavigateMainFramePostCommit(
[email protected]8286f51a2011-05-31 17:39:13561 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44562 const ViewHostMsg_FrameNavigate_Params& params);
563 void DidNavigateAnyFramePostCommit(
[email protected]eaabba22012-03-07 15:02:11564 content::RenderViewHost* render_view_host,
[email protected]8286f51a2011-05-31 17:39:13565 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44566 const ViewHostMsg_FrameNavigate_Params& params);
567
[email protected]74ce1ad2011-12-16 21:51:46568 // If our controller was restored, update the max page ID associated with the
569 // given RenderViewHost to be larger than the number of restored entries.
570 // This is called in CreateRenderView before any navigations in the RenderView
571 // have begun, to prevent any races in updating RenderView::next_page_id.
[email protected]eaabba22012-03-07 15:02:11572 void UpdateMaxPageIDIfNecessary(content::RenderViewHost* rvh);
[email protected]0dd3a0ab2011-02-18 08:17:44573
[email protected]0dd3a0ab2011-02-18 08:17:44574 // Saves the given title to the navigation entry and does associated work. It
575 // will update history and the view for the new title, and also synthesize
576 // titles for file URLs that have none (so we require that the URL of the
577 // entry already be set).
578 //
579 // This is used as the backend for state updates, which include a new title,
580 // or the dedicated set title message. It returns true if the new title is
581 // different and was therefore updated.
[email protected]10f417c52011-12-28 21:04:23582 bool UpdateTitleForEntry(content::NavigationEntryImpl* entry,
583 const string16& title);
[email protected]0dd3a0ab2011-02-18 08:17:44584
[email protected]b172aee2012-04-10 17:05:26585 // Causes the WebContentsImpl to navigate in the right renderer to |entry|,
586 // which must be already part of the entries in the navigation controller.
[email protected]0dd3a0ab2011-02-18 08:17:44587 // This does not change the NavigationController state.
[email protected]10f417c52011-12-28 21:04:23588 bool NavigateToEntry(const content::NavigationEntryImpl& entry,
[email protected]71fde352011-12-29 03:29:56589 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44590
[email protected]b172aee2012-04-10 17:05:26591 // Sets the history for this WebContentsImpl to |history_length| entries, and
[email protected]796931a92011-08-10 01:32:14592 // moves the current page_id to the last entry in the list if it's valid.
593 // This is mainly used when a prerendered page is swapped into the current
[email protected]9e1ad4b2011-08-14 16:49:19594 // tab. The method is virtual for testing.
[email protected]b6583592012-01-25 19:52:33595 virtual void SetHistoryLengthAndPrune(
596 const content::SiteInstance* site_instance,
597 int merge_history_length,
598 int32 minimum_page_id);
[email protected]796931a92011-08-10 01:32:14599
[email protected]14392a52012-05-02 20:28:44600 // Recursively creates swapped out RenderViews for this tab's opener chain
601 // (including this tab) in the given SiteInstance, allowing other tabs to send
602 // cross-process JavaScript calls to their opener(s). Returns the route ID of
603 // this tab's RenderView for |instance|.
604 int CreateOpenerRenderViews(content::SiteInstance* instance);
605
[email protected]bafe6cd2012-05-23 23:09:50606 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
607 void CreateNewWidget(int route_id,
608 bool is_fullscreen,
609 WebKit::WebPopupType popup_type);
610
611 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
612 void ShowCreatedWidget(int route_id,
613 bool is_fullscreen,
614 const gfx::Rect& initial_pos);
615
616 // Finds the new RenderWidgetHost and returns it. Note that this can only be
617 // called once as this call also removes it from the internal map.
618 content::RenderWidgetHostView* GetCreatedWidget(int route_id);
619
620 // Finds the new WebContentsImpl by route_id, initializes it for
621 // renderer-initiated creation, and returns it. Note that this can only be
622 // called once as this call also removes it from the internal map.
623 WebContentsImpl* GetCreatedWindow(int route_id);
624
[email protected]0dd3a0ab2011-02-18 08:17:44625 // Misc non-view stuff -------------------------------------------------------
626
627 // Helper functions for sending notifications.
628 void NotifySwapped();
629 void NotifyConnected();
630 void NotifyDisconnected();
631
[email protected]be1f56ab2011-12-22 06:55:31632 void SetEncoding(const std::string& encoding);
633
[email protected]27678b2a2012-02-04 22:09:14634 // Save a URL to the local filesystem.
[email protected]20b433a2012-05-15 21:23:46635 void SaveURL(const GURL& url,
636 const content::Referrer& referrer,
637 bool is_main_frame);
[email protected]27678b2a2012-02-04 22:09:14638
[email protected]eaabba22012-03-07 15:02:11639 content::RenderViewHostImpl* GetRenderViewHostImpl();
[email protected]9f76c1e2012-03-05 15:15:58640
[email protected]7900bfdb2012-05-24 19:31:24641 void GetBrowserPluginEmbedderInfo(content::RenderViewHost* render_view_host,
642 std::string* embedder_channel_name,
643 int* embedder_container_id);
644
[email protected]81898992011-06-14 22:15:00645 // Stores random bits of data for others to associate with this object.
646 // WARNING: this needs to be deleted after NavigationController.
[email protected]45644f62011-11-23 00:58:23647 base::PropertyBag property_bag_;
[email protected]81898992011-06-14 22:15:00648
[email protected]0dd3a0ab2011-02-18 08:17:44649 // Data for core operation ---------------------------------------------------
650
651 // Delegate for notifying our owner about stuff. Not owned by us.
[email protected]674bc592011-12-20 23:00:42652 content::WebContentsDelegate* delegate_;
[email protected]0dd3a0ab2011-02-18 08:17:44653
654 // Handles the back/forward list and loading.
[email protected]d202a7c2012-01-04 07:53:47655 NavigationControllerImpl controller_;
[email protected]0dd3a0ab2011-02-18 08:17:44656
657 // The corresponding view.
[email protected]8643e6d2012-01-18 20:26:10658 scoped_ptr<content::WebContentsView> view_;
[email protected]0dd3a0ab2011-02-18 08:17:44659
[email protected]5a3bdf52012-05-24 15:12:57660 // The view of the RVHD. Usually this is our WebContentsView implementation,
661 // but if an embedder uses a different WebContentsView, they'll need to
662 // provide this.
663 content::RenderViewHostDelegateView* render_view_host_delegate_view_;
664
[email protected]bafe6cd2012-05-23 23:09:50665 // Tracks created WebContentsImpl objects that have not been shown yet. They
666 // are identified by the route ID passed to CreateNewWindow.
667 typedef std::map<int, WebContentsImpl*> PendingContents;
668 PendingContents pending_contents_;
669
670 // These maps hold on to the widgets that we created on behalf of the renderer
671 // that haven't shown yet.
672 typedef std::map<int, content::RenderWidgetHostView*> PendingWidgetViews;
673 PendingWidgetViews pending_widget_views_;
674
[email protected]996042972011-11-08 22:43:59675 // A list of observers notified when page state changes. Weak references.
676 // This MUST be listed above render_manager_ since at destruction time the
677 // latter might cause RenderViewHost's destructor to call us and we might use
678 // the observer list then.
[email protected]d8c660432011-12-22 20:51:25679 ObserverList<content::WebContentsObserver> observers_;
[email protected]996042972011-11-08 22:43:59680
[email protected]14392a52012-05-02 20:28:44681 // The tab that opened this tab, if any. Will be set to null if the opener
682 // is closed.
683 WebContentsImpl* opener_;
684
[email protected]0dd3a0ab2011-02-18 08:17:44685 // Helper classes ------------------------------------------------------------
686
687 // Manages creation and swapping of render views.
688 RenderViewHostManager render_manager_;
689
[email protected]483623eb2011-10-25 09:30:00690 // Manages injecting Java objects into all RenderViewHosts associated with
[email protected]b172aee2012-04-10 17:05:26691 // this WebContentsImpl.
[email protected]483623eb2011-10-25 09:30:00692 scoped_ptr<JavaBridgeDispatcherHostManager>
693 java_bridge_dispatcher_host_manager_;
694
[email protected]dd26779c2012-08-08 01:50:28695 // TODO(fsamuel): Remove this once upstreaming of the new browser plugin
696 // implmentation is complete.
[email protected]172cf712012-05-23 15:07:39697 // Manages the browser plugin instances hosted by this WebContents.
[email protected]dd26779c2012-08-08 01:50:28698 scoped_ptr<content::old::BrowserPluginHost> old_browser_plugin_host_;
[email protected]172cf712012-05-23 15:07:39699
[email protected]c7dd2f62011-07-18 15:57:59700 // SavePackage, lazily created.
701 scoped_refptr<SavePackage> save_package_;
702
[email protected]0dd3a0ab2011-02-18 08:17:44703 // Data for loading state ----------------------------------------------------
704
705 // Indicates whether we're currently loading a resource.
706 bool is_loading_;
707
708 // Indicates if the tab is considered crashed.
709 base::TerminationStatus crashed_status_;
710 int crashed_error_code_;
711
[email protected]ca13a442012-04-17 14:00:12712 // Whether this WebContents is waiting for a first-response for the
[email protected]be1f56ab2011-12-22 06:55:31713 // main resource of the page. This controls whether the throbber state is
714 // "waiting" or "loading."
[email protected]0dd3a0ab2011-02-18 08:17:44715 bool waiting_for_response_;
716
[email protected]74ce1ad2011-12-16 21:51:46717 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
718 // to a given tab and SiteInstance, and must be valid for the lifetime of the
[email protected]b172aee2012-04-10 17:05:26719 // WebContentsImpl.
[email protected]74ce1ad2011-12-16 21:51:46720 std::map<int32, int32> max_page_ids_;
[email protected]0dd3a0ab2011-02-18 08:17:44721
722 // System time at which the current load was started.
723 base::TimeTicks current_load_start_;
724
725 // The current load state and the URL associated with it.
[email protected]9c235f042011-08-10 22:28:21726 net::LoadStateWithParam load_state_;
[email protected]0dd3a0ab2011-02-18 08:17:44727 string16 load_state_host_;
728 // Upload progress, for displaying in the status bar.
729 // Set to zero when there is no significant upload happening.
730 uint64 upload_size_;
731 uint64 upload_position_;
732
733 // Data for current page -----------------------------------------------------
734
[email protected]987fc3a2011-05-26 14:18:09735 // When a title cannot be taken from any entry, this title will be used.
736 string16 page_title_when_no_navigation_entry_;
737
[email protected]0dd3a0ab2011-02-18 08:17:44738 // When a navigation occurs, we record its contents MIME type. It can be
739 // used to check whether we can do something for some special contents.
740 std::string contents_mime_type_;
741
742 // Character encoding.
743 std::string encoding_;
744
[email protected]0dd3a0ab2011-02-18 08:17:44745 // True if this is a secure page which displayed insecure content.
746 bool displayed_insecure_content_;
747
[email protected]0dd3a0ab2011-02-18 08:17:44748 // Data for misc internal state ----------------------------------------------
749
[email protected]ca13a442012-04-17 14:00:12750 // Whether the WebContents is currently being screenshotted.
[email protected]0dd3a0ab2011-02-18 08:17:44751 bool capturing_contents_;
752
753 // See getter above.
754 bool is_being_destroyed_;
755
756 // Indicates whether we should notify about disconnection of this
[email protected]b172aee2012-04-10 17:05:26757 // WebContentsImpl. This is used to ensure disconnection notifications only
[email protected]0dd3a0ab2011-02-18 08:17:44758 // happen if a connection notification has happened and that they happen only
759 // once.
760 bool notify_disconnection_;
761
[email protected]2e5b90c2011-08-16 21:11:55762 // Pointer to the JavaScript dialog creator, lazily assigned. Used because the
[email protected]b172aee2012-04-10 17:05:26763 // delegate of this WebContentsImpl is nulled before its destructor is called.
[email protected]2e5b90c2011-08-16 21:11:55764 content::JavaScriptDialogCreator* dialog_creator_;
765
[email protected]0dd3a0ab2011-02-18 08:17:44766#if defined(OS_WIN)
767 // Handle to an event that's set when the page is showing a message box (or
768 // equivalent constrained window). Plugin processes check this to know if
769 // they should pump messages then.
770 base::win::ScopedHandle message_box_active_;
771#endif
772
[email protected]0dd3a0ab2011-02-18 08:17:44773 // Set to true when there is an active "before unload" dialog. When true,
774 // we've forced the throbber to start in Navigate, and we need to remember to
775 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
776 bool is_showing_before_unload_dialog_;
777
[email protected]0dd3a0ab2011-02-18 08:17:44778 // Settings that get passed to the renderer process.
[email protected]daf82f82011-10-31 22:35:31779 content::RendererPreferences renderer_preferences_;
[email protected]0dd3a0ab2011-02-18 08:17:44780
781 // If this tab was created from a renderer using window.open, this will be
782 // non-NULL and represent the WebUI of the opening renderer.
[email protected]01ec4ec2012-01-18 04:13:47783 content::WebUI::TypeID opener_web_ui_type_;
[email protected]0dd3a0ab2011-02-18 08:17:44784
785 // The time that we started to create the new tab page.
786 base::TimeTicks new_tab_start_time_;
787
[email protected]3bbacc5b2012-04-17 17:46:15788 // The time that we started to close this WebContents.
789 base::TimeTicks close_start_time_;
[email protected]0dd3a0ab2011-02-18 08:17:44790
791 // The time that this tab was last selected.
792 base::TimeTicks last_selected_time_;
793
[email protected]0dd3a0ab2011-02-18 08:17:44794 // See description above setter.
795 bool closed_by_user_gesture_;
796
797 // Minimum/maximum zoom percent.
798 int minimum_zoom_percent_;
799 int maximum_zoom_percent_;
800 // If true, the default zoom limits have been overriden for this tab, in which
801 // case we don't want saved settings to apply to it and we don't want to
802 // remember it.
803 bool temporary_zoom_settings_;
804
[email protected]bcd2815602012-01-14 18:17:23805 // The intrinsic size of the page.
806 gfx::Size preferred_size_;
807
[email protected]0dd3a0ab2011-02-18 08:17:44808 // Content restrictions, used to disable print/copy etc based on content's
809 // (full-page plugins for now only) permissions.
810 int content_restrictions_;
811
[email protected]da8543762012-03-20 08:52:20812 // Color chooser that was opened by this tab.
813 content::ColorChooser* color_chooser_;
814
[email protected]f53a9f872012-05-24 02:07:06815 // This must be at the end, or else we might get notifications and use other
816 // member variables that are gone.
817 content::NotificationRegistrar registrar_;
818
[email protected]7bb761892012-07-20 09:32:47819 // Used during IPC message dispatching so that the handlers can get a pointer
820 // to the RVH through which the message was received.
821 content::RenderViewHost* message_source_;
822
[email protected]b172aee2012-04-10 17:05:26823 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
[email protected]0dd3a0ab2011-02-18 08:17:44824};
825
[email protected]93ddb3c2012-04-11 21:44:29826#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_