blob: 7a9c198363733ca191eedd35633fac89079e50fe [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]97714c82012-06-06 10:15:1363
64} // namespace content
[email protected]e582fdd2011-12-20 16:48:1765
[email protected]daf82f82011-10-31 22:35:3166namespace webkit_glue {
67struct WebIntentData;
[email protected]3a3b75a2012-06-01 08:38:3668struct WebIntentServiceData;
[email protected]daf82f82011-10-31 22:35:3169}
[email protected]0dd3a0ab2011-02-18 08:17:4470
[email protected]b172aee2012-04-10 17:05:2671class CONTENT_EXPORT WebContentsImpl
[email protected]01d65172011-12-25 04:39:3072 : public NON_EXPORTED_BASE(content::WebContents),
[email protected]b0b67cf2012-01-18 21:59:5773 public content::RenderViewHostDelegate,
[email protected]4ca76c02012-05-16 16:19:0574 public content::RenderWidgetHostDelegate,
[email protected]14392a52012-05-02 20:28:4475 public RenderViewHostManager::Delegate,
76 public content::NotificationObserver {
[email protected]0dd3a0ab2011-02-18 08:17:4477 public:
[email protected]a81343d232011-12-27 07:39:2078 // See WebContents::Create for a description of these parameters.
[email protected]b172aee2012-04-10 17:05:2679 WebContentsImpl(content::BrowserContext* browser_context,
80 content::SiteInstance* site_instance,
81 int routing_id,
82 const WebContentsImpl* base_web_contents,
[email protected]14392a52012-05-02 20:28:4483 WebContentsImpl* opener,
[email protected]b172aee2012-04-10 17:05:2684 SessionStorageNamespaceImpl* session_storage_namespace);
85 virtual ~WebContentsImpl();
[email protected]0dd3a0ab2011-02-18 08:17:4486
[email protected]64d69de42012-02-06 00:19:5487 // Returns the content specific prefs for the given RVH.
[email protected]6717bf272012-05-11 23:31:2588 static webkit_glue::WebPreferences GetWebkitPrefs(
[email protected]eaabba22012-03-07 15:02:1189 content::RenderViewHost* rvh, const GURL& url);
[email protected]64d69de42012-02-06 00:19:5490
[email protected]c7dd2f62011-07-18 15:57:5991 // Returns the SavePackage which manages the page saving job. May be NULL.
92 SavePackage* save_package() const { return save_package_.get(); }
93
[email protected]b172aee2012-04-10 17:05:2694 // Updates the max page ID for the current SiteInstance in this
95 // WebContentsImpl to be at least |page_id|.
[email protected]0dd3a0ab2011-02-18 08:17:4496 void UpdateMaxPageID(int32 page_id);
97
[email protected]b172aee2012-04-10 17:05:2698 // Updates the max page ID for the given SiteInstance in this WebContentsImpl
[email protected]74ce1ad2011-12-16 21:51:4699 // to be at least |page_id|.
[email protected]b6583592012-01-25 19:52:33100 void UpdateMaxPageIDForSiteInstance(content::SiteInstance* site_instance,
[email protected]74ce1ad2011-12-16 21:51:46101 int32 page_id);
102
[email protected]91854cd2012-01-10 19:43:57103 // Copy the current map of SiteInstance ID to max page ID from another tab.
104 // This is necessary when this tab adopts the NavigationEntries from
[email protected]b172aee2012-04-10 17:05:26105 // |web_contents|.
106 void CopyMaxPageIDsFrom(WebContentsImpl* web_contents);
[email protected]91854cd2012-01-10 19:43:57107
[email protected]b172aee2012-04-10 17:05:26108 // Called by the NavigationController to cause the WebContentsImpl to navigate
109 // to the current pending entry. The NavigationController should be called
110 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
[email protected]9a7e68c2011-05-26 17:35:50111 // The callbacks can be inside of this function, or at some future time.
[email protected]0dd3a0ab2011-02-18 08:17:44112 //
113 // The entry has a PageID of -1 if newly created (corresponding to navigation
114 // to a new URL).
115 //
116 // If this method returns false, then the navigation is discarded (equivalent
117 // to calling DiscardPendingEntry on the NavigationController).
[email protected]0bfbf882011-12-22 18:19:27118 bool NavigateToPendingEntry(
[email protected]71fde352011-12-29 03:29:56119 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44120
[email protected]ba45bfd2012-05-22 21:51:44121 // Called by InterstitialPageImpl when it creates a RenderViewHost.
122 void RenderViewForInterstitialPageCreated(
123 content::RenderViewHost* render_view_host);
124
[email protected]0dd3a0ab2011-02-18 08:17:44125 // Sets the passed passed interstitial as the currently showing interstitial.
126 // |interstitial_page| should be non NULL (use the remove_interstitial_page
127 // method to unset the interstitial) and no interstitial page should be set
128 // when there is already a non NULL interstitial page set.
[email protected]cadaec52012-02-08 21:53:13129 void set_interstitial_page(InterstitialPageImpl* interstitial_page) {
[email protected]0dd3a0ab2011-02-18 08:17:44130 render_manager_.set_interstitial_page(interstitial_page);
131 }
132
133 // Unsets the currently showing interstitial.
134 void remove_interstitial_page() {
135 render_manager_.remove_interstitial_page();
136 }
137
[email protected]01ec4ec2012-01-18 04:13:47138 void set_opener_web_ui_type(content::WebUI::TypeID opener_web_ui_type) {
[email protected]0dd3a0ab2011-02-18 08:17:44139 opener_web_ui_type_ = opener_web_ui_type;
140 }
141
[email protected]276b37a22011-11-08 20:45:46142 JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const {
143 return java_bridge_dispatcher_host_manager_.get();
144 }
145
[email protected]172cf712012-05-23 15:07:39146 content::BrowserPluginHost* browser_plugin_host() const {
147 return browser_plugin_host_.get();
148 }
149
[email protected]cdcb1dee2012-01-04 00:46:20150 // Like GetController from WebContents, but returns the concrete object.
[email protected]d202a7c2012-01-04 07:53:47151 NavigationControllerImpl& GetControllerImpl();
[email protected]cdcb1dee2012-01-04 00:46:20152
[email protected]765187182012-01-11 23:59:28153 // Expose the render manager for testing.
154 RenderViewHostManager* GetRenderManagerForTesting();
155
[email protected]58f5d562011-12-20 17:13:03156 // content::WebContents ------------------------------------------------------
[email protected]6934a702011-12-20 00:04:51157 virtual const base::PropertyBag* GetPropertyBag() const OVERRIDE;
158 virtual base::PropertyBag* GetPropertyBag() OVERRIDE;
[email protected]674bc592011-12-20 23:00:42159 virtual content::WebContentsDelegate* GetDelegate() OVERRIDE;
160 virtual void SetDelegate(content::WebContentsDelegate* delegate) OVERRIDE;
[email protected]cdcb1dee2012-01-04 00:46:20161 virtual content::NavigationController& GetController() OVERRIDE;
162 virtual const content::NavigationController& GetController() const OVERRIDE;
[email protected]627e0512011-12-21 22:55:30163 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
[email protected]f5fa20e2011-12-21 22:35:56164 virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11165 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE;
[email protected]5626b0892012-02-20 14:46:58166 virtual content::RenderWidgetHostView*
167 GetRenderWidgetHostView() const OVERRIDE;
[email protected]8643e6d2012-01-18 20:26:10168 virtual content::WebContentsView* GetView() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47169 virtual content::WebUI* CreateWebUI(const GURL& url) OVERRIDE;
170 virtual content::WebUI* GetWebUI() const OVERRIDE;
171 virtual content::WebUI* GetCommittedWebUI() const OVERRIDE;
[email protected]86ef6a392012-05-11 22:03:11172 virtual void SetUserAgentOverride(const std::string& override) OVERRIDE;
173 virtual const std::string& GetUserAgentOverride() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31174 virtual const string16& GetTitle() const OVERRIDE;
175 virtual int32 GetMaxPageID() OVERRIDE;
176 virtual int32 GetMaxPageIDForSiteInstance(
[email protected]b6583592012-01-25 19:52:33177 content::SiteInstance* site_instance) OVERRIDE;
178 virtual content::SiteInstance* GetSiteInstance() const OVERRIDE;
179 virtual content::SiteInstance* GetPendingSiteInstance() const OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31180 virtual bool IsLoading() const OVERRIDE;
181 virtual bool IsWaitingForResponse() const OVERRIDE;
182 virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE;
183 virtual const string16& GetLoadStateHost() const OVERRIDE;
184 virtual uint64 GetUploadSize() const OVERRIDE;
185 virtual uint64 GetUploadPosition() const OVERRIDE;
186 virtual const std::string& GetEncoding() const OVERRIDE;
187 virtual bool DisplayedInsecureContent() const OVERRIDE;
188 virtual void SetCapturingContents(bool cap) OVERRIDE;
189 virtual bool IsCrashed() const OVERRIDE;
190 virtual void SetIsCrashed(base::TerminationStatus status,
191 int error_code) OVERRIDE;
192 virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE;
193 virtual bool IsBeingDestroyed() const OVERRIDE;
194 virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE;
195 virtual void DidBecomeSelected() OVERRIDE;
196 virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE;
197 virtual void WasHidden() OVERRIDE;
[email protected]375fa1b2012-05-22 22:05:37198 virtual void WasRestored() OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31199 virtual void ShowContents() OVERRIDE;
200 virtual void HideContents() OVERRIDE;
201 virtual bool NeedToFireBeforeUnload() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27202 virtual void Stop() OVERRIDE;
[email protected]d9083482012-01-06 00:38:46203 virtual content::WebContents* Clone() OVERRIDE;
[email protected]2a6bc3e2011-12-28 23:51:33204 virtual void AddNewContents(content::WebContents* new_contents,
[email protected]0bfbf882011-12-22 18:19:27205 WindowOpenDisposition disposition,
206 const gfx::Rect& initial_pos,
207 bool user_gesture) OVERRIDE;
208 virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
209 virtual gfx::NativeView GetNativeView() const OVERRIDE;
210 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE;
211 virtual void Focus() OVERRIDE;
212 virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE;
213 virtual bool ShowingInterstitialPage() const OVERRIDE;
[email protected]cadaec52012-02-08 21:53:13214 virtual content::InterstitialPage* GetInterstitialPage() const OVERRIDE;
[email protected]a53209b2012-01-20 16:48:16215 virtual bool IsSavable() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27216 virtual void OnSavePage() OVERRIDE;
217 virtual bool SavePage(const FilePath& main_file,
218 const FilePath& dir_path,
[email protected]a53209b2012-01-20 16:48:16219 content::SavePageType save_type) OVERRIDE;
[email protected]aa4f3972012-03-01 18:12:12220 virtual void GenerateMHTML(
221 const FilePath& file,
222 const base::Callback<void(const FilePath&, int64)>& callback) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27223 virtual bool IsActiveEntry(int32 page_id) OVERRIDE;
224
225 virtual const std::string& GetContentsMimeType() const OVERRIDE;
226 virtual bool WillNotifyDisconnection() const OVERRIDE;
227 virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE;
228 virtual void ResetOverrideEncoding() OVERRIDE;
229 virtual content::RendererPreferences* GetMutableRendererPrefs() OVERRIDE;
230 virtual void SetNewTabStartTime(const base::TimeTicks& time) OVERRIDE;
231 virtual base::TimeTicks GetNewTabStartTime() const OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47232 virtual void Close() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27233 virtual void OnCloseStarted() OVERRIDE;
234 virtual bool ShouldAcceptDragAndDrop() const OVERRIDE;
235 virtual void SystemDragEnded() OVERRIDE;
[email protected]e35ccd52012-05-23 16:22:47236 virtual void UserGestureDone() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27237 virtual void SetClosedByUserGesture(bool value) OVERRIDE;
238 virtual bool GetClosedByUserGesture() const OVERRIDE;
239 virtual double GetZoomLevel() const OVERRIDE;
240 virtual int GetZoomPercent(bool* enable_increment,
241 bool* enable_decrement) OVERRIDE;
242 virtual void ViewSource() OVERRIDE;
243 virtual void ViewFrameSource(const GURL& url,
244 const std::string& content_state) OVERRIDE;
245 virtual int GetMinimumZoomPercent() const OVERRIDE;
246 virtual int GetMaximumZoomPercent() const OVERRIDE;
[email protected]bcd2815602012-01-14 18:17:23247 virtual gfx::Size GetPreferredSize() const OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27248 virtual int GetContentRestrictions() const OVERRIDE;
[email protected]01ec4ec2012-01-18 04:13:47249 virtual content::WebUI::TypeID GetWebUITypeForCurrentState() OVERRIDE;
250 virtual content::WebUI* GetWebUIForCurrentState() OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27251 virtual bool GotResponseToLockMouseRequest(bool allowed) OVERRIDE;
[email protected]a0358d72012-03-09 14:06:50252 virtual bool HasOpener() const OVERRIDE;
[email protected]da8543762012-03-20 08:52:20253 virtual void DidChooseColorInColorChooser(int color_chooser_id,
[email protected]55578b0a2012-04-18 14:31:32254 SkColor color) OVERRIDE;
[email protected]da8543762012-03-20 08:52:20255 virtual void DidEndColorChooser(int color_chooser_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27256
257 // Implementation of PageNavigator.
[email protected]e5d549d2011-12-28 01:29:20258 virtual content::WebContents* OpenURL(
259 const content::OpenURLParams& params) OVERRIDE;
[email protected]151a63d2011-12-20 22:32:52260
[email protected]952a68e2011-11-17 00:36:10261 // RenderViewHostDelegate ----------------------------------------------------
262
[email protected]5a3bdf52012-05-24 15:12:57263 virtual content::RenderViewHostDelegateView* GetDelegateView() OVERRIDE;
[email protected]b0b67cf2012-01-18 21:59:57264 virtual content::RenderViewHostDelegate::RendererManagement*
[email protected]952a68e2011-11-17 00:36:10265 GetRendererManagementDelegate() OVERRIDE;
[email protected]be1f56ab2011-12-22 06:55:31266 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
267 virtual const GURL& GetURL() const OVERRIDE;
[email protected]768c5472011-12-26 19:06:17268 virtual WebContents* GetAsWebContents() OVERRIDE;
[email protected]b7a756d42012-01-23 18:08:17269 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11270 virtual void RenderViewCreated(
271 content::RenderViewHost* render_view_host) OVERRIDE;
272 virtual void RenderViewReady(
273 content::RenderViewHost* render_view_host) OVERRIDE;
274 virtual void RenderViewGone(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10275 base::TerminationStatus status,
276 int error_code) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11277 virtual void RenderViewDeleted(
278 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57279 virtual void DidStartProvisionalLoadForFrame(
280 content::RenderViewHost* render_view_host,
281 int64 frame_id,
282 bool main_frame,
283 const GURL& opener_url,
284 const GURL& url) OVERRIDE;
[email protected]400992b2012-06-14 00:03:54285 virtual void DidRedirectProvisionalLoad(
286 content::RenderViewHost* render_view_host,
287 int32 page_id,
288 const GURL& opener_url,
289 const GURL& source_url,
290 const GURL& target_url) OVERRIDE;
[email protected]54047eb52012-05-08 21:45:57291 virtual void DidFailProvisionalLoadWithError(
292 content::RenderViewHost* render_view_host,
293 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params)
294 OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10295 virtual void DidNavigate(
[email protected]eaabba22012-03-07 15:02:11296 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10297 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11298 virtual void UpdateState(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10299 int32 page_id,
300 const std::string& state) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11301 virtual void UpdateTitle(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10302 int32 page_id,
303 const string16& title,
304 base::i18n::TextDirection title_direction) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11305 virtual void UpdateEncoding(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10306 const std::string& encoding) OVERRIDE;
307 virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11308 virtual void Close(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10309 virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11310 virtual void SwappedOut(content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10311 virtual void DidStartLoading() OVERRIDE;
312 virtual void DidStopLoading() OVERRIDE;
313 virtual void DidCancelLoading() OVERRIDE;
314 virtual void DidChangeLoadProgress(double progress) OVERRIDE;
[email protected]87717d0e2012-04-26 02:58:43315 virtual void DocumentAvailableInMainFrame(
316 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10317 virtual void DocumentOnLoadCompletedInMainFrame(
[email protected]eaabba22012-03-07 15:02:11318 content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10319 int32 page_id) OVERRIDE;
[email protected]196159d2012-05-04 17:26:54320 virtual void RequestOpenURL(content::RenderViewHost* rvh,
321 const GURL& url,
[email protected]445e1042011-12-03 21:03:15322 const content::Referrer& referrer,
[email protected]952a68e2011-11-17 00:36:10323 WindowOpenDisposition disposition,
324 int64 source_frame_id) OVERRIDE;
[email protected]4ad5d77d2011-12-03 02:00:48325 virtual void RequestTransferURL(
326 const GURL& url,
[email protected]bce1f1c2011-12-05 15:11:58327 const content::Referrer& referrer,
[email protected]4ad5d77d2011-12-03 02:00:48328 WindowOpenDisposition disposition,
329 int64 source_frame_id,
[email protected]e5d549d2011-12-28 01:29:20330 const content::GlobalRequestID& transferred_global_request_id) OVERRIDE;
[email protected]e1c3a552012-05-04 20:51:32331 virtual void RouteCloseEvent(content::RenderViewHost* rvh) OVERRIDE;
[email protected]f546640b2012-05-15 00:03:49332 virtual void RouteMessageEvent(
333 content::RenderViewHost* rvh,
334 const ViewMsg_PostMessage_Params& params) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11335 virtual void RunJavaScriptMessage(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10336 const string16& message,
337 const string16& default_prompt,
338 const GURL& frame_url,
[email protected]be2510c02012-05-28 14:52:14339 content::JavaScriptMessageType type,
[email protected]952a68e2011-11-17 00:36:10340 IPC::Message* reply_msg,
341 bool* did_suppress_message) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11342 virtual void RunBeforeUnloadConfirm(content::RenderViewHost* rvh,
[email protected]952a68e2011-11-17 00:36:10343 const string16& message,
[email protected]3b3301f62012-02-29 04:32:32344 bool is_reload,
[email protected]952a68e2011-11-17 00:36:10345 IPC::Message* reply_msg) OVERRIDE;
[email protected]a796f202012-05-30 14:14:25346 virtual bool AddMessageToConsole(int32 level,
347 const string16& message,
348 int32 line_no,
349 const string16& source_id) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10350 virtual content::RendererPreferences GetRendererPrefs(
351 content::BrowserContext* browser_context) const OVERRIDE;
[email protected]6717bf272012-05-11 23:31:25352 virtual webkit_glue::WebPreferences GetWebkitPrefs() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10353 virtual void OnUserGesture() OVERRIDE;
354 virtual void OnIgnoredUIEvent() OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11355 virtual void RendererUnresponsive(content::RenderViewHost* render_view_host,
[email protected]952a68e2011-11-17 00:36:10356 bool is_during_unload) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11357 virtual void RendererResponsive(
358 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10359 virtual void LoadStateChanged(const GURL& url,
360 const net::LoadStateWithParam& load_state,
361 uint64 upload_position,
362 uint64 upload_size) OVERRIDE;
363 virtual void WorkerCrashed() OVERRIDE;
364 virtual void Activate() OVERRIDE;
365 virtual void Deactivate() OVERRIDE;
366 virtual void LostCapture() OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10367 virtual void HandleMouseDown() OVERRIDE;
368 virtual void HandleMouseUp() OVERRIDE;
369 virtual void HandleMouseActivate() OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38370 virtual void RunFileChooser(
[email protected]eaabba22012-03-07 15:02:11371 content::RenderViewHost* render_view_host,
[email protected]8caadeb2011-11-22 02:45:23372 const content::FileChooserParams& params) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10373 virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
374 virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
375 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
[email protected]61e2b3cc2012-03-02 16:13:34376 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
[email protected]a9c81f02012-06-01 00:15:44377 virtual void RequestToLockMouse(bool user_gesture,
378 bool last_unlocked_by_target) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10379 virtual void LostMouseLock() OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50380 virtual void CreateNewWindow(
381 int route_id,
[email protected]97714c82012-06-06 10:15:13382 const ViewHostMsg_CreateWindow_Params& params,
383 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE;
[email protected]bafe6cd2012-05-23 23:09:50384 virtual void CreateNewWidget(int route_id,
385 WebKit::WebPopupType popup_type) OVERRIDE;
386 virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
387 virtual void ShowCreatedWindow(int route_id,
388 WindowOpenDisposition disposition,
389 const gfx::Rect& initial_pos,
390 bool user_gesture) OVERRIDE;
391 virtual void ShowCreatedWidget(int route_id,
392 const gfx::Rect& initial_pos) OVERRIDE;
393 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
394 virtual void ShowContextMenu(
395 const content::ContextMenuParams& params) OVERRIDE;
[email protected]f13b4202012-06-12 23:53:23396 virtual void RequestMediaAccessPermission(
397 const content::MediaStreamRequest* request,
398 const content::MediaResponseCallback& callback) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10399
[email protected]4ca76c02012-05-16 16:19:05400 // RenderWidgetHostDelegate --------------------------------------------------
401
[email protected]b87ee522012-05-18 15:16:54402 virtual bool PreHandleKeyboardEvent(
403 const content::NativeWebKeyboardEvent& event,
404 bool* is_keyboard_shortcut) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05405 virtual void HandleKeyboardEvent(
[email protected]b87ee522012-05-18 15:16:54406 const content::NativeWebKeyboardEvent& event) OVERRIDE;
[email protected]4ca76c02012-05-16 16:19:05407
[email protected]0bfbf882011-12-22 18:19:27408 // RenderViewHostManager::Delegate -------------------------------------------
409
410 virtual bool CreateRenderViewForRenderManager(
[email protected]14392a52012-05-02 20:28:44411 content::RenderViewHost* render_view_host, int opener_route_id) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27412 virtual void BeforeUnloadFiredFromRenderManager(
413 bool proceed,
414 bool* proceed_to_fire_unload) OVERRIDE;
415 virtual void DidStartLoadingFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11416 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27417 virtual void RenderViewGoneFromRenderManager(
[email protected]eaabba22012-03-07 15:02:11418 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27419 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
420 virtual void NotifySwappedFromRenderManager() OVERRIDE;
[email protected]14392a52012-05-02 20:28:44421 virtual int CreateOpenerRenderViewsForRenderManager(
422 content::SiteInstance* instance) OVERRIDE;
[email protected]d202a7c2012-01-04 07:53:47423 virtual NavigationControllerImpl& GetControllerForRenderManager() OVERRIDE;
[email protected]d2353452012-01-19 19:53:56424 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
[email protected]ad23a092011-12-28 07:02:04425 virtual content::NavigationEntry*
[email protected]0bfbf882011-12-22 18:19:27426 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
427 virtual bool FocusLocationBarByDefault() OVERRIDE;
428 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
[email protected]eaabba22012-03-07 15:02:11429 virtual void CreateViewAndSetSizeForRVH(
430 content::RenderViewHost* rvh) OVERRIDE;
[email protected]0bfbf882011-12-22 18:19:27431
[email protected]14392a52012-05-02 20:28:44432 // content::NotificationObserver ---------------------------------------------
433
434 virtual void Observe(int type,
435 const content::NotificationSource& source,
436 const content::NotificationDetails& details) OVERRIDE;
437
[email protected]0dd3a0ab2011-02-18 08:17:44438 protected:
[email protected]d8c660432011-12-22 20:51:25439 friend class content::WebContentsObserver;
[email protected]553602e12011-04-05 17:01:18440
441 // Add and remove observers for page navigation notifications. Adding or
442 // removing multiple times has no effect. The order in which notifications
443 // are sent to observers is undefined. Clients must be sure to remove the
444 // observer before they go away.
[email protected]d8c660432011-12-22 20:51:25445 void AddObserver(content::WebContentsObserver* observer);
446 void RemoveObserver(content::WebContentsObserver* observer);
[email protected]553602e12011-04-05 17:01:18447
[email protected]0dd3a0ab2011-02-18 08:17:44448 private:
[email protected]d202a7c2012-01-04 07:53:47449 friend class NavigationControllerImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44450
[email protected]2db9bd72012-04-13 20:20:56451 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
452 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
453 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
454 CrossSiteCantPreemptAfterUnload);
[email protected]0dd3a0ab2011-02-18 08:17:44455 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
456 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
457 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
458
[email protected]cadaec52012-02-08 21:53:13459 // So InterstitialPageImpl can access SetIsLoading.
460 friend class InterstitialPageImpl;
[email protected]0dd3a0ab2011-02-18 08:17:44461
[email protected]80e776ae2012-03-23 16:17:20462 // TODO(brettw) TestWebContents shouldn't exist!
463 friend class content::TestWebContents;
[email protected]0dd3a0ab2011-02-18 08:17:44464
[email protected]14392a52012-05-02 20:28:44465 // Clears this tab's opener if it has been closed.
466 void OnWebContentsDestroyed(content::WebContents* web_contents);
467
[email protected]51da7e32012-01-30 19:24:52468 // Callback function when showing JS dialogs.
[email protected]eaabba22012-03-07 15:02:11469 void OnDialogClosed(content::RenderViewHost* rvh,
[email protected]51da7e32012-01-30 19:24:52470 IPC::Message* reply_msg,
471 bool success,
472 const string16& user_input);
473
[email protected]d0759f492012-04-19 22:50:50474 // IPC message handlers.
[email protected]3a3b75a2012-06-01 08:38:36475 void OnRegisterIntentService(const webkit_glue::WebIntentServiceData& data,
476 bool user_gesture);
[email protected]678105012011-12-09 04:01:21477 void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
[email protected]63c239322011-10-31 23:56:30478 int intent_id);
[email protected]0dd3a0ab2011-02-18 08:17:44479 void OnDidLoadResourceFromMemoryCache(const GURL& url,
[email protected]70435962011-08-02 20:13:28480 const std::string& security_info,
481 const std::string& http_request,
[email protected]6d6cfb3a2012-05-23 22:53:18482 const std::string& mime_type,
[email protected]70435962011-08-02 20:13:28483 ResourceType::Type resource_type);
[email protected]0dd3a0ab2011-02-18 08:17:44484 void OnDidDisplayInsecureContent();
485 void OnDidRunInsecureContent(const std::string& security_origin,
486 const GURL& target_url);
487 void OnDocumentLoadedInFrame(int64 frame_id);
[email protected]1a55c5be2011-11-29 11:36:31488 void OnDidFinishLoad(int64 frame_id,
489 const GURL& validated_url,
490 bool is_main_frame);
491 void OnDidFailLoadWithError(int64 frame_id,
492 const GURL& validated_url,
493 bool is_main_frame,
494 int error_code,
495 const string16& error_description);
[email protected]0dd3a0ab2011-02-18 08:17:44496 void OnUpdateContentRestrictions(int restrictions);
[email protected]0dd3a0ab2011-02-18 08:17:44497 void OnGoToEntryAtOffset(int offset);
[email protected]216813952011-05-19 22:21:26498 void OnUpdateZoomLimits(int minimum_percent,
499 int maximum_percent,
500 bool remember);
[email protected]20b433a2012-05-15 21:23:46501 void OnSaveURL(const GURL& url, const content::Referrer& referrer);
[email protected]3a29a6e2011-08-24 18:26:21502 void OnEnumerateDirectory(int request_id, const FilePath& path);
[email protected]7d189022011-08-25 22:54:20503 void OnJSOutOfMemory();
[email protected]b7a756d42012-01-23 18:08:17504
[email protected]7d189022011-08-25 22:54:20505 void OnRegisterProtocolHandler(const std::string& protocol,
506 const GURL& url,
[email protected]3a3b75a2012-06-01 08:38:36507 const string16& title,
508 bool user_gesture);
[email protected]b888919c2011-09-02 00:32:16509 void OnFindReply(int request_id, int number_of_matches,
510 const gfx::Rect& selection_rect, int active_match_ordinal,
511 bool final_update);
[email protected]d952a052011-09-06 18:42:45512 void OnCrashedPlugin(const FilePath& plugin_path);
[email protected]7fc4bbb2011-09-08 21:23:10513 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
[email protected]55578b0a2012-04-18 14:31:32514 void OnOpenColorChooser(int color_chooser_id, SkColor color);
[email protected]da8543762012-03-20 08:52:20515 void OnEndColorChooser(int color_chooser_id);
[email protected]55578b0a2012-04-18 14:31:32516 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
[email protected]8be45842012-04-13 19:49:29517 void OnPepperPluginHung(int plugin_child_id,
518 const FilePath& path,
519 bool is_hung);
[email protected]d0759f492012-04-19 22:50:50520 void OnWebUISend(const GURL& source_url,
521 const std::string& name,
522 const base::ListValue& args);
[email protected]0dd3a0ab2011-02-18 08:17:44523
524 // Changes the IsLoading state and notifies delegate as needed
525 // |details| is used to provide details on the load that just finished
526 // (but can be null if not applicable). Can be overridden.
527 void SetIsLoading(bool is_loading,
[email protected]09d31d52012-03-11 22:30:27528 content::LoadNotificationDetails* details);
[email protected]0dd3a0ab2011-02-18 08:17:44529
[email protected]0dd3a0ab2011-02-18 08:17:44530 // Called by derived classes to indicate that we're no longer waiting for a
531 // response. This won't actually update the throbber, but it will get picked
532 // up at the next animation step if the throbber is going.
533 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
534
[email protected]0dd3a0ab2011-02-18 08:17:44535 // Navigation helpers --------------------------------------------------------
536 //
537 // These functions are helpers for Navigate() and DidNavigate().
538
539 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
540 // committed to the navigation controller. Note that the navigation entry is
541 // not provided since it may be invalid/changed after being committed. The
542 // current navigation entry is in the NavigationController at this point.
543 void DidNavigateMainFramePostCommit(
[email protected]8286f51a2011-05-31 17:39:13544 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44545 const ViewHostMsg_FrameNavigate_Params& params);
546 void DidNavigateAnyFramePostCommit(
[email protected]eaabba22012-03-07 15:02:11547 content::RenderViewHost* render_view_host,
[email protected]8286f51a2011-05-31 17:39:13548 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44549 const ViewHostMsg_FrameNavigate_Params& params);
550
[email protected]74ce1ad2011-12-16 21:51:46551 // If our controller was restored, update the max page ID associated with the
552 // given RenderViewHost to be larger than the number of restored entries.
553 // This is called in CreateRenderView before any navigations in the RenderView
554 // have begun, to prevent any races in updating RenderView::next_page_id.
[email protected]eaabba22012-03-07 15:02:11555 void UpdateMaxPageIDIfNecessary(content::RenderViewHost* rvh);
[email protected]0dd3a0ab2011-02-18 08:17:44556
[email protected]0dd3a0ab2011-02-18 08:17:44557 // Saves the given title to the navigation entry and does associated work. It
558 // will update history and the view for the new title, and also synthesize
559 // titles for file URLs that have none (so we require that the URL of the
560 // entry already be set).
561 //
562 // This is used as the backend for state updates, which include a new title,
563 // or the dedicated set title message. It returns true if the new title is
564 // different and was therefore updated.
[email protected]10f417c52011-12-28 21:04:23565 bool UpdateTitleForEntry(content::NavigationEntryImpl* entry,
566 const string16& title);
[email protected]0dd3a0ab2011-02-18 08:17:44567
[email protected]b172aee2012-04-10 17:05:26568 // Causes the WebContentsImpl to navigate in the right renderer to |entry|,
569 // which must be already part of the entries in the navigation controller.
[email protected]0dd3a0ab2011-02-18 08:17:44570 // This does not change the NavigationController state.
[email protected]10f417c52011-12-28 21:04:23571 bool NavigateToEntry(const content::NavigationEntryImpl& entry,
[email protected]71fde352011-12-29 03:29:56572 content::NavigationController::ReloadType reload_type);
[email protected]0dd3a0ab2011-02-18 08:17:44573
[email protected]b172aee2012-04-10 17:05:26574 // Sets the history for this WebContentsImpl to |history_length| entries, and
[email protected]796931a92011-08-10 01:32:14575 // moves the current page_id to the last entry in the list if it's valid.
576 // This is mainly used when a prerendered page is swapped into the current
[email protected]9e1ad4b2011-08-14 16:49:19577 // tab. The method is virtual for testing.
[email protected]b6583592012-01-25 19:52:33578 virtual void SetHistoryLengthAndPrune(
579 const content::SiteInstance* site_instance,
580 int merge_history_length,
581 int32 minimum_page_id);
[email protected]796931a92011-08-10 01:32:14582
[email protected]14392a52012-05-02 20:28:44583 // Recursively creates swapped out RenderViews for this tab's opener chain
584 // (including this tab) in the given SiteInstance, allowing other tabs to send
585 // cross-process JavaScript calls to their opener(s). Returns the route ID of
586 // this tab's RenderView for |instance|.
587 int CreateOpenerRenderViews(content::SiteInstance* instance);
588
[email protected]bafe6cd2012-05-23 23:09:50589 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
590 void CreateNewWidget(int route_id,
591 bool is_fullscreen,
592 WebKit::WebPopupType popup_type);
593
594 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
595 void ShowCreatedWidget(int route_id,
596 bool is_fullscreen,
597 const gfx::Rect& initial_pos);
598
599 // Finds the new RenderWidgetHost and returns it. Note that this can only be
600 // called once as this call also removes it from the internal map.
601 content::RenderWidgetHostView* GetCreatedWidget(int route_id);
602
603 // Finds the new WebContentsImpl by route_id, initializes it for
604 // renderer-initiated creation, and returns it. Note that this can only be
605 // called once as this call also removes it from the internal map.
606 WebContentsImpl* GetCreatedWindow(int route_id);
607
[email protected]0dd3a0ab2011-02-18 08:17:44608 // Misc non-view stuff -------------------------------------------------------
609
610 // Helper functions for sending notifications.
611 void NotifySwapped();
612 void NotifyConnected();
613 void NotifyDisconnected();
614
[email protected]be1f56ab2011-12-22 06:55:31615 void SetEncoding(const std::string& encoding);
616
[email protected]27678b2a2012-02-04 22:09:14617 // Save a URL to the local filesystem.
[email protected]20b433a2012-05-15 21:23:46618 void SaveURL(const GURL& url,
619 const content::Referrer& referrer,
620 bool is_main_frame);
[email protected]27678b2a2012-02-04 22:09:14621
[email protected]eaabba22012-03-07 15:02:11622 content::RenderViewHostImpl* GetRenderViewHostImpl();
[email protected]9f76c1e2012-03-05 15:15:58623
[email protected]7900bfdb2012-05-24 19:31:24624 void GetBrowserPluginEmbedderInfo(content::RenderViewHost* render_view_host,
625 std::string* embedder_channel_name,
626 int* embedder_container_id);
627
[email protected]81898992011-06-14 22:15:00628 // Stores random bits of data for others to associate with this object.
629 // WARNING: this needs to be deleted after NavigationController.
[email protected]45644f62011-11-23 00:58:23630 base::PropertyBag property_bag_;
[email protected]81898992011-06-14 22:15:00631
[email protected]0dd3a0ab2011-02-18 08:17:44632 // Data for core operation ---------------------------------------------------
633
634 // Delegate for notifying our owner about stuff. Not owned by us.
[email protected]674bc592011-12-20 23:00:42635 content::WebContentsDelegate* delegate_;
[email protected]0dd3a0ab2011-02-18 08:17:44636
637 // Handles the back/forward list and loading.
[email protected]d202a7c2012-01-04 07:53:47638 NavigationControllerImpl controller_;
[email protected]0dd3a0ab2011-02-18 08:17:44639
640 // The corresponding view.
[email protected]8643e6d2012-01-18 20:26:10641 scoped_ptr<content::WebContentsView> view_;
[email protected]0dd3a0ab2011-02-18 08:17:44642
[email protected]5a3bdf52012-05-24 15:12:57643 // The view of the RVHD. Usually this is our WebContentsView implementation,
644 // but if an embedder uses a different WebContentsView, they'll need to
645 // provide this.
646 content::RenderViewHostDelegateView* render_view_host_delegate_view_;
647
[email protected]bafe6cd2012-05-23 23:09:50648 // Tracks created WebContentsImpl objects that have not been shown yet. They
649 // are identified by the route ID passed to CreateNewWindow.
650 typedef std::map<int, WebContentsImpl*> PendingContents;
651 PendingContents pending_contents_;
652
653 // These maps hold on to the widgets that we created on behalf of the renderer
654 // that haven't shown yet.
655 typedef std::map<int, content::RenderWidgetHostView*> PendingWidgetViews;
656 PendingWidgetViews pending_widget_views_;
657
[email protected]996042972011-11-08 22:43:59658 // A list of observers notified when page state changes. Weak references.
659 // This MUST be listed above render_manager_ since at destruction time the
660 // latter might cause RenderViewHost's destructor to call us and we might use
661 // the observer list then.
[email protected]d8c660432011-12-22 20:51:25662 ObserverList<content::WebContentsObserver> observers_;
[email protected]996042972011-11-08 22:43:59663
[email protected]14392a52012-05-02 20:28:44664 // The tab that opened this tab, if any. Will be set to null if the opener
665 // is closed.
666 WebContentsImpl* opener_;
667
[email protected]86ef6a392012-05-11 22:03:11668 // User agent to use if a NavigationEntry requires that the default user agent
669 // is overridden.
670 std::string user_agent_override_;
671
[email protected]0dd3a0ab2011-02-18 08:17:44672 // Helper classes ------------------------------------------------------------
673
674 // Manages creation and swapping of render views.
675 RenderViewHostManager render_manager_;
676
[email protected]483623eb2011-10-25 09:30:00677 // Manages injecting Java objects into all RenderViewHosts associated with
[email protected]b172aee2012-04-10 17:05:26678 // this WebContentsImpl.
[email protected]483623eb2011-10-25 09:30:00679 scoped_ptr<JavaBridgeDispatcherHostManager>
680 java_bridge_dispatcher_host_manager_;
681
[email protected]172cf712012-05-23 15:07:39682 // Manages the browser plugin instances hosted by this WebContents.
683 scoped_ptr<content::BrowserPluginHost> browser_plugin_host_;
684
[email protected]c7dd2f62011-07-18 15:57:59685 // SavePackage, lazily created.
686 scoped_refptr<SavePackage> save_package_;
687
[email protected]0dd3a0ab2011-02-18 08:17:44688 // Data for loading state ----------------------------------------------------
689
690 // Indicates whether we're currently loading a resource.
691 bool is_loading_;
692
693 // Indicates if the tab is considered crashed.
694 base::TerminationStatus crashed_status_;
695 int crashed_error_code_;
696
[email protected]ca13a442012-04-17 14:00:12697 // Whether this WebContents is waiting for a first-response for the
[email protected]be1f56ab2011-12-22 06:55:31698 // main resource of the page. This controls whether the throbber state is
699 // "waiting" or "loading."
[email protected]0dd3a0ab2011-02-18 08:17:44700 bool waiting_for_response_;
701
[email protected]74ce1ad2011-12-16 21:51:46702 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
703 // to a given tab and SiteInstance, and must be valid for the lifetime of the
[email protected]b172aee2012-04-10 17:05:26704 // WebContentsImpl.
[email protected]74ce1ad2011-12-16 21:51:46705 std::map<int32, int32> max_page_ids_;
[email protected]0dd3a0ab2011-02-18 08:17:44706
707 // System time at which the current load was started.
708 base::TimeTicks current_load_start_;
709
710 // The current load state and the URL associated with it.
[email protected]9c235f042011-08-10 22:28:21711 net::LoadStateWithParam load_state_;
[email protected]0dd3a0ab2011-02-18 08:17:44712 string16 load_state_host_;
713 // Upload progress, for displaying in the status bar.
714 // Set to zero when there is no significant upload happening.
715 uint64 upload_size_;
716 uint64 upload_position_;
717
718 // Data for current page -----------------------------------------------------
719
[email protected]987fc3a2011-05-26 14:18:09720 // When a title cannot be taken from any entry, this title will be used.
721 string16 page_title_when_no_navigation_entry_;
722
[email protected]0dd3a0ab2011-02-18 08:17:44723 // When a navigation occurs, we record its contents MIME type. It can be
724 // used to check whether we can do something for some special contents.
725 std::string contents_mime_type_;
726
727 // Character encoding.
728 std::string encoding_;
729
[email protected]0dd3a0ab2011-02-18 08:17:44730 // True if this is a secure page which displayed insecure content.
731 bool displayed_insecure_content_;
732
[email protected]0dd3a0ab2011-02-18 08:17:44733 // Data for misc internal state ----------------------------------------------
734
[email protected]ca13a442012-04-17 14:00:12735 // Whether the WebContents is currently being screenshotted.
[email protected]0dd3a0ab2011-02-18 08:17:44736 bool capturing_contents_;
737
738 // See getter above.
739 bool is_being_destroyed_;
740
741 // Indicates whether we should notify about disconnection of this
[email protected]b172aee2012-04-10 17:05:26742 // WebContentsImpl. This is used to ensure disconnection notifications only
[email protected]0dd3a0ab2011-02-18 08:17:44743 // happen if a connection notification has happened and that they happen only
744 // once.
745 bool notify_disconnection_;
746
[email protected]2e5b90c2011-08-16 21:11:55747 // Pointer to the JavaScript dialog creator, lazily assigned. Used because the
[email protected]b172aee2012-04-10 17:05:26748 // delegate of this WebContentsImpl is nulled before its destructor is called.
[email protected]2e5b90c2011-08-16 21:11:55749 content::JavaScriptDialogCreator* dialog_creator_;
750
[email protected]0dd3a0ab2011-02-18 08:17:44751#if defined(OS_WIN)
752 // Handle to an event that's set when the page is showing a message box (or
753 // equivalent constrained window). Plugin processes check this to know if
754 // they should pump messages then.
755 base::win::ScopedHandle message_box_active_;
756#endif
757
[email protected]0dd3a0ab2011-02-18 08:17:44758 // Set to true when there is an active "before unload" dialog. When true,
759 // we've forced the throbber to start in Navigate, and we need to remember to
760 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
761 bool is_showing_before_unload_dialog_;
762
[email protected]0dd3a0ab2011-02-18 08:17:44763 // Settings that get passed to the renderer process.
[email protected]daf82f82011-10-31 22:35:31764 content::RendererPreferences renderer_preferences_;
[email protected]0dd3a0ab2011-02-18 08:17:44765
766 // If this tab was created from a renderer using window.open, this will be
767 // non-NULL and represent the WebUI of the opening renderer.
[email protected]01ec4ec2012-01-18 04:13:47768 content::WebUI::TypeID opener_web_ui_type_;
[email protected]0dd3a0ab2011-02-18 08:17:44769
770 // The time that we started to create the new tab page.
771 base::TimeTicks new_tab_start_time_;
772
[email protected]3bbacc5b2012-04-17 17:46:15773 // The time that we started to close this WebContents.
774 base::TimeTicks close_start_time_;
[email protected]0dd3a0ab2011-02-18 08:17:44775
776 // The time that this tab was last selected.
777 base::TimeTicks last_selected_time_;
778
[email protected]0dd3a0ab2011-02-18 08:17:44779 // See description above setter.
780 bool closed_by_user_gesture_;
781
782 // Minimum/maximum zoom percent.
783 int minimum_zoom_percent_;
784 int maximum_zoom_percent_;
785 // If true, the default zoom limits have been overriden for this tab, in which
786 // case we don't want saved settings to apply to it and we don't want to
787 // remember it.
788 bool temporary_zoom_settings_;
789
[email protected]bcd2815602012-01-14 18:17:23790 // The intrinsic size of the page.
791 gfx::Size preferred_size_;
792
[email protected]0dd3a0ab2011-02-18 08:17:44793 // Content restrictions, used to disable print/copy etc based on content's
794 // (full-page plugins for now only) permissions.
795 int content_restrictions_;
796
[email protected]da8543762012-03-20 08:52:20797 // Color chooser that was opened by this tab.
798 content::ColorChooser* color_chooser_;
799
[email protected]f53a9f872012-05-24 02:07:06800 // This must be at the end, or else we might get notifications and use other
801 // member variables that are gone.
802 content::NotificationRegistrar registrar_;
803
[email protected]b172aee2012-04-10 17:05:26804 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
[email protected]0dd3a0ab2011-02-18 08:17:44805};
806
[email protected]93ddb3c2012-04-11 21:44:29807#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_