blob: 49959b3842348fa73f789bdd422e14ea2969fcb3 [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]375fa1b2012-05-22 22:05:37195 virtual void WasRestored() 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]be1f56ab2011-12-22 06:55:31262 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
263 virtual const GURL& GetURL() const OVERRIDE;
[email protected]768c5472011-12-26 19:06:17264 virtual WebContents* GetAsWebContents() OVERRIDE;
[email protected]b7a756d42012-01-23 18:08:17265 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11266 virtual void RenderViewCreated(
267 content::RenderViewHost* render_view_host) OVERRIDE;
268 virtual void RenderViewReady(
269 content::RenderViewHost* render_view_host) OVERRIDE;
270 virtual void RenderViewGone(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10271 base::TerminationStatus status,
272 int error_code) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11273 virtual void RenderViewDeleted(
274 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57275 virtual void DidStartProvisionalLoadForFrame(
276 content::RenderViewHost* render_view_host,
277 int64 frame_id,
278 bool main_frame,
279 const GURL& opener_url,
280 const GURL& url) OVERRIDE;
[email protected]400992b2012-06-14 00:03:54281 virtual void DidRedirectProvisionalLoad(
282 content::RenderViewHost* render_view_host,
283 int32 page_id,
284 const GURL& opener_url,
285 const GURL& source_url,
286 const GURL& target_url) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57287 virtual void DidFailProvisionalLoadWithError(
288 content::RenderViewHost* render_view_host,
289 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params)
290 OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10291 virtual void DidNavigate(
[email protected]eaabba22012-03-07 15:02:11292 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10293 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11294 virtual void UpdateState(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10295 int32 page_id,
296 const std::string& state) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11297 virtual void UpdateTitle(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10298 int32 page_id,
299 const string16& title,
300 base::i18n::TextDirection title_direction) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11301 virtual void UpdateEncoding(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10302 const std::string& encoding) OVERRIDE;
303 virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11304 virtual void Close(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10305 virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11306 virtual void SwappedOut(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10307 virtual void DidStartLoading() OVERRIDE;
308 virtual void DidStopLoading() OVERRIDE;
309 virtual void DidCancelLoading() OVERRIDE;
310 virtual void DidChangeLoadProgress(double progress) OVERRIDE;
[email protected]87717d0e2012-04-26 02:58:43311 virtual void DocumentAvailableInMainFrame(
312 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10313 virtual void DocumentOnLoadCompletedInMainFrame(
[email protected]eaabba22012-03-07 15:02:11314 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10315 int32 page_id) OVERRIDE;
[email protected]196159d2012-05-04 17:26:54316 virtual void RequestOpenURL(content::RenderViewHost* rvh,
317 const GURL& url,
[email protected]445e1042011-12-03 21:03:15318 const content::Referrer& referrer,
[email protected]952a68e2011-11-17 00:36:10319 WindowOpenDisposition disposition,
320 int64 source_frame_id) OVERRIDE;
[email protected]4ad5d77d2011-12-03 02:00:48321 virtual void RequestTransferURL(
322 const GURL& url,
[email protected]bce1f1c2011-12-05 15:11:58323 const content::Referrer& referrer,
[email protected]4ad5d77d2011-12-03 02:00:48324 WindowOpenDisposition disposition,
325 int64 source_frame_id,
[email protected]e5d549d2011-12-28 01:29:20326 const content::GlobalRequestID& transferred_global_request_id) OVERRIDE;
[email protected]e1c3a552012-05-04 20:51:32327 virtual void RouteCloseEvent(content::RenderViewHost* rvh) OVERRIDE;
[email protected]f546640b2012-05-15 00:03:49328 virtual void RouteMessageEvent(
329 content::RenderViewHost* rvh,
330 const ViewMsg_PostMessage_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11331 virtual void RunJavaScriptMessage(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10332 const string16& message,
333 const string16& default_prompt,
334 const GURL& frame_url,
[email protected]be2510c02012-05-28 14:52:14335 content::JavaScriptMessageType type,
[email protected]952a68e2011-11-17 00:36:10336 IPC::Message* reply_msg,
337 bool* did_suppress_message) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11338 virtual void RunBeforeUnloadConfirm(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10339 const string16& message,
[email protected]3b3301f62012-02-29 04:32:32340 bool is_reload,
[email protected]952a68e2011-11-17 00:36:10341 IPC::Message* reply_msg) OVERRIDE;
[email protected]a796f202012-05-30 14:14:25342 virtual bool AddMessageToConsole(int32 level,
343 const string16& message,
344 int32 line_no,
345 const string16& source_id) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10346 virtual content::RendererPreferences GetRendererPrefs(
347 content::BrowserContext* browser_context) const OVERRIDE;
[email protected]6717bf272012-05-11 23:31:25348 virtual webkit_glue::WebPreferences GetWebkitPrefs() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10349 virtual void OnUserGesture() OVERRIDE;
350 virtual void OnIgnoredUIEvent() OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11351 virtual void RendererUnresponsive(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10352 bool is_during_unload) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11353 virtual void RendererResponsive(
354 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10355 virtual void LoadStateChanged(const GURL& url,
356 const net::LoadStateWithParam& load_state,
357 uint64 upload_position,
358 uint64 upload_size) OVERRIDE;
359 virtual void WorkerCrashed() OVERRIDE;
360 virtual void Activate() OVERRIDE;
361 virtual void Deactivate() OVERRIDE;
362 virtual void LostCapture() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10363 virtual void HandleMouseDown() OVERRIDE;
364 virtual void HandleMouseUp() OVERRIDE;
[email protected]590a634e2012-07-19 16:38:23365 virtual void HandlePointerActivate() OVERRIDE;
366 virtual void HandleGestureBegin() OVERRIDE;
367 virtual void HandleGestureEnd() OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38368 virtual void RunFileChooser(
[email protected]eaabba22012-03-07 15:02:11369 content::RenderViewHost* render_view_host,
[email protected]8caadeb2011-11-22 02:45:23370 const content::FileChooserParams& params) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10371 virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
372 virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
373 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
[email protected]61e2b3cc2012-03-02 16:13:34374 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
[email protected]a9c81f02012-06-01 00:15:44375 virtual void RequestToLockMouse(bool user_gesture,
376 bool last_unlocked_by_target) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10377 virtual void LostMouseLock() OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50378 virtual void CreateNewWindow(
379 int route_id,
[email protected]97714c82012-06-06 10:15:13380 const ViewHostMsg_CreateWindow_Params& params,
381 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50382 virtual void CreateNewWidget(int route_id,
383 WebKit::WebPopupType popup_type) OVERRIDE;
384 virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
385 virtual void ShowCreatedWindow(int route_id,
386 WindowOpenDisposition disposition,
387 const gfx::Rect& initial_pos,
388 bool user_gesture) OVERRIDE;
389 virtual void ShowCreatedWidget(int route_id,
390 const gfx::Rect& initial_pos) OVERRIDE;
391 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
392 virtual void ShowContextMenu(
393 const content::ContextMenuParams& params) OVERRIDE;
[email protected]f13b4202012-06-12 23:53:23394 virtual void RequestMediaAccessPermission(
395 const content::MediaStreamRequest* request,
396 const content::MediaResponseCallback& callback) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10397
[email protected]4ca76c02012-05-16 16:19:05398 // RenderWidgetHostDelegate --------------------------------------------------
399
[email protected]b87ee522012-05-18 15:16:54400 virtual bool PreHandleKeyboardEvent(
401 const content::NativeWebKeyboardEvent& event,
402 bool* is_keyboard_shortcut) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05403 virtual void HandleKeyboardEvent(
[email protected]b87ee522012-05-18 15:16:54404 const content::NativeWebKeyboardEvent& event) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05405
[email protected]0bfbf882011-12-22 18:19:27406 // RenderViewHostManager::Delegate -------------------------------------------
407
408 virtual bool CreateRenderViewForRenderManager(
[email protected]14392a52012-05-02 20:28:44409 content::RenderViewHost* render_view_host, int opener_route_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27410 virtual void BeforeUnloadFiredFromRenderManager(
411 bool proceed,
412 bool* proceed_to_fire_unload) OVERRIDE;
413 virtual void DidStartLoadingFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11414 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27415 virtual void RenderViewGoneFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11416 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27417 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
418 virtual void NotifySwappedFromRenderManager() OVERRIDE;
[email protected]14392a52012-05-02 20:28:44419 virtual int CreateOpenerRenderViewsForRenderManager(
420 content::SiteInstance* instance) OVERRIDE;
[email protected]d202a7c2012-01-04 07:53:47421 virtual NavigationControllerImpl& GetControllerForRenderManager() OVERRIDE;
[email protected]d2353452012-01-19 19:53:56422 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
[email protected]ad23a092011-12-28 07:02:04423 virtual content::NavigationEntry*
[email protected]0bfbf882011-12-22 18:19:27424 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
425 virtual bool FocusLocationBarByDefault() OVERRIDE;
426 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11427 virtual void CreateViewAndSetSizeForRVH(
428 content::RenderViewHost* rvh) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27429
[email protected]14392a52012-05-02 20:28:44430 // content::NotificationObserver ---------------------------------------------
431
432 virtual void Observe(int type,
433 const content::NotificationSource& source,
434 const content::NotificationDetails& details) OVERRIDE;
435
[email protected]0dd3a0ab2011-02-18 08:17:44436 protected:
[email protected]d8c660432011-12-22 20:51:25437 friend class content::WebContentsObserver;
[email protected]553602e12011-04-05 17:01:18438
439 // Add and remove observers for page navigation notifications. Adding or
440 // removing multiple times has no effect. The order in which notifications
441 // are sent to observers is undefined. Clients must be sure to remove the
442 // observer before they go away.
[email protected]d8c660432011-12-22 20:51:25443 void AddObserver(content::WebContentsObserver* observer);
444 void RemoveObserver(content::WebContentsObserver* observer);
[email protected]553602e12011-04-05 17:01:18445
[email protected]0dd3a0ab2011-02-18 08:17:44446 private:
[email protected]d202a7c2012-01-04 07:53:47447 friend class NavigationControllerImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44448
[email protected]2db9bd72012-04-13 20:20:56449 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
450 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
451 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
452 CrossSiteCantPreemptAfterUnload);
[email protected]0dd3a0ab2011-02-18 08:17:44453 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
454 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
455 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
456
[email protected]cadaec52012-02-08 21:53:13457 // So InterstitialPageImpl can access SetIsLoading.
458 friend class InterstitialPageImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44459
[email protected]80e776ae2012-03-23 16:17:20460 // TODO(brettw) TestWebContents shouldn't exist!
461 friend class content::TestWebContents;
[email protected]0dd3a0ab2011-02-18 08:17:44462
[email protected]14392a52012-05-02 20:28:44463 // Clears this tab's opener if it has been closed.
464 void OnWebContentsDestroyed(content::WebContents* web_contents);
465
[email protected]51da7e32012-01-30 19:24:52466 // Callback function when showing JS dialogs.
[email protected]eaabba22012-03-07 15:02:11467 void OnDialogClosed(content::RenderViewHost* rvh,
[email protected]51da7e32012-01-30 19:24:52468 IPC::Message* reply_msg,
469 bool success,
470 const string16& user_input);
471
[email protected]d0759f492012-04-19 22:50:50472 // IPC message handlers.
[email protected]3a3b75a2012-06-01 08:38:36473 void OnRegisterIntentService(const webkit_glue::WebIntentServiceData& data,
474 bool user_gesture);
[email protected]678105012011-12-09 04:01:21475 void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
[email protected]63c239322011-10-31 23:56:30476 int intent_id);
[email protected]0dd3a0ab2011-02-18 08:17:44477 void OnDidLoadResourceFromMemoryCache(const GURL& url,
[email protected]70435962011-08-02 20:13:28478 const std::string& security_info,
479 const std::string& http_request,
[email protected]6d6cfb3a2012-05-23 22:53:18480 const std::string& mime_type,
[email protected]70435962011-08-02 20:13:28481 ResourceType::Type resource_type);
[email protected]0dd3a0ab2011-02-18 08:17:44482 void OnDidDisplayInsecureContent();
483 void OnDidRunInsecureContent(const std::string& security_origin,
484 const GURL& target_url);
485 void OnDocumentLoadedInFrame(int64 frame_id);
[email protected]1a55c5be2011-11-29 11:36:31486 void OnDidFinishLoad(int64 frame_id,
487 const GURL& validated_url,
488 bool is_main_frame);
489 void OnDidFailLoadWithError(int64 frame_id,
490 const GURL& validated_url,
491 bool is_main_frame,
492 int error_code,
493 const string16& error_description);
[email protected]0dd3a0ab2011-02-18 08:17:44494 void OnUpdateContentRestrictions(int restrictions);
[email protected]0dd3a0ab2011-02-18 08:17:44495 void OnGoToEntryAtOffset(int offset);
[email protected]216813952011-05-19 22:21:26496 void OnUpdateZoomLimits(int minimum_percent,
497 int maximum_percent,
498 bool remember);
[email protected]20b433a2012-05-15 21:23:46499 void OnSaveURL(const GURL& url, const content::Referrer& referrer);
[email protected]3a29a6e2011-08-24 18:26:21500 void OnEnumerateDirectory(int request_id, const FilePath& path);
[email protected]7d189022011-08-25 22:54:20501 void OnJSOutOfMemory();
[email protected]b7a756d42012-01-23 18:08:17502
[email protected]7d189022011-08-25 22:54:20503 void OnRegisterProtocolHandler(const std::string& protocol,
504 const GURL& url,
[email protected]3a3b75a2012-06-01 08:38:36505 const string16& title,
506 bool user_gesture);
[email protected]b888919c2011-09-02 00:32:16507 void OnFindReply(int request_id, int number_of_matches,
508 const gfx::Rect& selection_rect, int active_match_ordinal,
509 bool final_update);
[email protected]d952a052011-09-06 18:42:45510 void OnCrashedPlugin(const FilePath& plugin_path);
[email protected]7fc4bbb2011-09-08 21:23:10511 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
[email protected]55578b0a2012-04-18 14:31:32512 void OnOpenColorChooser(int color_chooser_id, SkColor color);
[email protected]da8543762012-03-20 08:52:20513 void OnEndColorChooser(int color_chooser_id);
[email protected]55578b0a2012-04-18 14:31:32514 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
[email protected]8be45842012-04-13 19:49:29515 void OnPepperPluginHung(int plugin_child_id,
516 const FilePath& path,
517 bool is_hung);
[email protected]d0759f492012-04-19 22:50:50518 void OnWebUISend(const GURL& source_url,
519 const std::string& name,
520 const base::ListValue& args);
[email protected]0dd3a0ab2011-02-18 08:17:44521
522 // Changes the IsLoading state and notifies delegate as needed
523 // |details| is used to provide details on the load that just finished
524 // (but can be null if not applicable). Can be overridden.
525 void SetIsLoading(bool is_loading,
[email protected]09d31d52012-03-11 22:30:27526 content::LoadNotificationDetails* details);
[email protected]0dd3a0ab2011-02-18 08:17:44527
[email protected]0dd3a0ab2011-02-18 08:17:44528 // Called by derived classes to indicate that we're no longer waiting for a
529 // response. This won't actually update the throbber, but it will get picked
530 // up at the next animation step if the throbber is going.
531 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
532
[email protected]0dd3a0ab2011-02-18 08:17:44533 // Navigation helpers --------------------------------------------------------
534 //
535 // These functions are helpers for Navigate() and DidNavigate().
536
537 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
538 // committed to the navigation controller. Note that the navigation entry is
539 // not provided since it may be invalid/changed after being committed. The
540 // current navigation entry is in the NavigationController at this point.
541 void DidNavigateMainFramePostCommit(
[email protected]8286f51a2011-05-31 17:39:13542 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44543 const ViewHostMsg_FrameNavigate_Params& params);
544 void DidNavigateAnyFramePostCommit(
[email protected]eaabba22012-03-07 15:02:11545 content::RenderViewHost* render_view_host,
[email protected]8286f51a2011-05-31 17:39:13546 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44547 const ViewHostMsg_FrameNavigate_Params& params);
548
[email protected]74ce1ad2011-12-16 21:51:46549 // If our controller was restored, update the max page ID associated with the
550 // given RenderViewHost to be larger than the number of restored entries.
551 // This is called in CreateRenderView before any navigations in the RenderView
552 // have begun, to prevent any races in updating RenderView::next_page_id.
[email protected]eaabba22012-03-07 15:02:11553 void UpdateMaxPageIDIfNecessary(content::RenderViewHost* rvh);
[email protected]0dd3a0ab2011-02-18 08:17:44554
[email protected]0dd3a0ab2011-02-18 08:17:44555 // Saves the given title to the navigation entry and does associated work. It
556 // will update history and the view for the new title, and also synthesize
557 // titles for file URLs that have none (so we require that the URL of the
558 // entry already be set).
559 //
560 // This is used as the backend for state updates, which include a new title,
561 // or the dedicated set title message. It returns true if the new title is
562 // different and was therefore updated.
[email protected]10f417c52011-12-28 21:04:23563 bool UpdateTitleForEntry(content::NavigationEntryImpl* entry,
564 const string16& title);
[email protected]0dd3a0ab2011-02-18 08:17:44565
[email protected]b172aee2012-04-10 17:05:26566 // Causes the WebContentsImpl to navigate in the right renderer to |entry|,
567 // which must be already part of the entries in the navigation controller.
[email protected]0dd3a0ab2011-02-18 08:17:44568 // This does not change the NavigationController state.
[email protected]10f417c52011-12-28 21:04:23569 bool NavigateToEntry(const content::NavigationEntryImpl& entry,
[email protected]71fde352011-12-29 03:29:56570 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44571
[email protected]b172aee2012-04-10 17:05:26572 // Sets the history for this WebContentsImpl to |history_length| entries, and
[email protected]796931a92011-08-10 01:32:14573 // moves the current page_id to the last entry in the list if it's valid.
574 // This is mainly used when a prerendered page is swapped into the current
[email protected]9e1ad4b2011-08-14 16:49:19575 // tab. The method is virtual for testing.
[email protected]b6583592012-01-25 19:52:33576 virtual void SetHistoryLengthAndPrune(
577 const content::SiteInstance* site_instance,
578 int merge_history_length,
579 int32 minimum_page_id);
[email protected]796931a92011-08-10 01:32:14580
[email protected]14392a52012-05-02 20:28:44581 // Recursively creates swapped out RenderViews for this tab's opener chain
582 // (including this tab) in the given SiteInstance, allowing other tabs to send
583 // cross-process JavaScript calls to their opener(s). Returns the route ID of
584 // this tab's RenderView for |instance|.
585 int CreateOpenerRenderViews(content::SiteInstance* instance);
586
[email protected]bafe6cd2012-05-23 23:09:50587 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
588 void CreateNewWidget(int route_id,
589 bool is_fullscreen,
590 WebKit::WebPopupType popup_type);
591
592 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
593 void ShowCreatedWidget(int route_id,
594 bool is_fullscreen,
595 const gfx::Rect& initial_pos);
596
597 // Finds the new RenderWidgetHost and returns it. Note that this can only be
598 // called once as this call also removes it from the internal map.
599 content::RenderWidgetHostView* GetCreatedWidget(int route_id);
600
601 // Finds the new WebContentsImpl by route_id, initializes it for
602 // renderer-initiated creation, and returns it. Note that this can only be
603 // called once as this call also removes it from the internal map.
604 WebContentsImpl* GetCreatedWindow(int route_id);
605
[email protected]0dd3a0ab2011-02-18 08:17:44606 // Misc non-view stuff -------------------------------------------------------
607
608 // Helper functions for sending notifications.
609 void NotifySwapped();
610 void NotifyConnected();
611 void NotifyDisconnected();
612
[email protected]be1f56ab2011-12-22 06:55:31613 void SetEncoding(const std::string& encoding);
614
[email protected]27678b2a2012-02-04 22:09:14615 // Save a URL to the local filesystem.
[email protected]20b433a2012-05-15 21:23:46616 void SaveURL(const GURL& url,
617 const content::Referrer& referrer,
618 bool is_main_frame);
[email protected]27678b2a2012-02-04 22:09:14619
[email protected]eaabba22012-03-07 15:02:11620 content::RenderViewHostImpl* GetRenderViewHostImpl();
[email protected]9f76c1e2012-03-05 15:15:58621
[email protected]7900bfdb2012-05-24 19:31:24622 void GetBrowserPluginEmbedderInfo(content::RenderViewHost* render_view_host,
623 std::string* embedder_channel_name,
624 int* embedder_container_id);
625
[email protected]81898992011-06-14 22:15:00626 // Stores random bits of data for others to associate with this object.
627 // WARNING: this needs to be deleted after NavigationController.
[email protected]45644f62011-11-23 00:58:23628 base::PropertyBag property_bag_;
[email protected]81898992011-06-14 22:15:00629
[email protected]0dd3a0ab2011-02-18 08:17:44630 // Data for core operation ---------------------------------------------------
631
632 // Delegate for notifying our owner about stuff. Not owned by us.
[email protected]674bc592011-12-20 23:00:42633 content::WebContentsDelegate* delegate_;
[email protected]0dd3a0ab2011-02-18 08:17:44634
635 // Handles the back/forward list and loading.
[email protected]d202a7c2012-01-04 07:53:47636 NavigationControllerImpl controller_;
[email protected]0dd3a0ab2011-02-18 08:17:44637
638 // The corresponding view.
[email protected]8643e6d2012-01-18 20:26:10639 scoped_ptr<content::WebContentsView> view_;
[email protected]0dd3a0ab2011-02-18 08:17:44640
[email protected]5a3bdf52012-05-24 15:12:57641 // The view of the RVHD. Usually this is our WebContentsView implementation,
642 // but if an embedder uses a different WebContentsView, they'll need to
643 // provide this.
644 content::RenderViewHostDelegateView* render_view_host_delegate_view_;
645
[email protected]bafe6cd2012-05-23 23:09:50646 // Tracks created WebContentsImpl objects that have not been shown yet. They
647 // are identified by the route ID passed to CreateNewWindow.
648 typedef std::map<int, WebContentsImpl*> PendingContents;
649 PendingContents pending_contents_;
650
651 // These maps hold on to the widgets that we created on behalf of the renderer
652 // that haven't shown yet.
653 typedef std::map<int, content::RenderWidgetHostView*> PendingWidgetViews;
654 PendingWidgetViews pending_widget_views_;
655
[email protected]996042972011-11-08 22:43:59656 // A list of observers notified when page state changes. Weak references.
657 // This MUST be listed above render_manager_ since at destruction time the
658 // latter might cause RenderViewHost's destructor to call us and we might use
659 // the observer list then.
[email protected]d8c660432011-12-22 20:51:25660 ObserverList<content::WebContentsObserver> observers_;
[email protected]996042972011-11-08 22:43:59661
[email protected]14392a52012-05-02 20:28:44662 // The tab that opened this tab, if any. Will be set to null if the opener
663 // is closed.
664 WebContentsImpl* opener_;
665
[email protected]0dd3a0ab2011-02-18 08:17:44666 // Helper classes ------------------------------------------------------------
667
668 // Manages creation and swapping of render views.
669 RenderViewHostManager render_manager_;
670
[email protected]483623eb2011-10-25 09:30:00671 // Manages injecting Java objects into all RenderViewHosts associated with
[email protected]b172aee2012-04-10 17:05:26672 // this WebContentsImpl.
[email protected]483623eb2011-10-25 09:30:00673 scoped_ptr<JavaBridgeDispatcherHostManager>
674 java_bridge_dispatcher_host_manager_;
675
[email protected]172cf712012-05-23 15:07:39676 // Manages the browser plugin instances hosted by this WebContents.
677 scoped_ptr<content::BrowserPluginHost> browser_plugin_host_;
678
[email protected]c7dd2f62011-07-18 15:57:59679 // SavePackage, lazily created.
680 scoped_refptr<SavePackage> save_package_;
681
[email protected]0dd3a0ab2011-02-18 08:17:44682 // Data for loading state ----------------------------------------------------
683
684 // Indicates whether we're currently loading a resource.
685 bool is_loading_;
686
687 // Indicates if the tab is considered crashed.
688 base::TerminationStatus crashed_status_;
689 int crashed_error_code_;
690
[email protected]ca13a442012-04-17 14:00:12691 // Whether this WebContents is waiting for a first-response for the
[email protected]be1f56ab2011-12-22 06:55:31692 // main resource of the page. This controls whether the throbber state is
693 // "waiting" or "loading."
[email protected]0dd3a0ab2011-02-18 08:17:44694 bool waiting_for_response_;
695
[email protected]74ce1ad2011-12-16 21:51:46696 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
697 // to a given tab and SiteInstance, and must be valid for the lifetime of the
[email protected]b172aee2012-04-10 17:05:26698 // WebContentsImpl.
[email protected]74ce1ad2011-12-16 21:51:46699 std::map<int32, int32> max_page_ids_;
[email protected]0dd3a0ab2011-02-18 08:17:44700
701 // System time at which the current load was started.
702 base::TimeTicks current_load_start_;
703
704 // The current load state and the URL associated with it.
[email protected]9c235f042011-08-10 22:28:21705 net::LoadStateWithParam load_state_;
[email protected]0dd3a0ab2011-02-18 08:17:44706 string16 load_state_host_;
707 // Upload progress, for displaying in the status bar.
708 // Set to zero when there is no significant upload happening.
709 uint64 upload_size_;
710 uint64 upload_position_;
711
712 // Data for current page -----------------------------------------------------
713
[email protected]987fc3a2011-05-26 14:18:09714 // When a title cannot be taken from any entry, this title will be used.
715 string16 page_title_when_no_navigation_entry_;
716
[email protected]0dd3a0ab2011-02-18 08:17:44717 // When a navigation occurs, we record its contents MIME type. It can be
718 // used to check whether we can do something for some special contents.
719 std::string contents_mime_type_;
720
721 // Character encoding.
722 std::string encoding_;
723
[email protected]0dd3a0ab2011-02-18 08:17:44724 // True if this is a secure page which displayed insecure content.
725 bool displayed_insecure_content_;
726
[email protected]0dd3a0ab2011-02-18 08:17:44727 // Data for misc internal state ----------------------------------------------
728
[email protected]ca13a442012-04-17 14:00:12729 // Whether the WebContents is currently being screenshotted.
[email protected]0dd3a0ab2011-02-18 08:17:44730 bool capturing_contents_;
731
732 // See getter above.
733 bool is_being_destroyed_;
734
735 // Indicates whether we should notify about disconnection of this
[email protected]b172aee2012-04-10 17:05:26736 // WebContentsImpl. This is used to ensure disconnection notifications only
[email protected]0dd3a0ab2011-02-18 08:17:44737 // happen if a connection notification has happened and that they happen only
738 // once.
739 bool notify_disconnection_;
740
[email protected]2e5b90c2011-08-16 21:11:55741 // Pointer to the JavaScript dialog creator, lazily assigned. Used because the
[email protected]b172aee2012-04-10 17:05:26742 // delegate of this WebContentsImpl is nulled before its destructor is called.
[email protected]2e5b90c2011-08-16 21:11:55743 content::JavaScriptDialogCreator* dialog_creator_;
744
[email protected]0dd3a0ab2011-02-18 08:17:44745#if defined(OS_WIN)
746 // Handle to an event that's set when the page is showing a message box (or
747 // equivalent constrained window). Plugin processes check this to know if
748 // they should pump messages then.
749 base::win::ScopedHandle message_box_active_;
750#endif
751
[email protected]0dd3a0ab2011-02-18 08:17:44752 // Set to true when there is an active "before unload" dialog. When true,
753 // we've forced the throbber to start in Navigate, and we need to remember to
754 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
755 bool is_showing_before_unload_dialog_;
756
[email protected]0dd3a0ab2011-02-18 08:17:44757 // Settings that get passed to the renderer process.
[email protected]daf82f82011-10-31 22:35:31758 content::RendererPreferences renderer_preferences_;
[email protected]0dd3a0ab2011-02-18 08:17:44759
760 // If this tab was created from a renderer using window.open, this will be
761 // non-NULL and represent the WebUI of the opening renderer.
[email protected]01ec4ec2012-01-18 04:13:47762 content::WebUI::TypeID opener_web_ui_type_;
[email protected]0dd3a0ab2011-02-18 08:17:44763
764 // The time that we started to create the new tab page.
765 base::TimeTicks new_tab_start_time_;
766
[email protected]3bbacc5b2012-04-17 17:46:15767 // The time that we started to close this WebContents.
768 base::TimeTicks close_start_time_;
[email protected]0dd3a0ab2011-02-18 08:17:44769
770 // The time that this tab was last selected.
771 base::TimeTicks last_selected_time_;
772
[email protected]0dd3a0ab2011-02-18 08:17:44773 // See description above setter.
774 bool closed_by_user_gesture_;
775
776 // Minimum/maximum zoom percent.
777 int minimum_zoom_percent_;
778 int maximum_zoom_percent_;
779 // If true, the default zoom limits have been overriden for this tab, in which
780 // case we don't want saved settings to apply to it and we don't want to
781 // remember it.
782 bool temporary_zoom_settings_;
783
[email protected]bcd2815602012-01-14 18:17:23784 // The intrinsic size of the page.
785 gfx::Size preferred_size_;
786
[email protected]0dd3a0ab2011-02-18 08:17:44787 // Content restrictions, used to disable print/copy etc based on content's
788 // (full-page plugins for now only) permissions.
789 int content_restrictions_;
790
[email protected]da8543762012-03-20 08:52:20791 // Color chooser that was opened by this tab.
792 content::ColorChooser* color_chooser_;
793
[email protected]f53a9f872012-05-24 02:07:06794 // This must be at the end, or else we might get notifications and use other
795 // member variables that are gone.
796 content::NotificationRegistrar registrar_;
797
[email protected]b172aee2012-04-10 17:05:26798 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
[email protected]0dd3a0ab2011-02-18 08:17:44799};
800
[email protected]93ddb3c2012-04-11 21:44:29801#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_