blob: d4fc8b772a901d8ef7a2110b72f6e82b1ba7fbfa [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;
344 virtual content::RendererPreferences GetRendererPrefs(
345 content::BrowserContext* browser_context) const OVERRIDE;
[email protected]6717bf272012-05-11 23:31:25346 virtual webkit_glue::WebPreferences GetWebkitPrefs() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10347 virtual void OnUserGesture() OVERRIDE;
348 virtual void OnIgnoredUIEvent() OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11349 virtual void RendererUnresponsive(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10350 bool is_during_unload) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11351 virtual void RendererResponsive(
352 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10353 virtual void LoadStateChanged(const GURL& url,
354 const net::LoadStateWithParam& load_state,
355 uint64 upload_position,
356 uint64 upload_size) OVERRIDE;
357 virtual void WorkerCrashed() OVERRIDE;
358 virtual void Activate() OVERRIDE;
359 virtual void Deactivate() OVERRIDE;
360 virtual void LostCapture() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10361 virtual void HandleMouseDown() OVERRIDE;
362 virtual void HandleMouseUp() OVERRIDE;
363 virtual void HandleMouseActivate() OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38364 virtual void RunFileChooser(
[email protected]eaabba22012-03-07 15:02:11365 content::RenderViewHost* render_view_host,
[email protected]8caadeb2011-11-22 02:45:23366 const content::FileChooserParams& params) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10367 virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
368 virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
369 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
[email protected]61e2b3cc2012-03-02 16:13:34370 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
[email protected]42252e02012-04-26 16:29:39371 virtual void RequestToLockMouse(bool user_gesture) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10372 virtual void LostMouseLock() OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50373 virtual void CreateNewWindow(
374 int route_id,
375 const ViewHostMsg_CreateWindow_Params& params) OVERRIDE;
376 virtual void CreateNewWidget(int route_id,
377 WebKit::WebPopupType popup_type) OVERRIDE;
378 virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
379 virtual void ShowCreatedWindow(int route_id,
380 WindowOpenDisposition disposition,
381 const gfx::Rect& initial_pos,
382 bool user_gesture) OVERRIDE;
383 virtual void ShowCreatedWidget(int route_id,
384 const gfx::Rect& initial_pos) OVERRIDE;
385 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
386 virtual void ShowContextMenu(
387 const content::ContextMenuParams& params) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10388
[email protected]4ca76c02012-05-16 16:19:05389 // RenderWidgetHostDelegate --------------------------------------------------
390
[email protected]b87ee522012-05-18 15:16:54391 virtual bool PreHandleKeyboardEvent(
392 const content::NativeWebKeyboardEvent& event,
393 bool* is_keyboard_shortcut) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05394 virtual void HandleKeyboardEvent(
[email protected]b87ee522012-05-18 15:16:54395 const content::NativeWebKeyboardEvent& event) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05396
[email protected]0bfbf882011-12-22 18:19:27397 // RenderViewHostManager::Delegate -------------------------------------------
398
399 virtual bool CreateRenderViewForRenderManager(
[email protected]14392a52012-05-02 20:28:44400 content::RenderViewHost* render_view_host, int opener_route_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27401 virtual void BeforeUnloadFiredFromRenderManager(
402 bool proceed,
403 bool* proceed_to_fire_unload) OVERRIDE;
404 virtual void DidStartLoadingFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11405 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27406 virtual void RenderViewGoneFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11407 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27408 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
409 virtual void NotifySwappedFromRenderManager() OVERRIDE;
[email protected]14392a52012-05-02 20:28:44410 virtual int CreateOpenerRenderViewsForRenderManager(
411 content::SiteInstance* instance) OVERRIDE;
[email protected]d202a7c2012-01-04 07:53:47412 virtual NavigationControllerImpl& GetControllerForRenderManager() OVERRIDE;
[email protected]d2353452012-01-19 19:53:56413 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
[email protected]ad23a092011-12-28 07:02:04414 virtual content::NavigationEntry*
[email protected]0bfbf882011-12-22 18:19:27415 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
416 virtual bool FocusLocationBarByDefault() OVERRIDE;
417 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11418 virtual void CreateViewAndSetSizeForRVH(
419 content::RenderViewHost* rvh) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27420
[email protected]14392a52012-05-02 20:28:44421 // content::NotificationObserver ---------------------------------------------
422
423 virtual void Observe(int type,
424 const content::NotificationSource& source,
425 const content::NotificationDetails& details) OVERRIDE;
426
[email protected]0dd3a0ab2011-02-18 08:17:44427 protected:
[email protected]d8c660432011-12-22 20:51:25428 friend class content::WebContentsObserver;
[email protected]553602e12011-04-05 17:01:18429
430 // Add and remove observers for page navigation notifications. Adding or
431 // removing multiple times has no effect. The order in which notifications
432 // are sent to observers is undefined. Clients must be sure to remove the
433 // observer before they go away.
[email protected]d8c660432011-12-22 20:51:25434 void AddObserver(content::WebContentsObserver* observer);
435 void RemoveObserver(content::WebContentsObserver* observer);
[email protected]553602e12011-04-05 17:01:18436
[email protected]0dd3a0ab2011-02-18 08:17:44437 private:
[email protected]d202a7c2012-01-04 07:53:47438 friend class NavigationControllerImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44439
[email protected]2db9bd72012-04-13 20:20:56440 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
441 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
442 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
443 CrossSiteCantPreemptAfterUnload);
[email protected]0dd3a0ab2011-02-18 08:17:44444 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
445 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
446 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
447
[email protected]cadaec52012-02-08 21:53:13448 // So InterstitialPageImpl can access SetIsLoading.
449 friend class InterstitialPageImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44450
[email protected]80e776ae2012-03-23 16:17:20451 // TODO(brettw) TestWebContents shouldn't exist!
452 friend class content::TestWebContents;
[email protected]0dd3a0ab2011-02-18 08:17:44453
[email protected]14392a52012-05-02 20:28:44454 // Clears this tab's opener if it has been closed.
455 void OnWebContentsDestroyed(content::WebContents* web_contents);
456
[email protected]51da7e32012-01-30 19:24:52457 // Callback function when showing JS dialogs.
[email protected]eaabba22012-03-07 15:02:11458 void OnDialogClosed(content::RenderViewHost* rvh,
[email protected]51da7e32012-01-30 19:24:52459 IPC::Message* reply_msg,
460 bool success,
461 const string16& user_input);
462
[email protected]d0759f492012-04-19 22:50:50463 // IPC message handlers.
[email protected]8b5af492011-11-28 21:50:58464 void OnRegisterIntentService(const string16& action,
[email protected]63c239322011-10-31 23:56:30465 const string16& type,
466 const string16& href,
467 const string16& title,
468 const string16& disposition);
[email protected]678105012011-12-09 04:01:21469 void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
[email protected]63c239322011-10-31 23:56:30470 int intent_id);
[email protected]0dd3a0ab2011-02-18 08:17:44471 void OnDidLoadResourceFromMemoryCache(const GURL& url,
[email protected]70435962011-08-02 20:13:28472 const std::string& security_info,
473 const std::string& http_request,
[email protected]6d6cfb3a2012-05-23 22:53:18474 const std::string& mime_type,
[email protected]70435962011-08-02 20:13:28475 ResourceType::Type resource_type);
[email protected]0dd3a0ab2011-02-18 08:17:44476 void OnDidDisplayInsecureContent();
477 void OnDidRunInsecureContent(const std::string& security_origin,
478 const GURL& target_url);
479 void OnDocumentLoadedInFrame(int64 frame_id);
[email protected]1a55c5be2011-11-29 11:36:31480 void OnDidFinishLoad(int64 frame_id,
481 const GURL& validated_url,
482 bool is_main_frame);
483 void OnDidFailLoadWithError(int64 frame_id,
484 const GURL& validated_url,
485 bool is_main_frame,
486 int error_code,
487 const string16& error_description);
[email protected]0dd3a0ab2011-02-18 08:17:44488 void OnUpdateContentRestrictions(int restrictions);
[email protected]0dd3a0ab2011-02-18 08:17:44489 void OnGoToEntryAtOffset(int offset);
[email protected]216813952011-05-19 22:21:26490 void OnUpdateZoomLimits(int minimum_percent,
491 int maximum_percent,
492 bool remember);
[email protected]20b433a2012-05-15 21:23:46493 void OnSaveURL(const GURL& url, const content::Referrer& referrer);
[email protected]3a29a6e2011-08-24 18:26:21494 void OnEnumerateDirectory(int request_id, const FilePath& path);
[email protected]7d189022011-08-25 22:54:20495 void OnJSOutOfMemory();
[email protected]b7a756d42012-01-23 18:08:17496
[email protected]7d189022011-08-25 22:54:20497 void OnRegisterProtocolHandler(const std::string& protocol,
498 const GURL& url,
499 const string16& title);
[email protected]b888919c2011-09-02 00:32:16500 void OnFindReply(int request_id, int number_of_matches,
501 const gfx::Rect& selection_rect, int active_match_ordinal,
502 bool final_update);
[email protected]d952a052011-09-06 18:42:45503 void OnCrashedPlugin(const FilePath& plugin_path);
[email protected]7fc4bbb2011-09-08 21:23:10504 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
[email protected]55578b0a2012-04-18 14:31:32505 void OnOpenColorChooser(int color_chooser_id, SkColor color);
[email protected]da8543762012-03-20 08:52:20506 void OnEndColorChooser(int color_chooser_id);
[email protected]55578b0a2012-04-18 14:31:32507 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
[email protected]8be45842012-04-13 19:49:29508 void OnPepperPluginHung(int plugin_child_id,
509 const FilePath& path,
510 bool is_hung);
[email protected]d0759f492012-04-19 22:50:50511 void OnWebUISend(const GURL& source_url,
512 const std::string& name,
513 const base::ListValue& args);
[email protected]0dd3a0ab2011-02-18 08:17:44514
515 // Changes the IsLoading state and notifies delegate as needed
516 // |details| is used to provide details on the load that just finished
517 // (but can be null if not applicable). Can be overridden.
518 void SetIsLoading(bool is_loading,
[email protected]09d31d52012-03-11 22:30:27519 content::LoadNotificationDetails* details);
[email protected]0dd3a0ab2011-02-18 08:17:44520
[email protected]0dd3a0ab2011-02-18 08:17:44521 // Called by derived classes to indicate that we're no longer waiting for a
522 // response. This won't actually update the throbber, but it will get picked
523 // up at the next animation step if the throbber is going.
524 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
525
[email protected]0dd3a0ab2011-02-18 08:17:44526 // Navigation helpers --------------------------------------------------------
527 //
528 // These functions are helpers for Navigate() and DidNavigate().
529
530 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
531 // committed to the navigation controller. Note that the navigation entry is
532 // not provided since it may be invalid/changed after being committed. The
533 // current navigation entry is in the NavigationController at this point.
534 void DidNavigateMainFramePostCommit(
[email protected]8286f51a2011-05-31 17:39:13535 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44536 const ViewHostMsg_FrameNavigate_Params& params);
537 void DidNavigateAnyFramePostCommit(
[email protected]eaabba22012-03-07 15:02:11538 content::RenderViewHost* render_view_host,
[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
[email protected]74ce1ad2011-12-16 21:51:46542 // If our controller was restored, update the max page ID associated with the
543 // given RenderViewHost to be larger than the number of restored entries.
544 // This is called in CreateRenderView before any navigations in the RenderView
545 // have begun, to prevent any races in updating RenderView::next_page_id.
[email protected]eaabba22012-03-07 15:02:11546 void UpdateMaxPageIDIfNecessary(content::RenderViewHost* rvh);
[email protected]0dd3a0ab2011-02-18 08:17:44547
[email protected]0dd3a0ab2011-02-18 08:17:44548 // Saves the given title to the navigation entry and does associated work. It
549 // will update history and the view for the new title, and also synthesize
550 // titles for file URLs that have none (so we require that the URL of the
551 // entry already be set).
552 //
553 // This is used as the backend for state updates, which include a new title,
554 // or the dedicated set title message. It returns true if the new title is
555 // different and was therefore updated.
[email protected]10f417c52011-12-28 21:04:23556 bool UpdateTitleForEntry(content::NavigationEntryImpl* entry,
557 const string16& title);
[email protected]0dd3a0ab2011-02-18 08:17:44558
[email protected]b172aee2012-04-10 17:05:26559 // Causes the WebContentsImpl to navigate in the right renderer to |entry|,
560 // which must be already part of the entries in the navigation controller.
[email protected]0dd3a0ab2011-02-18 08:17:44561 // This does not change the NavigationController state.
[email protected]10f417c52011-12-28 21:04:23562 bool NavigateToEntry(const content::NavigationEntryImpl& entry,
[email protected]71fde352011-12-29 03:29:56563 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44564
[email protected]b172aee2012-04-10 17:05:26565 // Sets the history for this WebContentsImpl to |history_length| entries, and
[email protected]796931a92011-08-10 01:32:14566 // moves the current page_id to the last entry in the list if it's valid.
567 // This is mainly used when a prerendered page is swapped into the current
[email protected]9e1ad4b2011-08-14 16:49:19568 // tab. The method is virtual for testing.
[email protected]b6583592012-01-25 19:52:33569 virtual void SetHistoryLengthAndPrune(
570 const content::SiteInstance* site_instance,
571 int merge_history_length,
572 int32 minimum_page_id);
[email protected]796931a92011-08-10 01:32:14573
[email protected]14392a52012-05-02 20:28:44574 // Recursively creates swapped out RenderViews for this tab's opener chain
575 // (including this tab) in the given SiteInstance, allowing other tabs to send
576 // cross-process JavaScript calls to their opener(s). Returns the route ID of
577 // this tab's RenderView for |instance|.
578 int CreateOpenerRenderViews(content::SiteInstance* instance);
579
[email protected]bafe6cd2012-05-23 23:09:50580 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
581 void CreateNewWidget(int route_id,
582 bool is_fullscreen,
583 WebKit::WebPopupType popup_type);
584
585 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
586 void ShowCreatedWidget(int route_id,
587 bool is_fullscreen,
588 const gfx::Rect& initial_pos);
589
590 // Finds the new RenderWidgetHost and returns it. Note that this can only be
591 // called once as this call also removes it from the internal map.
592 content::RenderWidgetHostView* GetCreatedWidget(int route_id);
593
594 // Finds the new WebContentsImpl by route_id, initializes it for
595 // renderer-initiated creation, and returns it. Note that this can only be
596 // called once as this call also removes it from the internal map.
597 WebContentsImpl* GetCreatedWindow(int route_id);
598
[email protected]0dd3a0ab2011-02-18 08:17:44599 // Misc non-view stuff -------------------------------------------------------
600
601 // Helper functions for sending notifications.
602 void NotifySwapped();
603 void NotifyConnected();
604 void NotifyDisconnected();
605
[email protected]be1f56ab2011-12-22 06:55:31606 void SetEncoding(const std::string& encoding);
607
[email protected]27678b2a2012-02-04 22:09:14608 // Save a URL to the local filesystem.
[email protected]20b433a2012-05-15 21:23:46609 void SaveURL(const GURL& url,
610 const content::Referrer& referrer,
611 bool is_main_frame);
[email protected]27678b2a2012-02-04 22:09:14612
[email protected]eaabba22012-03-07 15:02:11613 content::RenderViewHostImpl* GetRenderViewHostImpl();
[email protected]9f76c1e2012-03-05 15:15:58614
[email protected]7900bfdb2012-05-24 19:31:24615 void GetBrowserPluginEmbedderInfo(content::RenderViewHost* render_view_host,
616 std::string* embedder_channel_name,
617 int* embedder_container_id);
618
[email protected]81898992011-06-14 22:15:00619 // Stores random bits of data for others to associate with this object.
620 // WARNING: this needs to be deleted after NavigationController.
[email protected]45644f62011-11-23 00:58:23621 base::PropertyBag property_bag_;
[email protected]81898992011-06-14 22:15:00622
[email protected]0dd3a0ab2011-02-18 08:17:44623 // Data for core operation ---------------------------------------------------
624
625 // Delegate for notifying our owner about stuff. Not owned by us.
[email protected]674bc592011-12-20 23:00:42626 content::WebContentsDelegate* delegate_;
[email protected]0dd3a0ab2011-02-18 08:17:44627
628 // Handles the back/forward list and loading.
[email protected]d202a7c2012-01-04 07:53:47629 NavigationControllerImpl controller_;
[email protected]0dd3a0ab2011-02-18 08:17:44630
631 // The corresponding view.
[email protected]8643e6d2012-01-18 20:26:10632 scoped_ptr<content::WebContentsView> view_;
[email protected]0dd3a0ab2011-02-18 08:17:44633
[email protected]5a3bdf52012-05-24 15:12:57634 // The view of the RVHD. Usually this is our WebContentsView implementation,
635 // but if an embedder uses a different WebContentsView, they'll need to
636 // provide this.
637 content::RenderViewHostDelegateView* render_view_host_delegate_view_;
638
[email protected]bafe6cd2012-05-23 23:09:50639 // Tracks created WebContentsImpl objects that have not been shown yet. They
640 // are identified by the route ID passed to CreateNewWindow.
641 typedef std::map<int, WebContentsImpl*> PendingContents;
642 PendingContents pending_contents_;
643
644 // These maps hold on to the widgets that we created on behalf of the renderer
645 // that haven't shown yet.
646 typedef std::map<int, content::RenderWidgetHostView*> PendingWidgetViews;
647 PendingWidgetViews pending_widget_views_;
648
[email protected]996042972011-11-08 22:43:59649 // A list of observers notified when page state changes. Weak references.
650 // This MUST be listed above render_manager_ since at destruction time the
651 // latter might cause RenderViewHost's destructor to call us and we might use
652 // the observer list then.
[email protected]d8c660432011-12-22 20:51:25653 ObserverList<content::WebContentsObserver> observers_;
[email protected]996042972011-11-08 22:43:59654
[email protected]14392a52012-05-02 20:28:44655 // The tab that opened this tab, if any. Will be set to null if the opener
656 // is closed.
657 WebContentsImpl* opener_;
658
[email protected]86ef6a392012-05-11 22:03:11659 // User agent to use if a NavigationEntry requires that the default user agent
660 // is overridden.
661 std::string user_agent_override_;
662
[email protected]0dd3a0ab2011-02-18 08:17:44663 // Helper classes ------------------------------------------------------------
664
665 // Manages creation and swapping of render views.
666 RenderViewHostManager render_manager_;
667
[email protected]483623eb2011-10-25 09:30:00668 // Manages injecting Java objects into all RenderViewHosts associated with
[email protected]b172aee2012-04-10 17:05:26669 // this WebContentsImpl.
[email protected]483623eb2011-10-25 09:30:00670 scoped_ptr<JavaBridgeDispatcherHostManager>
671 java_bridge_dispatcher_host_manager_;
672
[email protected]172cf712012-05-23 15:07:39673 // Manages the browser plugin instances hosted by this WebContents.
674 scoped_ptr<content::BrowserPluginHost> browser_plugin_host_;
675
[email protected]c7dd2f62011-07-18 15:57:59676 // SavePackage, lazily created.
677 scoped_refptr<SavePackage> save_package_;
678
[email protected]0dd3a0ab2011-02-18 08:17:44679 // Data for loading state ----------------------------------------------------
680
681 // Indicates whether we're currently loading a resource.
682 bool is_loading_;
683
684 // Indicates if the tab is considered crashed.
685 base::TerminationStatus crashed_status_;
686 int crashed_error_code_;
687
[email protected]ca13a442012-04-17 14:00:12688 // Whether this WebContents is waiting for a first-response for the
[email protected]be1f56ab2011-12-22 06:55:31689 // main resource of the page. This controls whether the throbber state is
690 // "waiting" or "loading."
[email protected]0dd3a0ab2011-02-18 08:17:44691 bool waiting_for_response_;
692
[email protected]74ce1ad2011-12-16 21:51:46693 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
694 // to a given tab and SiteInstance, and must be valid for the lifetime of the
[email protected]b172aee2012-04-10 17:05:26695 // WebContentsImpl.
[email protected]74ce1ad2011-12-16 21:51:46696 std::map<int32, int32> max_page_ids_;
[email protected]0dd3a0ab2011-02-18 08:17:44697
698 // System time at which the current load was started.
699 base::TimeTicks current_load_start_;
700
701 // The current load state and the URL associated with it.
[email protected]9c235f042011-08-10 22:28:21702 net::LoadStateWithParam load_state_;
[email protected]0dd3a0ab2011-02-18 08:17:44703 string16 load_state_host_;
704 // Upload progress, for displaying in the status bar.
705 // Set to zero when there is no significant upload happening.
706 uint64 upload_size_;
707 uint64 upload_position_;
708
709 // Data for current page -----------------------------------------------------
710
[email protected]987fc3a2011-05-26 14:18:09711 // When a title cannot be taken from any entry, this title will be used.
712 string16 page_title_when_no_navigation_entry_;
713
[email protected]0dd3a0ab2011-02-18 08:17:44714 // When a navigation occurs, we record its contents MIME type. It can be
715 // used to check whether we can do something for some special contents.
716 std::string contents_mime_type_;
717
718 // Character encoding.
719 std::string encoding_;
720
[email protected]0dd3a0ab2011-02-18 08:17:44721 // True if this is a secure page which displayed insecure content.
722 bool displayed_insecure_content_;
723
[email protected]0dd3a0ab2011-02-18 08:17:44724 // Data for misc internal state ----------------------------------------------
725
[email protected]ca13a442012-04-17 14:00:12726 // Whether the WebContents is currently being screenshotted.
[email protected]0dd3a0ab2011-02-18 08:17:44727 bool capturing_contents_;
728
729 // See getter above.
730 bool is_being_destroyed_;
731
732 // Indicates whether we should notify about disconnection of this
[email protected]b172aee2012-04-10 17:05:26733 // WebContentsImpl. This is used to ensure disconnection notifications only
[email protected]0dd3a0ab2011-02-18 08:17:44734 // happen if a connection notification has happened and that they happen only
735 // once.
736 bool notify_disconnection_;
737
[email protected]2e5b90c2011-08-16 21:11:55738 // Pointer to the JavaScript dialog creator, lazily assigned. Used because the
[email protected]b172aee2012-04-10 17:05:26739 // delegate of this WebContentsImpl is nulled before its destructor is called.
[email protected]2e5b90c2011-08-16 21:11:55740 content::JavaScriptDialogCreator* dialog_creator_;
741
[email protected]0dd3a0ab2011-02-18 08:17:44742#if defined(OS_WIN)
743 // Handle to an event that's set when the page is showing a message box (or
744 // equivalent constrained window). Plugin processes check this to know if
745 // they should pump messages then.
746 base::win::ScopedHandle message_box_active_;
747#endif
748
[email protected]0dd3a0ab2011-02-18 08:17:44749 // Set to true when there is an active "before unload" dialog. When true,
750 // we've forced the throbber to start in Navigate, and we need to remember to
751 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
752 bool is_showing_before_unload_dialog_;
753
[email protected]0dd3a0ab2011-02-18 08:17:44754 // Settings that get passed to the renderer process.
[email protected]daf82f82011-10-31 22:35:31755 content::RendererPreferences renderer_preferences_;
[email protected]0dd3a0ab2011-02-18 08:17:44756
757 // If this tab was created from a renderer using window.open, this will be
758 // non-NULL and represent the WebUI of the opening renderer.
[email protected]01ec4ec2012-01-18 04:13:47759 content::WebUI::TypeID opener_web_ui_type_;
[email protected]0dd3a0ab2011-02-18 08:17:44760
761 // The time that we started to create the new tab page.
762 base::TimeTicks new_tab_start_time_;
763
[email protected]3bbacc5b2012-04-17 17:46:15764 // The time that we started to close this WebContents.
765 base::TimeTicks close_start_time_;
[email protected]0dd3a0ab2011-02-18 08:17:44766
767 // The time that this tab was last selected.
768 base::TimeTicks last_selected_time_;
769
[email protected]0dd3a0ab2011-02-18 08:17:44770 // See description above setter.
771 bool closed_by_user_gesture_;
772
773 // Minimum/maximum zoom percent.
774 int minimum_zoom_percent_;
775 int maximum_zoom_percent_;
776 // If true, the default zoom limits have been overriden for this tab, in which
777 // case we don't want saved settings to apply to it and we don't want to
778 // remember it.
779 bool temporary_zoom_settings_;
780
[email protected]bcd2815602012-01-14 18:17:23781 // The intrinsic size of the page.
782 gfx::Size preferred_size_;
783
[email protected]0dd3a0ab2011-02-18 08:17:44784 // Content restrictions, used to disable print/copy etc based on content's
785 // (full-page plugins for now only) permissions.
786 int content_restrictions_;
787
[email protected]da8543762012-03-20 08:52:20788 // Color chooser that was opened by this tab.
789 content::ColorChooser* color_chooser_;
790
[email protected]f53a9f872012-05-24 02:07:06791 // This must be at the end, or else we might get notifications and use other
792 // member variables that are gone.
793 content::NotificationRegistrar registrar_;
794
[email protected]b172aee2012-04-10 17:05:26795 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
[email protected]0dd3a0ab2011-02-18 08:17:44796};
797
[email protected]93ddb3c2012-04-11 21:44:29798#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_