blob: 4a468ed5b250ba36c44ddf0a26dee0b05bf00cbd [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]14cf0f12012-06-18 17:15:5716#include "content/browser/browser_plugin/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]a81343d232011-12-27 07:39:2077 // See WebContents::Create for a description of these parameters.
[email protected]b172aee2012-04-10 17:05:2678 WebContentsImpl(content::BrowserContext* browser_context,
79 content::SiteInstance* site_instance,
80 int routing_id,
81 const WebContentsImpl* base_web_contents,
[email protected]14392a52012-05-02 20:28:4482 WebContentsImpl* opener,
[email protected]b172aee2012-04-10 17:05:2683 SessionStorageNamespaceImpl* session_storage_namespace);
84 virtual ~WebContentsImpl();
[email protected]0dd3a0ab2011-02-18 08:17:4485
[email protected]64d69de42012-02-06 00:19:5486 // Returns the content specific prefs for the given RVH.
[email protected]6717bf272012-05-11 23:31:2587 static webkit_glue::WebPreferences GetWebkitPrefs(
[email protected]eaabba22012-03-07 15:02:1188 content::RenderViewHost* rvh, const GURL& url);
[email protected]64d69de42012-02-06 00:19:5489
[email protected]c7dd2f62011-07-18 15:57:5990 // Returns the SavePackage which manages the page saving job. May be NULL.
91 SavePackage* save_package() const { return save_package_.get(); }
92
[email protected]b172aee2012-04-10 17:05:2693 // Updates the max page ID for the current SiteInstance in this
94 // WebContentsImpl to be at least |page_id|.
[email protected]0dd3a0ab2011-02-18 08:17:4495 void UpdateMaxPageID(int32 page_id);
96
[email protected]b172aee2012-04-10 17:05:2697 // Updates the max page ID for the given SiteInstance in this WebContentsImpl
[email protected]74ce1ad2011-12-16 21:51:4698 // to be at least |page_id|.
[email protected]b6583592012-01-25 19:52:3399 void UpdateMaxPageIDForSiteInstance(content::SiteInstance* site_instance,
[email protected]74ce1ad2011-12-16 21:51:46100 int32 page_id);
101
[email protected]91854cd2012-01-10 19:43:57102 // Copy the current map of SiteInstance ID to max page ID from another tab.
103 // This is necessary when this tab adopts the NavigationEntries from
[email protected]b172aee2012-04-10 17:05:26104 // |web_contents|.
105 void CopyMaxPageIDsFrom(WebContentsImpl* web_contents);
[email protected]91854cd2012-01-10 19:43:57106
[email protected]b172aee2012-04-10 17:05:26107 // Called by the NavigationController to cause the WebContentsImpl to navigate
108 // to the current pending entry. The NavigationController should be called
109 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
[email protected]9a7e68c2011-05-26 17:35:50110 // The callbacks can be inside of this function, or at some future time.
[email protected]0dd3a0ab2011-02-18 08:17:44111 //
112 // The entry has a PageID of -1 if newly created (corresponding to navigation
113 // to a new URL).
114 //
115 // If this method returns false, then the navigation is discarded (equivalent
116 // to calling DiscardPendingEntry on the NavigationController).
[email protected]0bfbf882011-12-22 18:19:27117 bool NavigateToPendingEntry(
[email protected]71fde352011-12-29 03:29:56118 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44119
[email protected]ba45bfd2012-05-22 21:51:44120 // Called by InterstitialPageImpl when it creates a RenderViewHost.
121 void RenderViewForInterstitialPageCreated(
122 content::RenderViewHost* render_view_host);
123
[email protected]0dd3a0ab2011-02-18 08:17:44124 // Sets the passed passed interstitial as the currently showing interstitial.
125 // |interstitial_page| should be non NULL (use the remove_interstitial_page
126 // method to unset the interstitial) and no interstitial page should be set
127 // when there is already a non NULL interstitial page set.
[email protected]cadaec52012-02-08 21:53:13128 void set_interstitial_page(InterstitialPageImpl* interstitial_page) {
[email protected]0dd3a0ab2011-02-18 08:17:44129 render_manager_.set_interstitial_page(interstitial_page);
130 }
131
132 // Unsets the currently showing interstitial.
133 void remove_interstitial_page() {
134 render_manager_.remove_interstitial_page();
135 }
136
[email protected]01ec4ec2012-01-18 04:13:47137 void set_opener_web_ui_type(content::WebUI::TypeID opener_web_ui_type) {
[email protected]0dd3a0ab2011-02-18 08:17:44138 opener_web_ui_type_ = opener_web_ui_type;
139 }
140
[email protected]276b37a22011-11-08 20:45:46141 JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const {
142 return java_bridge_dispatcher_host_manager_.get();
143 }
144
[email protected]172cf712012-05-23 15:07:39145 content::BrowserPluginHost* browser_plugin_host() const {
146 return browser_plugin_host_.get();
147 }
148
[email protected]cdcb1dee2012-01-04 00:46:20149 // Like GetController from WebContents, but returns the concrete object.
[email protected]d202a7c2012-01-04 07:53:47150 NavigationControllerImpl& GetControllerImpl();
[email protected]cdcb1dee2012-01-04 00:46:20151
[email protected]765187182012-01-11 23:59:28152 // Expose the render manager for testing.
153 RenderViewHostManager* GetRenderManagerForTesting();
154
[email protected]58f5d562011-12-20 17:13:03155 // content::WebContents ------------------------------------------------------
[email protected]6934a702011-12-20 00:04:51156 virtual const base::PropertyBag* GetPropertyBag() const OVERRIDE;
157 virtual base::PropertyBag* GetPropertyBag() OVERRIDE;
[email protected]674bc592011-12-20 23:00:42158 virtual content::WebContentsDelegate* GetDelegate() OVERRIDE;
159 virtual void SetDelegate(content::WebContentsDelegate* delegate) OVERRIDE;
[email protected]cdcb1dee2012-01-04 00:46:20160 virtual content::NavigationController& GetController() OVERRIDE;
161 virtual const content::NavigationController& GetController() const OVERRIDE;
[email protected]627e0512011-12-21 22:55:30162 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
[email protected]f5fa20e2011-12-21 22:35:56163 virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11164 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE;
[email protected]5626b0892012-02-20 14:46:58165 virtual content::RenderWidgetHostView*
166 GetRenderWidgetHostView() const OVERRIDE;
[email protected]8643e6d2012-01-18 20:26:10167 virtual content::WebContentsView* GetView() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47168 virtual content::WebUI* CreateWebUI(const GURL& url) OVERRIDE;
169 virtual content::WebUI* GetWebUI() const OVERRIDE;
170 virtual content::WebUI* GetCommittedWebUI() const OVERRIDE;
[email protected]86ef6a392012-05-11 22:03:11171 virtual void SetUserAgentOverride(const std::string& override) OVERRIDE;
172 virtual const std::string& GetUserAgentOverride() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31173 virtual const string16& GetTitle() const OVERRIDE;
174 virtual int32 GetMaxPageID() OVERRIDE;
175 virtual int32 GetMaxPageIDForSiteInstance(
[email protected]b6583592012-01-25 19:52:33176 content::SiteInstance* site_instance) OVERRIDE;
177 virtual content::SiteInstance* GetSiteInstance() const OVERRIDE;
178 virtual content::SiteInstance* GetPendingSiteInstance() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31179 virtual bool IsLoading() const OVERRIDE;
180 virtual bool IsWaitingForResponse() const OVERRIDE;
181 virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE;
182 virtual const string16& GetLoadStateHost() const OVERRIDE;
183 virtual uint64 GetUploadSize() const OVERRIDE;
184 virtual uint64 GetUploadPosition() const OVERRIDE;
185 virtual const std::string& GetEncoding() const OVERRIDE;
186 virtual bool DisplayedInsecureContent() const OVERRIDE;
187 virtual void SetCapturingContents(bool cap) OVERRIDE;
188 virtual bool IsCrashed() const OVERRIDE;
189 virtual void SetIsCrashed(base::TerminationStatus status,
190 int error_code) OVERRIDE;
191 virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE;
192 virtual bool IsBeingDestroyed() const OVERRIDE;
193 virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31194 virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE;
[email protected]9e2e4632012-07-27 16:38:41195 virtual void WasShown() OVERRIDE;
[email protected]3e324142012-06-25 18:26:33196 virtual void WasHidden() OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31197 virtual bool NeedToFireBeforeUnload() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27198 virtual void Stop() OVERRIDE;
[email protected]d9083482012-01-06 00:38:46199 virtual content::WebContents* Clone() OVERRIDE;
[email protected]2a6bc3e2011-12-28 23:51:33200 virtual void AddNewContents(content::WebContents* new_contents,
[email protected]0bfbf882011-12-22 18:19:27201 WindowOpenDisposition disposition,
202 const gfx::Rect& initial_pos,
203 bool user_gesture) OVERRIDE;
204 virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
205 virtual gfx::NativeView GetNativeView() const OVERRIDE;
206 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE;
207 virtual void Focus() OVERRIDE;
208 virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE;
209 virtual bool ShowingInterstitialPage() const OVERRIDE;
[email protected]cadaec52012-02-08 21:53:13210 virtual content::InterstitialPage* GetInterstitialPage() const OVERRIDE;
[email protected]a53209b2012-01-20 16:48:16211 virtual bool IsSavable() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27212 virtual void OnSavePage() OVERRIDE;
213 virtual bool SavePage(const FilePath& main_file,
214 const FilePath& dir_path,
[email protected]a53209b2012-01-20 16:48:16215 content::SavePageType save_type) OVERRIDE;
[email protected]aa4f3972012-03-01 18:12:12216 virtual void GenerateMHTML(
217 const FilePath& file,
218 const base::Callback<void(const FilePath&, int64)>& callback) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27219 virtual bool IsActiveEntry(int32 page_id) OVERRIDE;
220
221 virtual const std::string& GetContentsMimeType() const OVERRIDE;
222 virtual bool WillNotifyDisconnection() const OVERRIDE;
223 virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE;
224 virtual void ResetOverrideEncoding() OVERRIDE;
225 virtual content::RendererPreferences* GetMutableRendererPrefs() OVERRIDE;
226 virtual void SetNewTabStartTime(const base::TimeTicks& time) OVERRIDE;
227 virtual base::TimeTicks GetNewTabStartTime() const OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47228 virtual void Close() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27229 virtual void OnCloseStarted() OVERRIDE;
230 virtual bool ShouldAcceptDragAndDrop() const OVERRIDE;
231 virtual void SystemDragEnded() OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47232 virtual void UserGestureDone() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27233 virtual void SetClosedByUserGesture(bool value) OVERRIDE;
234 virtual bool GetClosedByUserGesture() const OVERRIDE;
235 virtual double GetZoomLevel() const OVERRIDE;
236 virtual int GetZoomPercent(bool* enable_increment,
237 bool* enable_decrement) OVERRIDE;
238 virtual void ViewSource() OVERRIDE;
239 virtual void ViewFrameSource(const GURL& url,
240 const std::string& content_state) OVERRIDE;
241 virtual int GetMinimumZoomPercent() const OVERRIDE;
242 virtual int GetMaximumZoomPercent() const OVERRIDE;
[email protected]bcd2815602012-01-14 18:17:23243 virtual gfx::Size GetPreferredSize() const OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27244 virtual int GetContentRestrictions() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47245 virtual content::WebUI::TypeID GetWebUITypeForCurrentState() OVERRIDE;
246 virtual content::WebUI* GetWebUIForCurrentState() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27247 virtual bool GotResponseToLockMouseRequest(bool allowed) OVERRIDE;
[email protected]a0358d72012-03-09 14:06:50248 virtual bool HasOpener() const OVERRIDE;
[email protected]da8543762012-03-20 08:52:20249 virtual void DidChooseColorInColorChooser(int color_chooser_id,
[email protected]55578b0a2012-04-18 14:31:32250 SkColor color) OVERRIDE;
[email protected]da8543762012-03-20 08:52:20251 virtual void DidEndColorChooser(int color_chooser_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27252
253 // Implementation of PageNavigator.
[email protected]e5d549d2011-12-28 01:29:20254 virtual content::WebContents* OpenURL(
255 const content::OpenURLParams& params) OVERRIDE;
[email protected]151a63d2011-12-20 22:32:52256
[email protected]952a68e2011-11-17 00:36:10257 // RenderViewHostDelegate ----------------------------------------------------
258
[email protected]5a3bdf52012-05-24 15:12:57259 virtual content::RenderViewHostDelegateView* GetDelegateView() OVERRIDE;
[email protected]b0b67cf2012-01-18 21:59:57260 virtual content::RenderViewHostDelegate::RendererManagement*
[email protected]952a68e2011-11-17 00:36:10261 GetRendererManagementDelegate() OVERRIDE;
[email protected]7bb761892012-07-20 09:32:47262 virtual bool OnMessageReceived(content::RenderViewHost* render_view_host,
263 const IPC::Message& message) OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31264 virtual const GURL& GetURL() const OVERRIDE;
[email protected]768c5472011-12-26 19:06:17265 virtual WebContents* GetAsWebContents() OVERRIDE;
[email protected]b7a756d42012-01-23 18:08:17266 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11267 virtual void RenderViewCreated(
268 content::RenderViewHost* render_view_host) OVERRIDE;
269 virtual void RenderViewReady(
270 content::RenderViewHost* render_view_host) OVERRIDE;
271 virtual void RenderViewGone(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10272 base::TerminationStatus status,
273 int error_code) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11274 virtual void RenderViewDeleted(
275 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57276 virtual void DidStartProvisionalLoadForFrame(
277 content::RenderViewHost* render_view_host,
278 int64 frame_id,
279 bool main_frame,
280 const GURL& opener_url,
281 const GURL& url) OVERRIDE;
[email protected]400992b2012-06-14 00:03:54282 virtual void DidRedirectProvisionalLoad(
283 content::RenderViewHost* render_view_host,
284 int32 page_id,
285 const GURL& opener_url,
286 const GURL& source_url,
287 const GURL& target_url) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57288 virtual void DidFailProvisionalLoadWithError(
289 content::RenderViewHost* render_view_host,
290 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params)
291 OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10292 virtual void DidNavigate(
[email protected]eaabba22012-03-07 15:02:11293 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10294 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11295 virtual void UpdateState(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10296 int32 page_id,
297 const std::string& state) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11298 virtual void UpdateTitle(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10299 int32 page_id,
300 const string16& title,
301 base::i18n::TextDirection title_direction) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11302 virtual void UpdateEncoding(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10303 const std::string& encoding) OVERRIDE;
304 virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11305 virtual void Close(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10306 virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11307 virtual void SwappedOut(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]89793072012-07-23 22:25:29308 virtual void DidStartLoading(
309 content::RenderViewHost* render_view_host) OVERRIDE;
310 virtual void DidStopLoading(
311 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10312 virtual void DidCancelLoading() OVERRIDE;
313 virtual void DidChangeLoadProgress(double progress) OVERRIDE;
[email protected]87717d0e2012-04-26 02:58:43314 virtual void DocumentAvailableInMainFrame(
315 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10316 virtual void DocumentOnLoadCompletedInMainFrame(
[email protected]eaabba22012-03-07 15:02:11317 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10318 int32 page_id) OVERRIDE;
[email protected]196159d2012-05-04 17:26:54319 virtual void RequestOpenURL(content::RenderViewHost* rvh,
320 const GURL& url,
[email protected]445e1042011-12-03 21:03:15321 const content::Referrer& referrer,
[email protected]952a68e2011-11-17 00:36:10322 WindowOpenDisposition disposition,
323 int64 source_frame_id) OVERRIDE;
[email protected]4ad5d77d2011-12-03 02:00:48324 virtual void RequestTransferURL(
325 const GURL& url,
[email protected]bce1f1c2011-12-05 15:11:58326 const content::Referrer& referrer,
[email protected]4ad5d77d2011-12-03 02:00:48327 WindowOpenDisposition disposition,
328 int64 source_frame_id,
[email protected]e5d549d2011-12-28 01:29:20329 const content::GlobalRequestID& transferred_global_request_id) OVERRIDE;
[email protected]e1c3a552012-05-04 20:51:32330 virtual void RouteCloseEvent(content::RenderViewHost* rvh) OVERRIDE;
[email protected]f546640b2012-05-15 00:03:49331 virtual void RouteMessageEvent(
332 content::RenderViewHost* rvh,
333 const ViewMsg_PostMessage_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11334 virtual void RunJavaScriptMessage(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10335 const string16& message,
336 const string16& default_prompt,
337 const GURL& frame_url,
[email protected]be2510c02012-05-28 14:52:14338 content::JavaScriptMessageType type,
[email protected]952a68e2011-11-17 00:36:10339 IPC::Message* reply_msg,
340 bool* did_suppress_message) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11341 virtual void RunBeforeUnloadConfirm(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10342 const string16& message,
[email protected]3b3301f62012-02-29 04:32:32343 bool is_reload,
[email protected]952a68e2011-11-17 00:36:10344 IPC::Message* reply_msg) OVERRIDE;
[email protected]a796f202012-05-30 14:14:25345 virtual bool AddMessageToConsole(int32 level,
346 const string16& message,
347 int32 line_no,
348 const string16& source_id) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10349 virtual content::RendererPreferences GetRendererPrefs(
350 content::BrowserContext* browser_context) const OVERRIDE;
[email protected]6717bf272012-05-11 23:31:25351 virtual webkit_glue::WebPreferences GetWebkitPrefs() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10352 virtual void OnUserGesture() OVERRIDE;
353 virtual void OnIgnoredUIEvent() OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11354 virtual void RendererUnresponsive(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10355 bool is_during_unload) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11356 virtual void RendererResponsive(
357 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10358 virtual void LoadStateChanged(const GURL& url,
359 const net::LoadStateWithParam& load_state,
360 uint64 upload_position,
361 uint64 upload_size) OVERRIDE;
362 virtual void WorkerCrashed() OVERRIDE;
363 virtual void Activate() OVERRIDE;
364 virtual void Deactivate() OVERRIDE;
365 virtual void LostCapture() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10366 virtual void HandleMouseDown() OVERRIDE;
367 virtual void HandleMouseUp() OVERRIDE;
[email protected]590a634e2012-07-19 16:38:23368 virtual void HandlePointerActivate() OVERRIDE;
369 virtual void HandleGestureBegin() OVERRIDE;
370 virtual void HandleGestureEnd() OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38371 virtual void RunFileChooser(
[email protected]eaabba22012-03-07 15:02:11372 content::RenderViewHost* render_view_host,
[email protected]8caadeb2011-11-22 02:45:23373 const content::FileChooserParams& params) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10374 virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
375 virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
376 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
[email protected]61e2b3cc2012-03-02 16:13:34377 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
[email protected]a9c81f02012-06-01 00:15:44378 virtual void RequestToLockMouse(bool user_gesture,
379 bool last_unlocked_by_target) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10380 virtual void LostMouseLock() OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50381 virtual void CreateNewWindow(
382 int route_id,
[email protected]97714c82012-06-06 10:15:13383 const ViewHostMsg_CreateWindow_Params& params,
384 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50385 virtual void CreateNewWidget(int route_id,
386 WebKit::WebPopupType popup_type) OVERRIDE;
387 virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
388 virtual void ShowCreatedWindow(int route_id,
389 WindowOpenDisposition disposition,
390 const gfx::Rect& initial_pos,
391 bool user_gesture) OVERRIDE;
392 virtual void ShowCreatedWidget(int route_id,
393 const gfx::Rect& initial_pos) OVERRIDE;
394 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
395 virtual void ShowContextMenu(
396 const content::ContextMenuParams& params) OVERRIDE;
[email protected]f13b4202012-06-12 23:53:23397 virtual void RequestMediaAccessPermission(
398 const content::MediaStreamRequest* request,
399 const content::MediaResponseCallback& callback) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10400
[email protected]4ca76c02012-05-16 16:19:05401 // RenderWidgetHostDelegate --------------------------------------------------
402
[email protected]b87ee522012-05-18 15:16:54403 virtual bool PreHandleKeyboardEvent(
404 const content::NativeWebKeyboardEvent& event,
405 bool* is_keyboard_shortcut) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05406 virtual void HandleKeyboardEvent(
[email protected]b87ee522012-05-18 15:16:54407 const content::NativeWebKeyboardEvent& event) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05408
[email protected]0bfbf882011-12-22 18:19:27409 // RenderViewHostManager::Delegate -------------------------------------------
410
411 virtual bool CreateRenderViewForRenderManager(
[email protected]14392a52012-05-02 20:28:44412 content::RenderViewHost* render_view_host, int opener_route_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27413 virtual void BeforeUnloadFiredFromRenderManager(
414 bool proceed,
415 bool* proceed_to_fire_unload) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27416 virtual void RenderViewGoneFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11417 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27418 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
419 virtual void NotifySwappedFromRenderManager() OVERRIDE;
[email protected]14392a52012-05-02 20:28:44420 virtual int CreateOpenerRenderViewsForRenderManager(
421 content::SiteInstance* instance) OVERRIDE;
[email protected]d202a7c2012-01-04 07:53:47422 virtual NavigationControllerImpl& GetControllerForRenderManager() OVERRIDE;
[email protected]d2353452012-01-19 19:53:56423 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
[email protected]ad23a092011-12-28 07:02:04424 virtual content::NavigationEntry*
[email protected]0bfbf882011-12-22 18:19:27425 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
426 virtual bool FocusLocationBarByDefault() OVERRIDE;
427 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11428 virtual void CreateViewAndSetSizeForRVH(
429 content::RenderViewHost* rvh) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27430
[email protected]14392a52012-05-02 20:28:44431 // content::NotificationObserver ---------------------------------------------
432
433 virtual void Observe(int type,
434 const content::NotificationSource& source,
435 const content::NotificationDetails& details) OVERRIDE;
436
[email protected]0dd3a0ab2011-02-18 08:17:44437 protected:
[email protected]d8c660432011-12-22 20:51:25438 friend class content::WebContentsObserver;
[email protected]553602e12011-04-05 17:01:18439
440 // Add and remove observers for page navigation notifications. Adding or
441 // removing multiple times has no effect. The order in which notifications
442 // are sent to observers is undefined. Clients must be sure to remove the
443 // observer before they go away.
[email protected]d8c660432011-12-22 20:51:25444 void AddObserver(content::WebContentsObserver* observer);
445 void RemoveObserver(content::WebContentsObserver* observer);
[email protected]553602e12011-04-05 17:01:18446
[email protected]0dd3a0ab2011-02-18 08:17:44447 private:
[email protected]d202a7c2012-01-04 07:53:47448 friend class NavigationControllerImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44449
[email protected]2db9bd72012-04-13 20:20:56450 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
451 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
452 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
453 CrossSiteCantPreemptAfterUnload);
[email protected]0dd3a0ab2011-02-18 08:17:44454 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
455 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
456 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
457
[email protected]cadaec52012-02-08 21:53:13458 // So InterstitialPageImpl can access SetIsLoading.
459 friend class InterstitialPageImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44460
[email protected]80e776ae2012-03-23 16:17:20461 // TODO(brettw) TestWebContents shouldn't exist!
462 friend class content::TestWebContents;
[email protected]0dd3a0ab2011-02-18 08:17:44463
[email protected]14392a52012-05-02 20:28:44464 // Clears this tab's opener if it has been closed.
465 void OnWebContentsDestroyed(content::WebContents* web_contents);
466
[email protected]51da7e32012-01-30 19:24:52467 // Callback function when showing JS dialogs.
[email protected]eaabba22012-03-07 15:02:11468 void OnDialogClosed(content::RenderViewHost* rvh,
[email protected]51da7e32012-01-30 19:24:52469 IPC::Message* reply_msg,
470 bool success,
471 const string16& user_input);
472
[email protected]d0759f492012-04-19 22:50:50473 // IPC message handlers.
[email protected]3a3b75a2012-06-01 08:38:36474 void OnRegisterIntentService(const webkit_glue::WebIntentServiceData& data,
475 bool user_gesture);
[email protected]678105012011-12-09 04:01:21476 void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
[email protected]63c239322011-10-31 23:56:30477 int intent_id);
[email protected]0dd3a0ab2011-02-18 08:17:44478 void OnDidLoadResourceFromMemoryCache(const GURL& url,
[email protected]70435962011-08-02 20:13:28479 const std::string& security_info,
480 const std::string& http_request,
[email protected]6d6cfb3a2012-05-23 22:53:18481 const std::string& mime_type,
[email protected]70435962011-08-02 20:13:28482 ResourceType::Type resource_type);
[email protected]0dd3a0ab2011-02-18 08:17:44483 void OnDidDisplayInsecureContent();
484 void OnDidRunInsecureContent(const std::string& security_origin,
485 const GURL& target_url);
486 void OnDocumentLoadedInFrame(int64 frame_id);
[email protected]1a55c5be2011-11-29 11:36:31487 void OnDidFinishLoad(int64 frame_id,
488 const GURL& validated_url,
489 bool is_main_frame);
490 void OnDidFailLoadWithError(int64 frame_id,
491 const GURL& validated_url,
492 bool is_main_frame,
493 int error_code,
494 const string16& error_description);
[email protected]0dd3a0ab2011-02-18 08:17:44495 void OnUpdateContentRestrictions(int restrictions);
[email protected]0dd3a0ab2011-02-18 08:17:44496 void OnGoToEntryAtOffset(int offset);
[email protected]216813952011-05-19 22:21:26497 void OnUpdateZoomLimits(int minimum_percent,
498 int maximum_percent,
499 bool remember);
[email protected]20b433a2012-05-15 21:23:46500 void OnSaveURL(const GURL& url, const content::Referrer& referrer);
[email protected]3a29a6e2011-08-24 18:26:21501 void OnEnumerateDirectory(int request_id, const FilePath& path);
[email protected]7d189022011-08-25 22:54:20502 void OnJSOutOfMemory();
[email protected]b7a756d42012-01-23 18:08:17503
[email protected]7d189022011-08-25 22:54:20504 void OnRegisterProtocolHandler(const std::string& protocol,
505 const GURL& url,
[email protected]3a3b75a2012-06-01 08:38:36506 const string16& title,
507 bool user_gesture);
[email protected]b888919c2011-09-02 00:32:16508 void OnFindReply(int request_id, int number_of_matches,
509 const gfx::Rect& selection_rect, int active_match_ordinal,
510 bool final_update);
[email protected]d952a052011-09-06 18:42:45511 void OnCrashedPlugin(const FilePath& plugin_path);
[email protected]7fc4bbb2011-09-08 21:23:10512 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
[email protected]55578b0a2012-04-18 14:31:32513 void OnOpenColorChooser(int color_chooser_id, SkColor color);
[email protected]da8543762012-03-20 08:52:20514 void OnEndColorChooser(int color_chooser_id);
[email protected]55578b0a2012-04-18 14:31:32515 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
[email protected]8be45842012-04-13 19:49:29516 void OnPepperPluginHung(int plugin_child_id,
517 const FilePath& path,
518 bool is_hung);
[email protected]d0759f492012-04-19 22:50:50519 void OnWebUISend(const GURL& source_url,
520 const std::string& name,
521 const base::ListValue& args);
[email protected]0dd3a0ab2011-02-18 08:17:44522
523 // Changes the IsLoading state and notifies delegate as needed
524 // |details| is used to provide details on the load that just finished
525 // (but can be null if not applicable). Can be overridden.
526 void SetIsLoading(bool is_loading,
[email protected]09d31d52012-03-11 22:30:27527 content::LoadNotificationDetails* details);
[email protected]0dd3a0ab2011-02-18 08:17:44528
[email protected]0dd3a0ab2011-02-18 08:17:44529 // Called by derived classes to indicate that we're no longer waiting for a
530 // response. This won't actually update the throbber, but it will get picked
531 // up at the next animation step if the throbber is going.
532 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
533
[email protected]0dd3a0ab2011-02-18 08:17:44534 // Navigation helpers --------------------------------------------------------
535 //
536 // These functions are helpers for Navigate() and DidNavigate().
537
538 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
539 // committed to the navigation controller. Note that the navigation entry is
540 // not provided since it may be invalid/changed after being committed. The
541 // current navigation entry is in the NavigationController at this point.
542 void DidNavigateMainFramePostCommit(
[email protected]8286f51a2011-05-31 17:39:13543 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44544 const ViewHostMsg_FrameNavigate_Params& params);
545 void DidNavigateAnyFramePostCommit(
[email protected]eaabba22012-03-07 15:02:11546 content::RenderViewHost* render_view_host,
[email protected]8286f51a2011-05-31 17:39:13547 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44548 const ViewHostMsg_FrameNavigate_Params& params);
549
[email protected]74ce1ad2011-12-16 21:51:46550 // If our controller was restored, update the max page ID associated with the
551 // given RenderViewHost to be larger than the number of restored entries.
552 // This is called in CreateRenderView before any navigations in the RenderView
553 // have begun, to prevent any races in updating RenderView::next_page_id.
[email protected]eaabba22012-03-07 15:02:11554 void UpdateMaxPageIDIfNecessary(content::RenderViewHost* rvh);
[email protected]0dd3a0ab2011-02-18 08:17:44555
[email protected]0dd3a0ab2011-02-18 08:17:44556 // Saves the given title to the navigation entry and does associated work. It
557 // will update history and the view for the new title, and also synthesize
558 // titles for file URLs that have none (so we require that the URL of the
559 // entry already be set).
560 //
561 // This is used as the backend for state updates, which include a new title,
562 // or the dedicated set title message. It returns true if the new title is
563 // different and was therefore updated.
[email protected]10f417c52011-12-28 21:04:23564 bool UpdateTitleForEntry(content::NavigationEntryImpl* entry,
565 const string16& title);
[email protected]0dd3a0ab2011-02-18 08:17:44566
[email protected]b172aee2012-04-10 17:05:26567 // Causes the WebContentsImpl to navigate in the right renderer to |entry|,
568 // which must be already part of the entries in the navigation controller.
[email protected]0dd3a0ab2011-02-18 08:17:44569 // This does not change the NavigationController state.
[email protected]10f417c52011-12-28 21:04:23570 bool NavigateToEntry(const content::NavigationEntryImpl& entry,
[email protected]71fde352011-12-29 03:29:56571 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44572
[email protected]b172aee2012-04-10 17:05:26573 // Sets the history for this WebContentsImpl to |history_length| entries, and
[email protected]796931a92011-08-10 01:32:14574 // moves the current page_id to the last entry in the list if it's valid.
575 // This is mainly used when a prerendered page is swapped into the current
[email protected]9e1ad4b2011-08-14 16:49:19576 // tab. The method is virtual for testing.
[email protected]b6583592012-01-25 19:52:33577 virtual void SetHistoryLengthAndPrune(
578 const content::SiteInstance* site_instance,
579 int merge_history_length,
580 int32 minimum_page_id);
[email protected]796931a92011-08-10 01:32:14581
[email protected]14392a52012-05-02 20:28:44582 // Recursively creates swapped out RenderViews for this tab's opener chain
583 // (including this tab) in the given SiteInstance, allowing other tabs to send
584 // cross-process JavaScript calls to their opener(s). Returns the route ID of
585 // this tab's RenderView for |instance|.
586 int CreateOpenerRenderViews(content::SiteInstance* instance);
587
[email protected]bafe6cd2012-05-23 23:09:50588 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
589 void CreateNewWidget(int route_id,
590 bool is_fullscreen,
591 WebKit::WebPopupType popup_type);
592
593 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
594 void ShowCreatedWidget(int route_id,
595 bool is_fullscreen,
596 const gfx::Rect& initial_pos);
597
598 // Finds the new RenderWidgetHost and returns it. Note that this can only be
599 // called once as this call also removes it from the internal map.
600 content::RenderWidgetHostView* GetCreatedWidget(int route_id);
601
602 // Finds the new WebContentsImpl by route_id, initializes it for
603 // renderer-initiated creation, and returns it. Note that this can only be
604 // called once as this call also removes it from the internal map.
605 WebContentsImpl* GetCreatedWindow(int route_id);
606
[email protected]0dd3a0ab2011-02-18 08:17:44607 // Misc non-view stuff -------------------------------------------------------
608
609 // Helper functions for sending notifications.
610 void NotifySwapped();
611 void NotifyConnected();
612 void NotifyDisconnected();
613
[email protected]be1f56ab2011-12-22 06:55:31614 void SetEncoding(const std::string& encoding);
615
[email protected]27678b2a2012-02-04 22:09:14616 // Save a URL to the local filesystem.
[email protected]20b433a2012-05-15 21:23:46617 void SaveURL(const GURL& url,
618 const content::Referrer& referrer,
619 bool is_main_frame);
[email protected]27678b2a2012-02-04 22:09:14620
[email protected]eaabba22012-03-07 15:02:11621 content::RenderViewHostImpl* GetRenderViewHostImpl();
[email protected]9f76c1e2012-03-05 15:15:58622
[email protected]7900bfdb2012-05-24 19:31:24623 void GetBrowserPluginEmbedderInfo(content::RenderViewHost* render_view_host,
624 std::string* embedder_channel_name,
625 int* embedder_container_id);
626
[email protected]81898992011-06-14 22:15:00627 // Stores random bits of data for others to associate with this object.
628 // WARNING: this needs to be deleted after NavigationController.
[email protected]45644f62011-11-23 00:58:23629 base::PropertyBag property_bag_;
[email protected]81898992011-06-14 22:15:00630
[email protected]0dd3a0ab2011-02-18 08:17:44631 // Data for core operation ---------------------------------------------------
632
633 // Delegate for notifying our owner about stuff. Not owned by us.
[email protected]674bc592011-12-20 23:00:42634 content::WebContentsDelegate* delegate_;
[email protected]0dd3a0ab2011-02-18 08:17:44635
636 // Handles the back/forward list and loading.
[email protected]d202a7c2012-01-04 07:53:47637 NavigationControllerImpl controller_;
[email protected]0dd3a0ab2011-02-18 08:17:44638
639 // The corresponding view.
[email protected]8643e6d2012-01-18 20:26:10640 scoped_ptr<content::WebContentsView> view_;
[email protected]0dd3a0ab2011-02-18 08:17:44641
[email protected]5a3bdf52012-05-24 15:12:57642 // The view of the RVHD. Usually this is our WebContentsView implementation,
643 // but if an embedder uses a different WebContentsView, they'll need to
644 // provide this.
645 content::RenderViewHostDelegateView* render_view_host_delegate_view_;
646
[email protected]bafe6cd2012-05-23 23:09:50647 // Tracks created WebContentsImpl objects that have not been shown yet. They
648 // are identified by the route ID passed to CreateNewWindow.
649 typedef std::map<int, WebContentsImpl*> PendingContents;
650 PendingContents pending_contents_;
651
652 // These maps hold on to the widgets that we created on behalf of the renderer
653 // that haven't shown yet.
654 typedef std::map<int, content::RenderWidgetHostView*> PendingWidgetViews;
655 PendingWidgetViews pending_widget_views_;
656
[email protected]996042972011-11-08 22:43:59657 // A list of observers notified when page state changes. Weak references.
658 // This MUST be listed above render_manager_ since at destruction time the
659 // latter might cause RenderViewHost's destructor to call us and we might use
660 // the observer list then.
[email protected]d8c660432011-12-22 20:51:25661 ObserverList<content::WebContentsObserver> observers_;
[email protected]996042972011-11-08 22:43:59662
[email protected]14392a52012-05-02 20:28:44663 // The tab that opened this tab, if any. Will be set to null if the opener
664 // is closed.
665 WebContentsImpl* opener_;
666
[email protected]0dd3a0ab2011-02-18 08:17:44667 // Helper classes ------------------------------------------------------------
668
669 // Manages creation and swapping of render views.
670 RenderViewHostManager render_manager_;
671
[email protected]483623eb2011-10-25 09:30:00672 // Manages injecting Java objects into all RenderViewHosts associated with
[email protected]b172aee2012-04-10 17:05:26673 // this WebContentsImpl.
[email protected]483623eb2011-10-25 09:30:00674 scoped_ptr<JavaBridgeDispatcherHostManager>
675 java_bridge_dispatcher_host_manager_;
676
[email protected]172cf712012-05-23 15:07:39677 // Manages the browser plugin instances hosted by this WebContents.
678 scoped_ptr<content::BrowserPluginHost> browser_plugin_host_;
679
[email protected]c7dd2f62011-07-18 15:57:59680 // SavePackage, lazily created.
681 scoped_refptr<SavePackage> save_package_;
682
[email protected]0dd3a0ab2011-02-18 08:17:44683 // Data for loading state ----------------------------------------------------
684
685 // Indicates whether we're currently loading a resource.
686 bool is_loading_;
687
688 // Indicates if the tab is considered crashed.
689 base::TerminationStatus crashed_status_;
690 int crashed_error_code_;
691
[email protected]ca13a442012-04-17 14:00:12692 // Whether this WebContents is waiting for a first-response for the
[email protected]be1f56ab2011-12-22 06:55:31693 // main resource of the page. This controls whether the throbber state is
694 // "waiting" or "loading."
[email protected]0dd3a0ab2011-02-18 08:17:44695 bool waiting_for_response_;
696
[email protected]74ce1ad2011-12-16 21:51:46697 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
698 // to a given tab and SiteInstance, and must be valid for the lifetime of the
[email protected]b172aee2012-04-10 17:05:26699 // WebContentsImpl.
[email protected]74ce1ad2011-12-16 21:51:46700 std::map<int32, int32> max_page_ids_;
[email protected]0dd3a0ab2011-02-18 08:17:44701
702 // System time at which the current load was started.
703 base::TimeTicks current_load_start_;
704
705 // The current load state and the URL associated with it.
[email protected]9c235f042011-08-10 22:28:21706 net::LoadStateWithParam load_state_;
[email protected]0dd3a0ab2011-02-18 08:17:44707 string16 load_state_host_;
708 // Upload progress, for displaying in the status bar.
709 // Set to zero when there is no significant upload happening.
710 uint64 upload_size_;
711 uint64 upload_position_;
712
713 // Data for current page -----------------------------------------------------
714
[email protected]987fc3a2011-05-26 14:18:09715 // When a title cannot be taken from any entry, this title will be used.
716 string16 page_title_when_no_navigation_entry_;
717
[email protected]0dd3a0ab2011-02-18 08:17:44718 // When a navigation occurs, we record its contents MIME type. It can be
719 // used to check whether we can do something for some special contents.
720 std::string contents_mime_type_;
721
722 // Character encoding.
723 std::string encoding_;
724
[email protected]0dd3a0ab2011-02-18 08:17:44725 // True if this is a secure page which displayed insecure content.
726 bool displayed_insecure_content_;
727
[email protected]0dd3a0ab2011-02-18 08:17:44728 // Data for misc internal state ----------------------------------------------
729
[email protected]ca13a442012-04-17 14:00:12730 // Whether the WebContents is currently being screenshotted.
[email protected]0dd3a0ab2011-02-18 08:17:44731 bool capturing_contents_;
732
733 // See getter above.
734 bool is_being_destroyed_;
735
736 // Indicates whether we should notify about disconnection of this
[email protected]b172aee2012-04-10 17:05:26737 // WebContentsImpl. This is used to ensure disconnection notifications only
[email protected]0dd3a0ab2011-02-18 08:17:44738 // happen if a connection notification has happened and that they happen only
739 // once.
740 bool notify_disconnection_;
741
[email protected]2e5b90c2011-08-16 21:11:55742 // Pointer to the JavaScript dialog creator, lazily assigned. Used because the
[email protected]b172aee2012-04-10 17:05:26743 // delegate of this WebContentsImpl is nulled before its destructor is called.
[email protected]2e5b90c2011-08-16 21:11:55744 content::JavaScriptDialogCreator* dialog_creator_;
745
[email protected]0dd3a0ab2011-02-18 08:17:44746#if defined(OS_WIN)
747 // Handle to an event that's set when the page is showing a message box (or
748 // equivalent constrained window). Plugin processes check this to know if
749 // they should pump messages then.
750 base::win::ScopedHandle message_box_active_;
751#endif
752
[email protected]0dd3a0ab2011-02-18 08:17:44753 // Set to true when there is an active "before unload" dialog. When true,
754 // we've forced the throbber to start in Navigate, and we need to remember to
755 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
756 bool is_showing_before_unload_dialog_;
757
[email protected]0dd3a0ab2011-02-18 08:17:44758 // Settings that get passed to the renderer process.
[email protected]daf82f82011-10-31 22:35:31759 content::RendererPreferences renderer_preferences_;
[email protected]0dd3a0ab2011-02-18 08:17:44760
761 // If this tab was created from a renderer using window.open, this will be
762 // non-NULL and represent the WebUI of the opening renderer.
[email protected]01ec4ec2012-01-18 04:13:47763 content::WebUI::TypeID opener_web_ui_type_;
[email protected]0dd3a0ab2011-02-18 08:17:44764
765 // The time that we started to create the new tab page.
766 base::TimeTicks new_tab_start_time_;
767
[email protected]3bbacc5b2012-04-17 17:46:15768 // The time that we started to close this WebContents.
769 base::TimeTicks close_start_time_;
[email protected]0dd3a0ab2011-02-18 08:17:44770
771 // The time that this tab was last selected.
772 base::TimeTicks last_selected_time_;
773
[email protected]0dd3a0ab2011-02-18 08:17:44774 // See description above setter.
775 bool closed_by_user_gesture_;
776
777 // Minimum/maximum zoom percent.
778 int minimum_zoom_percent_;
779 int maximum_zoom_percent_;
780 // If true, the default zoom limits have been overriden for this tab, in which
781 // case we don't want saved settings to apply to it and we don't want to
782 // remember it.
783 bool temporary_zoom_settings_;
784
[email protected]bcd2815602012-01-14 18:17:23785 // The intrinsic size of the page.
786 gfx::Size preferred_size_;
787
[email protected]0dd3a0ab2011-02-18 08:17:44788 // Content restrictions, used to disable print/copy etc based on content's
789 // (full-page plugins for now only) permissions.
790 int content_restrictions_;
791
[email protected]da8543762012-03-20 08:52:20792 // Color chooser that was opened by this tab.
793 content::ColorChooser* color_chooser_;
794
[email protected]f53a9f872012-05-24 02:07:06795 // This must be at the end, or else we might get notifications and use other
796 // member variables that are gone.
797 content::NotificationRegistrar registrar_;
798
[email protected]7bb761892012-07-20 09:32:47799 // Used during IPC message dispatching so that the handlers can get a pointer
800 // to the RVH through which the message was received.
801 content::RenderViewHost* message_source_;
802
[email protected]b172aee2012-04-10 17:05:26803 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
[email protected]0dd3a0ab2011-02-18 08:17:44804};
805
[email protected]93ddb3c2012-04-11 21:44:29806#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_