blob: 3c918cc7375bdbceabd5a7d2bf10dbe71d771c8c [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#pragma once
8
[email protected]0dd3a0ab2011-02-18 08:17:449#include <map>
10#include <string>
[email protected]0dd3a0ab2011-02-18 08:17:4411
[email protected]01d65172011-12-25 04:39:3012#include "base/compiler_specific.h"
[email protected]0dd3a0ab2011-02-18 08:17:4413#include "base/gtest_prod_util.h"
[email protected]3b63f8f42011-03-28 01:54:1514#include "base/memory/scoped_ptr.h"
[email protected]6eac57a2011-07-12 21:15:0915#include "base/observer_list.h"
[email protected]45644f62011-11-23 00:58:2316#include "base/property_bag.h"
[email protected]172cf712012-05-23 15:07:3917#include "content/browser/browser_plugin/browser_plugin_host.h"
[email protected]07161902011-11-11 09:57:4218#include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager.h"
[email protected]2e3bf992012-05-24 17:36:2419#include "content/browser/renderer_host/render_view_host_delegate.h"
[email protected]4ca76c02012-05-16 16:19:0520#include "content/browser/renderer_host/render_widget_host_delegate.h"
[email protected]f9e4dae2012-04-10 21:26:3721#include "content/browser/web_contents/navigation_controller_impl.h"
[email protected]0c4e92e62012-04-11 15:19:0022#include "content/browser/web_contents/render_view_host_manager.h"
[email protected]8d128d62011-09-13 22:11:5723#include "content/common/content_export.h"
[email protected]14392a52012-05-02 20:28:4424#include "content/public/browser/notification_observer.h"
25#include "content/public/browser/notification_registrar.h"
[email protected]58f5d562011-12-20 17:13:0326#include "content/public/browser/web_contents.h"
[email protected]daf82f82011-10-31 22:35:3127#include "content/public/common/renderer_preferences.h"
[email protected]0dd3a0ab2011-02-18 08:17:4428#include "net/base/load_states.h"
[email protected]bcd2815602012-01-14 18:17:2329#include "ui/gfx/size.h"
[email protected]70435962011-08-02 20:13:2830#include "webkit/glue/resource_type.h"
[email protected]0dd3a0ab2011-02-18 08:17:4431
32#if defined(OS_WIN)
33#include "base/win/scoped_handle.h"
34#endif
35
[email protected]cadaec52012-02-08 21:53:1336class InterstitialPageImpl;
[email protected]a53209b2012-01-20 16:48:1637class SavePackage;
[email protected]adbfb8df2012-02-24 01:19:4338class SessionStorageNamespaceImpl;
[email protected]f66df822012-05-18 16:52:1739class WebContentsImpl;
[email protected]f546640b2012-05-15 00:03:4940struct ViewMsg_PostMessage_Params;
[email protected]daf82f82011-10-31 22:35:3141
[email protected]e582fdd2011-12-20 16:48:1742namespace content {
[email protected]da8543762012-03-20 08:52:2043class ColorChooser;
[email protected]e582fdd2011-12-20 16:48:1744class DownloadItem;
[email protected]51da7e32012-01-30 19:24:5245class JavaScriptDialogCreator;
[email protected]eaabba22012-03-07 15:02:1146class RenderViewHost;
[email protected]5a3bdf52012-05-24 15:12:5747class RenderViewHostDelegateView;
[email protected]eaabba22012-03-07 15:02:1148class RenderViewHostImpl;
[email protected]09d31d52012-03-11 22:30:2749class SiteInstance;
[email protected]80e776ae2012-03-23 16:17:2050class TestWebContents;
[email protected]674bc592011-12-20 23:00:4251class WebContentsDelegate;
[email protected]51da7e32012-01-30 19:24:5252class WebContentsObserver;
[email protected]8643e6d2012-01-18 20:26:1053class WebContentsView;
[email protected]f66df822012-05-18 16:52:1754class WebContentsViewDelegate;
[email protected]09d31d52012-03-11 22:30:2755struct LoadNotificationDetails;
[email protected]f66df822012-05-18 16:52:1756
57// Factory function for the implementations that content knows about. Takes
58// ownership of |delegate|.
[email protected]5a3bdf52012-05-24 15:12:5759WebContentsView* CreateWebContentsView(
60 WebContentsImpl* web_contents,
61 WebContentsViewDelegate* delegate,
62 RenderViewHostDelegateView** render_view_host_delegate_view);
[email protected]e582fdd2011-12-20 16:48:1763}
64
[email protected]daf82f82011-10-31 22:35:3165namespace webkit_glue {
66struct WebIntentData;
67}
[email protected]0dd3a0ab2011-02-18 08:17:4468
[email protected]b172aee2012-04-10 17:05:2669class CONTENT_EXPORT WebContentsImpl
[email protected]01d65172011-12-25 04:39:3070 : public NON_EXPORTED_BASE(content::WebContents),
[email protected]b0b67cf2012-01-18 21:59:5771 public content::RenderViewHostDelegate,
[email protected]4ca76c02012-05-16 16:19:0572 public content::RenderWidgetHostDelegate,
[email protected]14392a52012-05-02 20:28:4473 public RenderViewHostManager::Delegate,
74 public content::NotificationObserver {
[email protected]0dd3a0ab2011-02-18 08:17:4475 public:
[email protected]a81343d232011-12-27 07:39:2076 // See WebContents::Create for a description of these parameters.
[email protected]b172aee2012-04-10 17:05:2677 WebContentsImpl(content::BrowserContext* browser_context,
78 content::SiteInstance* site_instance,
79 int routing_id,
80 const WebContentsImpl* base_web_contents,
[email protected]14392a52012-05-02 20:28:4481 WebContentsImpl* opener,
[email protected]b172aee2012-04-10 17:05:2682 SessionStorageNamespaceImpl* session_storage_namespace);
83 virtual ~WebContentsImpl();
[email protected]0dd3a0ab2011-02-18 08:17:4484
[email protected]64d69de42012-02-06 00:19:5485 // Returns the content specific prefs for the given RVH.
[email protected]6717bf272012-05-11 23:31:2586 static webkit_glue::WebPreferences GetWebkitPrefs(
[email protected]eaabba22012-03-07 15:02:1187 content::RenderViewHost* rvh, const GURL& url);
[email protected]64d69de42012-02-06 00:19:5488
[email protected]c7dd2f62011-07-18 15:57:5989 // Returns the SavePackage which manages the page saving job. May be NULL.
90 SavePackage* save_package() const { return save_package_.get(); }
91
[email protected]b172aee2012-04-10 17:05:2692 // Updates the max page ID for the current SiteInstance in this
93 // WebContentsImpl to be at least |page_id|.
[email protected]0dd3a0ab2011-02-18 08:17:4494 void UpdateMaxPageID(int32 page_id);
95
[email protected]b172aee2012-04-10 17:05:2696 // Updates the max page ID for the given SiteInstance in this WebContentsImpl
[email protected]74ce1ad2011-12-16 21:51:4697 // to be at least |page_id|.
[email protected]b6583592012-01-25 19:52:3398 void UpdateMaxPageIDForSiteInstance(content::SiteInstance* site_instance,
[email protected]74ce1ad2011-12-16 21:51:4699 int32 page_id);
100
[email protected]91854cd2012-01-10 19:43:57101 // Copy the current map of SiteInstance ID to max page ID from another tab.
102 // This is necessary when this tab adopts the NavigationEntries from
[email protected]b172aee2012-04-10 17:05:26103 // |web_contents|.
104 void CopyMaxPageIDsFrom(WebContentsImpl* web_contents);
[email protected]91854cd2012-01-10 19:43:57105
[email protected]b172aee2012-04-10 17:05:26106 // Called by the NavigationController to cause the WebContentsImpl to navigate
107 // to the current pending entry. The NavigationController should be called
108 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
[email protected]9a7e68c2011-05-26 17:35:50109 // The callbacks can be inside of this function, or at some future time.
[email protected]0dd3a0ab2011-02-18 08:17:44110 //
111 // The entry has a PageID of -1 if newly created (corresponding to navigation
112 // to a new URL).
113 //
114 // If this method returns false, then the navigation is discarded (equivalent
115 // to calling DiscardPendingEntry on the NavigationController).
[email protected]0bfbf882011-12-22 18:19:27116 bool NavigateToPendingEntry(
[email protected]71fde352011-12-29 03:29:56117 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44118
[email protected]ba45bfd2012-05-22 21:51:44119 // Called by InterstitialPageImpl when it creates a RenderViewHost.
120 void RenderViewForInterstitialPageCreated(
121 content::RenderViewHost* render_view_host);
122
[email protected]0dd3a0ab2011-02-18 08:17:44123 // Sets the passed passed interstitial as the currently showing interstitial.
124 // |interstitial_page| should be non NULL (use the remove_interstitial_page
125 // method to unset the interstitial) and no interstitial page should be set
126 // when there is already a non NULL interstitial page set.
[email protected]cadaec52012-02-08 21:53:13127 void set_interstitial_page(InterstitialPageImpl* interstitial_page) {
[email protected]0dd3a0ab2011-02-18 08:17:44128 render_manager_.set_interstitial_page(interstitial_page);
129 }
130
131 // Unsets the currently showing interstitial.
132 void remove_interstitial_page() {
133 render_manager_.remove_interstitial_page();
134 }
135
[email protected]01ec4ec2012-01-18 04:13:47136 void set_opener_web_ui_type(content::WebUI::TypeID opener_web_ui_type) {
[email protected]0dd3a0ab2011-02-18 08:17:44137 opener_web_ui_type_ = opener_web_ui_type;
138 }
139
[email protected]276b37a22011-11-08 20:45:46140 JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const {
141 return java_bridge_dispatcher_host_manager_.get();
142 }
143
[email protected]172cf712012-05-23 15:07:39144 content::BrowserPluginHost* browser_plugin_host() const {
145 return browser_plugin_host_.get();
146 }
147
[email protected]cdcb1dee2012-01-04 00:46:20148 // Like GetController from WebContents, but returns the concrete object.
[email protected]d202a7c2012-01-04 07:53:47149 NavigationControllerImpl& GetControllerImpl();
[email protected]cdcb1dee2012-01-04 00:46:20150
[email protected]765187182012-01-11 23:59:28151 // Expose the render manager for testing.
152 RenderViewHostManager* GetRenderManagerForTesting();
153
[email protected]58f5d562011-12-20 17:13:03154 // content::WebContents ------------------------------------------------------
[email protected]6934a702011-12-20 00:04:51155 virtual const base::PropertyBag* GetPropertyBag() const OVERRIDE;
156 virtual base::PropertyBag* GetPropertyBag() OVERRIDE;
[email protected]674bc592011-12-20 23:00:42157 virtual content::WebContentsDelegate* GetDelegate() OVERRIDE;
158 virtual void SetDelegate(content::WebContentsDelegate* delegate) OVERRIDE;
[email protected]cdcb1dee2012-01-04 00:46:20159 virtual content::NavigationController& GetController() OVERRIDE;
160 virtual const content::NavigationController& GetController() const OVERRIDE;
[email protected]627e0512011-12-21 22:55:30161 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
[email protected]f5fa20e2011-12-21 22:35:56162 virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11163 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE;
[email protected]5626b0892012-02-20 14:46:58164 virtual content::RenderWidgetHostView*
165 GetRenderWidgetHostView() const OVERRIDE;
[email protected]8643e6d2012-01-18 20:26:10166 virtual content::WebContentsView* GetView() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47167 virtual content::WebUI* CreateWebUI(const GURL& url) OVERRIDE;
168 virtual content::WebUI* GetWebUI() const OVERRIDE;
169 virtual content::WebUI* GetCommittedWebUI() const OVERRIDE;
[email protected]86ef6a392012-05-11 22:03:11170 virtual void SetUserAgentOverride(const std::string& override) OVERRIDE;
171 virtual const std::string& GetUserAgentOverride() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31172 virtual const string16& GetTitle() const OVERRIDE;
173 virtual int32 GetMaxPageID() OVERRIDE;
174 virtual int32 GetMaxPageIDForSiteInstance(
[email protected]b6583592012-01-25 19:52:33175 content::SiteInstance* site_instance) OVERRIDE;
176 virtual content::SiteInstance* GetSiteInstance() const OVERRIDE;
177 virtual content::SiteInstance* GetPendingSiteInstance() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31178 virtual bool IsLoading() const OVERRIDE;
179 virtual bool IsWaitingForResponse() const OVERRIDE;
180 virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE;
181 virtual const string16& GetLoadStateHost() const OVERRIDE;
182 virtual uint64 GetUploadSize() const OVERRIDE;
183 virtual uint64 GetUploadPosition() const OVERRIDE;
184 virtual const std::string& GetEncoding() const OVERRIDE;
185 virtual bool DisplayedInsecureContent() const OVERRIDE;
186 virtual void SetCapturingContents(bool cap) OVERRIDE;
187 virtual bool IsCrashed() const OVERRIDE;
188 virtual void SetIsCrashed(base::TerminationStatus status,
189 int error_code) OVERRIDE;
190 virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE;
191 virtual bool IsBeingDestroyed() const OVERRIDE;
192 virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE;
193 virtual void DidBecomeSelected() OVERRIDE;
194 virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE;
195 virtual void WasHidden() OVERRIDE;
[email protected]375fa1b2012-05-22 22:05:37196 virtual void WasRestored() OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31197 virtual void ShowContents() OVERRIDE;
198 virtual void HideContents() OVERRIDE;
199 virtual bool NeedToFireBeforeUnload() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27200 virtual void Stop() OVERRIDE;
[email protected]d9083482012-01-06 00:38:46201 virtual content::WebContents* Clone() OVERRIDE;
[email protected]2a6bc3e2011-12-28 23:51:33202 virtual void AddNewContents(content::WebContents* new_contents,
[email protected]0bfbf882011-12-22 18:19:27203 WindowOpenDisposition disposition,
204 const gfx::Rect& initial_pos,
205 bool user_gesture) OVERRIDE;
206 virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
207 virtual gfx::NativeView GetNativeView() const OVERRIDE;
208 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE;
209 virtual void Focus() OVERRIDE;
210 virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE;
211 virtual bool ShowingInterstitialPage() const OVERRIDE;
[email protected]cadaec52012-02-08 21:53:13212 virtual content::InterstitialPage* GetInterstitialPage() const OVERRIDE;
[email protected]a53209b2012-01-20 16:48:16213 virtual bool IsSavable() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27214 virtual void OnSavePage() OVERRIDE;
215 virtual bool SavePage(const FilePath& main_file,
216 const FilePath& dir_path,
[email protected]a53209b2012-01-20 16:48:16217 content::SavePageType save_type) OVERRIDE;
[email protected]aa4f3972012-03-01 18:12:12218 virtual void GenerateMHTML(
219 const FilePath& file,
220 const base::Callback<void(const FilePath&, int64)>& callback) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27221 virtual bool IsActiveEntry(int32 page_id) OVERRIDE;
222
223 virtual const std::string& GetContentsMimeType() const OVERRIDE;
224 virtual bool WillNotifyDisconnection() const OVERRIDE;
225 virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE;
226 virtual void ResetOverrideEncoding() OVERRIDE;
227 virtual content::RendererPreferences* GetMutableRendererPrefs() OVERRIDE;
228 virtual void SetNewTabStartTime(const base::TimeTicks& time) OVERRIDE;
229 virtual base::TimeTicks GetNewTabStartTime() const OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47230 virtual void Close() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27231 virtual void OnCloseStarted() OVERRIDE;
232 virtual bool ShouldAcceptDragAndDrop() const OVERRIDE;
233 virtual void SystemDragEnded() OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47234 virtual void UserGestureDone() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27235 virtual void SetClosedByUserGesture(bool value) OVERRIDE;
236 virtual bool GetClosedByUserGesture() const OVERRIDE;
237 virtual double GetZoomLevel() const OVERRIDE;
238 virtual int GetZoomPercent(bool* enable_increment,
239 bool* enable_decrement) OVERRIDE;
240 virtual void ViewSource() OVERRIDE;
241 virtual void ViewFrameSource(const GURL& url,
242 const std::string& content_state) OVERRIDE;
243 virtual int GetMinimumZoomPercent() const OVERRIDE;
244 virtual int GetMaximumZoomPercent() const OVERRIDE;
[email protected]bcd2815602012-01-14 18:17:23245 virtual gfx::Size GetPreferredSize() const OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27246 virtual int GetContentRestrictions() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47247 virtual content::WebUI::TypeID GetWebUITypeForCurrentState() OVERRIDE;
248 virtual content::WebUI* GetWebUIForCurrentState() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27249 virtual bool GotResponseToLockMouseRequest(bool allowed) OVERRIDE;
[email protected]a0358d72012-03-09 14:06:50250 virtual bool HasOpener() const OVERRIDE;
[email protected]da8543762012-03-20 08:52:20251 virtual void DidChooseColorInColorChooser(int color_chooser_id,
[email protected]55578b0a2012-04-18 14:31:32252 SkColor color) OVERRIDE;
[email protected]da8543762012-03-20 08:52:20253 virtual void DidEndColorChooser(int color_chooser_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27254
255 // Implementation of PageNavigator.
[email protected]e5d549d2011-12-28 01:29:20256 virtual content::WebContents* OpenURL(
257 const content::OpenURLParams& params) OVERRIDE;
[email protected]151a63d2011-12-20 22:32:52258
[email protected]952a68e2011-11-17 00:36:10259 // RenderViewHostDelegate ----------------------------------------------------
260
[email protected]5a3bdf52012-05-24 15:12:57261 virtual content::RenderViewHostDelegateView* GetDelegateView() OVERRIDE;
[email protected]b0b67cf2012-01-18 21:59:57262 virtual content::RenderViewHostDelegate::RendererManagement*
[email protected]952a68e2011-11-17 00:36:10263 GetRendererManagementDelegate() OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31264 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
265 virtual const GURL& GetURL() const OVERRIDE;
[email protected]768c5472011-12-26 19:06:17266 virtual WebContents* GetAsWebContents() OVERRIDE;
[email protected]b7a756d42012-01-23 18:08:17267 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11268 virtual void RenderViewCreated(
269 content::RenderViewHost* render_view_host) OVERRIDE;
270 virtual void RenderViewReady(
271 content::RenderViewHost* render_view_host) OVERRIDE;
272 virtual void RenderViewGone(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10273 base::TerminationStatus status,
274 int error_code) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11275 virtual void RenderViewDeleted(
276 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57277 virtual void DidStartProvisionalLoadForFrame(
278 content::RenderViewHost* render_view_host,
279 int64 frame_id,
280 bool main_frame,
281 const GURL& opener_url,
282 const GURL& url) OVERRIDE;
283 virtual void DidRedirectProvisionalLoad(
284 content::RenderViewHost* render_view_host,
285 int32 page_id,
286 const GURL& opener_url,
287 const GURL& source_url,
288 const GURL& target_url) OVERRIDE;
289 virtual void DidFailProvisionalLoadWithError(
290 content::RenderViewHost* render_view_host,
291 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params)
292 OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10293 virtual void DidNavigate(
[email protected]eaabba22012-03-07 15:02:11294 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10295 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11296 virtual void UpdateState(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10297 int32 page_id,
298 const std::string& state) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11299 virtual void UpdateTitle(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10300 int32 page_id,
301 const string16& title,
302 base::i18n::TextDirection title_direction) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11303 virtual void UpdateEncoding(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10304 const std::string& encoding) OVERRIDE;
305 virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11306 virtual void Close(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10307 virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11308 virtual void SwappedOut(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10309 virtual void DidStartLoading() OVERRIDE;
310 virtual void DidStopLoading() OVERRIDE;
311 virtual void DidCancelLoading() OVERRIDE;
312 virtual void DidChangeLoadProgress(double progress) OVERRIDE;
[email protected]87717d0e2012-04-26 02:58:43313 virtual void DocumentAvailableInMainFrame(
314 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10315 virtual void DocumentOnLoadCompletedInMainFrame(
[email protected]eaabba22012-03-07 15:02:11316 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10317 int32 page_id) OVERRIDE;
[email protected]196159d2012-05-04 17:26:54318 virtual void RequestOpenURL(content::RenderViewHost* rvh,
319 const GURL& url,
[email protected]445e1042011-12-03 21:03:15320 const content::Referrer& referrer,
[email protected]952a68e2011-11-17 00:36:10321 WindowOpenDisposition disposition,
322 int64 source_frame_id) OVERRIDE;
[email protected]4ad5d77d2011-12-03 02:00:48323 virtual void RequestTransferURL(
324 const GURL& url,
[email protected]bce1f1c2011-12-05 15:11:58325 const content::Referrer& referrer,
[email protected]4ad5d77d2011-12-03 02:00:48326 WindowOpenDisposition disposition,
327 int64 source_frame_id,
[email protected]e5d549d2011-12-28 01:29:20328 const content::GlobalRequestID& transferred_global_request_id) OVERRIDE;
[email protected]e1c3a552012-05-04 20:51:32329 virtual void RouteCloseEvent(content::RenderViewHost* rvh) OVERRIDE;
[email protected]f546640b2012-05-15 00:03:49330 virtual void RouteMessageEvent(
331 content::RenderViewHost* rvh,
332 const ViewMsg_PostMessage_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11333 virtual void RunJavaScriptMessage(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10334 const string16& message,
335 const string16& default_prompt,
336 const GURL& frame_url,
[email protected]be2510c02012-05-28 14:52:14337 content::JavaScriptMessageType type,
[email protected]952a68e2011-11-17 00:36:10338 IPC::Message* reply_msg,
339 bool* did_suppress_message) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11340 virtual void RunBeforeUnloadConfirm(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10341 const string16& message,
[email protected]3b3301f62012-02-29 04:32:32342 bool is_reload,
[email protected]952a68e2011-11-17 00:36:10343 IPC::Message* reply_msg) OVERRIDE;
[email protected]a796f202012-05-30 14:14:25344 virtual bool AddMessageToConsole(int32 level,
345 const string16& message,
346 int32 line_no,
347 const string16& source_id) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10348 virtual content::RendererPreferences GetRendererPrefs(
349 content::BrowserContext* browser_context) const OVERRIDE;
[email protected]6717bf272012-05-11 23:31:25350 virtual webkit_glue::WebPreferences GetWebkitPrefs() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10351 virtual void OnUserGesture() OVERRIDE;
352 virtual void OnIgnoredUIEvent() OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11353 virtual void RendererUnresponsive(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10354 bool is_during_unload) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11355 virtual void RendererResponsive(
356 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10357 virtual void LoadStateChanged(const GURL& url,
358 const net::LoadStateWithParam& load_state,
359 uint64 upload_position,
360 uint64 upload_size) OVERRIDE;
361 virtual void WorkerCrashed() OVERRIDE;
362 virtual void Activate() OVERRIDE;
363 virtual void Deactivate() OVERRIDE;
364 virtual void LostCapture() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10365 virtual void HandleMouseDown() OVERRIDE;
366 virtual void HandleMouseUp() OVERRIDE;
367 virtual void HandleMouseActivate() 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]42252e02012-04-26 16:29:39375 virtual void RequestToLockMouse(bool user_gesture) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10376 virtual void LostMouseLock() OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50377 virtual void CreateNewWindow(
378 int route_id,
379 const ViewHostMsg_CreateWindow_Params& params) OVERRIDE;
380 virtual void CreateNewWidget(int route_id,
381 WebKit::WebPopupType popup_type) OVERRIDE;
382 virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
383 virtual void ShowCreatedWindow(int route_id,
384 WindowOpenDisposition disposition,
385 const gfx::Rect& initial_pos,
386 bool user_gesture) OVERRIDE;
387 virtual void ShowCreatedWidget(int route_id,
388 const gfx::Rect& initial_pos) OVERRIDE;
389 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
390 virtual void ShowContextMenu(
391 const content::ContextMenuParams& params) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10392
[email protected]4ca76c02012-05-16 16:19:05393 // RenderWidgetHostDelegate --------------------------------------------------
394
[email protected]b87ee522012-05-18 15:16:54395 virtual bool PreHandleKeyboardEvent(
396 const content::NativeWebKeyboardEvent& event,
397 bool* is_keyboard_shortcut) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05398 virtual void HandleKeyboardEvent(
[email protected]b87ee522012-05-18 15:16:54399 const content::NativeWebKeyboardEvent& event) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05400
[email protected]0bfbf882011-12-22 18:19:27401 // RenderViewHostManager::Delegate -------------------------------------------
402
403 virtual bool CreateRenderViewForRenderManager(
[email protected]14392a52012-05-02 20:28:44404 content::RenderViewHost* render_view_host, int opener_route_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27405 virtual void BeforeUnloadFiredFromRenderManager(
406 bool proceed,
407 bool* proceed_to_fire_unload) OVERRIDE;
408 virtual void DidStartLoadingFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11409 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27410 virtual void RenderViewGoneFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11411 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27412 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
413 virtual void NotifySwappedFromRenderManager() OVERRIDE;
[email protected]14392a52012-05-02 20:28:44414 virtual int CreateOpenerRenderViewsForRenderManager(
415 content::SiteInstance* instance) OVERRIDE;
[email protected]d202a7c2012-01-04 07:53:47416 virtual NavigationControllerImpl& GetControllerForRenderManager() OVERRIDE;
[email protected]d2353452012-01-19 19:53:56417 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
[email protected]ad23a092011-12-28 07:02:04418 virtual content::NavigationEntry*
[email protected]0bfbf882011-12-22 18:19:27419 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
420 virtual bool FocusLocationBarByDefault() OVERRIDE;
421 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11422 virtual void CreateViewAndSetSizeForRVH(
423 content::RenderViewHost* rvh) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27424
[email protected]14392a52012-05-02 20:28:44425 // content::NotificationObserver ---------------------------------------------
426
427 virtual void Observe(int type,
428 const content::NotificationSource& source,
429 const content::NotificationDetails& details) OVERRIDE;
430
[email protected]0dd3a0ab2011-02-18 08:17:44431 protected:
[email protected]d8c660432011-12-22 20:51:25432 friend class content::WebContentsObserver;
[email protected]553602e12011-04-05 17:01:18433
434 // Add and remove observers for page navigation notifications. Adding or
435 // removing multiple times has no effect. The order in which notifications
436 // are sent to observers is undefined. Clients must be sure to remove the
437 // observer before they go away.
[email protected]d8c660432011-12-22 20:51:25438 void AddObserver(content::WebContentsObserver* observer);
439 void RemoveObserver(content::WebContentsObserver* observer);
[email protected]553602e12011-04-05 17:01:18440
[email protected]0dd3a0ab2011-02-18 08:17:44441 private:
[email protected]d202a7c2012-01-04 07:53:47442 friend class NavigationControllerImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44443
[email protected]2db9bd72012-04-13 20:20:56444 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
445 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
446 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
447 CrossSiteCantPreemptAfterUnload);
[email protected]0dd3a0ab2011-02-18 08:17:44448 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
449 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
450 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
451
[email protected]cadaec52012-02-08 21:53:13452 // So InterstitialPageImpl can access SetIsLoading.
453 friend class InterstitialPageImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44454
[email protected]80e776ae2012-03-23 16:17:20455 // TODO(brettw) TestWebContents shouldn't exist!
456 friend class content::TestWebContents;
[email protected]0dd3a0ab2011-02-18 08:17:44457
[email protected]14392a52012-05-02 20:28:44458 // Clears this tab's opener if it has been closed.
459 void OnWebContentsDestroyed(content::WebContents* web_contents);
460
[email protected]51da7e32012-01-30 19:24:52461 // Callback function when showing JS dialogs.
[email protected]eaabba22012-03-07 15:02:11462 void OnDialogClosed(content::RenderViewHost* rvh,
[email protected]51da7e32012-01-30 19:24:52463 IPC::Message* reply_msg,
464 bool success,
465 const string16& user_input);
466
[email protected]d0759f492012-04-19 22:50:50467 // IPC message handlers.
[email protected]8b5af492011-11-28 21:50:58468 void OnRegisterIntentService(const string16& action,
[email protected]63c239322011-10-31 23:56:30469 const string16& type,
470 const string16& href,
471 const string16& title,
472 const string16& disposition);
[email protected]678105012011-12-09 04:01:21473 void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
[email protected]63c239322011-10-31 23:56:30474 int intent_id);
[email protected]0dd3a0ab2011-02-18 08:17:44475 void OnDidLoadResourceFromMemoryCache(const GURL& url,
[email protected]70435962011-08-02 20:13:28476 const std::string& security_info,
477 const std::string& http_request,
[email protected]6d6cfb3a2012-05-23 22:53:18478 const std::string& mime_type,
[email protected]70435962011-08-02 20:13:28479 ResourceType::Type resource_type);
[email protected]0dd3a0ab2011-02-18 08:17:44480 void OnDidDisplayInsecureContent();
481 void OnDidRunInsecureContent(const std::string& security_origin,
482 const GURL& target_url);
483 void OnDocumentLoadedInFrame(int64 frame_id);
[email protected]1a55c5be2011-11-29 11:36:31484 void OnDidFinishLoad(int64 frame_id,
485 const GURL& validated_url,
486 bool is_main_frame);
487 void OnDidFailLoadWithError(int64 frame_id,
488 const GURL& validated_url,
489 bool is_main_frame,
490 int error_code,
491 const string16& error_description);
[email protected]0dd3a0ab2011-02-18 08:17:44492 void OnUpdateContentRestrictions(int restrictions);
[email protected]0dd3a0ab2011-02-18 08:17:44493 void OnGoToEntryAtOffset(int offset);
[email protected]216813952011-05-19 22:21:26494 void OnUpdateZoomLimits(int minimum_percent,
495 int maximum_percent,
496 bool remember);
[email protected]20b433a2012-05-15 21:23:46497 void OnSaveURL(const GURL& url, const content::Referrer& referrer);
[email protected]3a29a6e2011-08-24 18:26:21498 void OnEnumerateDirectory(int request_id, const FilePath& path);
[email protected]7d189022011-08-25 22:54:20499 void OnJSOutOfMemory();
[email protected]b7a756d42012-01-23 18:08:17500
[email protected]7d189022011-08-25 22:54:20501 void OnRegisterProtocolHandler(const std::string& protocol,
502 const GURL& url,
503 const string16& title);
[email protected]b888919c2011-09-02 00:32:16504 void OnFindReply(int request_id, int number_of_matches,
505 const gfx::Rect& selection_rect, int active_match_ordinal,
506 bool final_update);
[email protected]d952a052011-09-06 18:42:45507 void OnCrashedPlugin(const FilePath& plugin_path);
[email protected]7fc4bbb2011-09-08 21:23:10508 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
[email protected]55578b0a2012-04-18 14:31:32509 void OnOpenColorChooser(int color_chooser_id, SkColor color);
[email protected]da8543762012-03-20 08:52:20510 void OnEndColorChooser(int color_chooser_id);
[email protected]55578b0a2012-04-18 14:31:32511 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
[email protected]8be45842012-04-13 19:49:29512 void OnPepperPluginHung(int plugin_child_id,
513 const FilePath& path,
514 bool is_hung);
[email protected]d0759f492012-04-19 22:50:50515 void OnWebUISend(const GURL& source_url,
516 const std::string& name,
517 const base::ListValue& args);
[email protected]0dd3a0ab2011-02-18 08:17:44518
519 // Changes the IsLoading state and notifies delegate as needed
520 // |details| is used to provide details on the load that just finished
521 // (but can be null if not applicable). Can be overridden.
522 void SetIsLoading(bool is_loading,
[email protected]09d31d52012-03-11 22:30:27523 content::LoadNotificationDetails* details);
[email protected]0dd3a0ab2011-02-18 08:17:44524
[email protected]0dd3a0ab2011-02-18 08:17:44525 // Called by derived classes to indicate that we're no longer waiting for a
526 // response. This won't actually update the throbber, but it will get picked
527 // up at the next animation step if the throbber is going.
528 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
529
[email protected]0dd3a0ab2011-02-18 08:17:44530 // Navigation helpers --------------------------------------------------------
531 //
532 // These functions are helpers for Navigate() and DidNavigate().
533
534 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
535 // committed to the navigation controller. Note that the navigation entry is
536 // not provided since it may be invalid/changed after being committed. The
537 // current navigation entry is in the NavigationController at this point.
538 void DidNavigateMainFramePostCommit(
[email protected]8286f51a2011-05-31 17:39:13539 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44540 const ViewHostMsg_FrameNavigate_Params& params);
541 void DidNavigateAnyFramePostCommit(
[email protected]eaabba22012-03-07 15:02:11542 content::RenderViewHost* render_view_host,
[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
[email protected]74ce1ad2011-12-16 21:51:46546 // If our controller was restored, update the max page ID associated with the
547 // given RenderViewHost to be larger than the number of restored entries.
548 // This is called in CreateRenderView before any navigations in the RenderView
549 // have begun, to prevent any races in updating RenderView::next_page_id.
[email protected]eaabba22012-03-07 15:02:11550 void UpdateMaxPageIDIfNecessary(content::RenderViewHost* rvh);
[email protected]0dd3a0ab2011-02-18 08:17:44551
[email protected]0dd3a0ab2011-02-18 08:17:44552 // Saves the given title to the navigation entry and does associated work. It
553 // will update history and the view for the new title, and also synthesize
554 // titles for file URLs that have none (so we require that the URL of the
555 // entry already be set).
556 //
557 // This is used as the backend for state updates, which include a new title,
558 // or the dedicated set title message. It returns true if the new title is
559 // different and was therefore updated.
[email protected]10f417c52011-12-28 21:04:23560 bool UpdateTitleForEntry(content::NavigationEntryImpl* entry,
561 const string16& title);
[email protected]0dd3a0ab2011-02-18 08:17:44562
[email protected]b172aee2012-04-10 17:05:26563 // Causes the WebContentsImpl to navigate in the right renderer to |entry|,
564 // which must be already part of the entries in the navigation controller.
[email protected]0dd3a0ab2011-02-18 08:17:44565 // This does not change the NavigationController state.
[email protected]10f417c52011-12-28 21:04:23566 bool NavigateToEntry(const content::NavigationEntryImpl& entry,
[email protected]71fde352011-12-29 03:29:56567 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44568
[email protected]b172aee2012-04-10 17:05:26569 // Sets the history for this WebContentsImpl to |history_length| entries, and
[email protected]796931a92011-08-10 01:32:14570 // moves the current page_id to the last entry in the list if it's valid.
571 // This is mainly used when a prerendered page is swapped into the current
[email protected]9e1ad4b2011-08-14 16:49:19572 // tab. The method is virtual for testing.
[email protected]b6583592012-01-25 19:52:33573 virtual void SetHistoryLengthAndPrune(
574 const content::SiteInstance* site_instance,
575 int merge_history_length,
576 int32 minimum_page_id);
[email protected]796931a92011-08-10 01:32:14577
[email protected]14392a52012-05-02 20:28:44578 // Recursively creates swapped out RenderViews for this tab's opener chain
579 // (including this tab) in the given SiteInstance, allowing other tabs to send
580 // cross-process JavaScript calls to their opener(s). Returns the route ID of
581 // this tab's RenderView for |instance|.
582 int CreateOpenerRenderViews(content::SiteInstance* instance);
583
[email protected]bafe6cd2012-05-23 23:09:50584 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
585 void CreateNewWidget(int route_id,
586 bool is_fullscreen,
587 WebKit::WebPopupType popup_type);
588
589 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
590 void ShowCreatedWidget(int route_id,
591 bool is_fullscreen,
592 const gfx::Rect& initial_pos);
593
594 // Finds the new RenderWidgetHost and returns it. Note that this can only be
595 // called once as this call also removes it from the internal map.
596 content::RenderWidgetHostView* GetCreatedWidget(int route_id);
597
598 // Finds the new WebContentsImpl by route_id, initializes it for
599 // renderer-initiated creation, and returns it. Note that this can only be
600 // called once as this call also removes it from the internal map.
601 WebContentsImpl* GetCreatedWindow(int route_id);
602
[email protected]0dd3a0ab2011-02-18 08:17:44603 // Misc non-view stuff -------------------------------------------------------
604
605 // Helper functions for sending notifications.
606 void NotifySwapped();
607 void NotifyConnected();
608 void NotifyDisconnected();
609
[email protected]be1f56ab2011-12-22 06:55:31610 void SetEncoding(const std::string& encoding);
611
[email protected]27678b2a2012-02-04 22:09:14612 // Save a URL to the local filesystem.
[email protected]20b433a2012-05-15 21:23:46613 void SaveURL(const GURL& url,
614 const content::Referrer& referrer,
615 bool is_main_frame);
[email protected]27678b2a2012-02-04 22:09:14616
[email protected]eaabba22012-03-07 15:02:11617 content::RenderViewHostImpl* GetRenderViewHostImpl();
[email protected]9f76c1e2012-03-05 15:15:58618
[email protected]7900bfdb2012-05-24 19:31:24619 void GetBrowserPluginEmbedderInfo(content::RenderViewHost* render_view_host,
620 std::string* embedder_channel_name,
621 int* embedder_container_id);
622
[email protected]81898992011-06-14 22:15:00623 // Stores random bits of data for others to associate with this object.
624 // WARNING: this needs to be deleted after NavigationController.
[email protected]45644f62011-11-23 00:58:23625 base::PropertyBag property_bag_;
[email protected]81898992011-06-14 22:15:00626
[email protected]0dd3a0ab2011-02-18 08:17:44627 // Data for core operation ---------------------------------------------------
628
629 // Delegate for notifying our owner about stuff. Not owned by us.
[email protected]674bc592011-12-20 23:00:42630 content::WebContentsDelegate* delegate_;
[email protected]0dd3a0ab2011-02-18 08:17:44631
632 // Handles the back/forward list and loading.
[email protected]d202a7c2012-01-04 07:53:47633 NavigationControllerImpl controller_;
[email protected]0dd3a0ab2011-02-18 08:17:44634
635 // The corresponding view.
[email protected]8643e6d2012-01-18 20:26:10636 scoped_ptr<content::WebContentsView> view_;
[email protected]0dd3a0ab2011-02-18 08:17:44637
[email protected]5a3bdf52012-05-24 15:12:57638 // The view of the RVHD. Usually this is our WebContentsView implementation,
639 // but if an embedder uses a different WebContentsView, they'll need to
640 // provide this.
641 content::RenderViewHostDelegateView* render_view_host_delegate_view_;
642
[email protected]bafe6cd2012-05-23 23:09:50643 // Tracks created WebContentsImpl objects that have not been shown yet. They
644 // are identified by the route ID passed to CreateNewWindow.
645 typedef std::map<int, WebContentsImpl*> PendingContents;
646 PendingContents pending_contents_;
647
648 // These maps hold on to the widgets that we created on behalf of the renderer
649 // that haven't shown yet.
650 typedef std::map<int, content::RenderWidgetHostView*> PendingWidgetViews;
651 PendingWidgetViews pending_widget_views_;
652
[email protected]996042972011-11-08 22:43:59653 // A list of observers notified when page state changes. Weak references.
654 // This MUST be listed above render_manager_ since at destruction time the
655 // latter might cause RenderViewHost's destructor to call us and we might use
656 // the observer list then.
[email protected]d8c660432011-12-22 20:51:25657 ObserverList<content::WebContentsObserver> observers_;
[email protected]996042972011-11-08 22:43:59658
[email protected]14392a52012-05-02 20:28:44659 // The tab that opened this tab, if any. Will be set to null if the opener
660 // is closed.
661 WebContentsImpl* opener_;
662
[email protected]86ef6a392012-05-11 22:03:11663 // User agent to use if a NavigationEntry requires that the default user agent
664 // is overridden.
665 std::string user_agent_override_;
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]b172aee2012-04-10 17:05:26799 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
[email protected]0dd3a0ab2011-02-18 08:17:44800};
801
[email protected]93ddb3c2012-04-11 21:44:29802#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_