[email protected] | 91854cd | 2012-01-10 19:43:57 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 93ddb3c | 2012-04-11 21:44:29 | [diff] [blame] | 5 | #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
| 6 | #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 7 | #pragma once |
| 8 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 9 | #include <map> |
| 10 | #include <string> |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 11 | |
[email protected] | 01d6517 | 2011-12-25 04:39:30 | [diff] [blame] | 12 | #include "base/compiler_specific.h" |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 13 | #include "base/gtest_prod_util.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 14 | #include "base/memory/scoped_ptr.h" |
[email protected] | 6eac57a | 2011-07-12 21:15:09 | [diff] [blame] | 15 | #include "base/observer_list.h" |
[email protected] | 45644f6 | 2011-11-23 00:58:23 | [diff] [blame] | 16 | #include "base/property_bag.h" |
[email protected] | 8dd709fb | 2012-04-06 00:49:06 | [diff] [blame] | 17 | #include "content/browser/browser_plugin/browser_plugin_web_contents_observer.h" |
[email protected] | 0716190 | 2011-11-11 09:57:42 | [diff] [blame] | 18 | #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager.h" |
[email protected] | f9e4dae | 2012-04-10 21:26:37 | [diff] [blame] | 19 | #include "content/browser/web_contents/navigation_controller_impl.h" |
[email protected] | 0c4e92e6 | 2012-04-11 15:19:00 | [diff] [blame] | 20 | #include "content/browser/web_contents/render_view_host_manager.h" |
[email protected] | 8d128d6 | 2011-09-13 22:11:57 | [diff] [blame] | 21 | #include "content/common/content_export.h" |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 22 | #include "content/public/browser/notification_observer.h" |
| 23 | #include "content/public/browser/notification_registrar.h" |
[email protected] | b0b67cf | 2012-01-18 21:59:57 | [diff] [blame] | 24 | #include "content/public/browser/render_view_host_delegate.h" |
[email protected] | 58f5d56 | 2011-12-20 17:13:03 | [diff] [blame] | 25 | #include "content/public/browser/web_contents.h" |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 26 | #include "content/public/common/renderer_preferences.h" |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 27 | #include "net/base/load_states.h" |
[email protected] | bcd281560 | 2012-01-14 18:17:23 | [diff] [blame] | 28 | #include "ui/gfx/size.h" |
[email protected] | 7043596 | 2011-08-02 20:13:28 | [diff] [blame] | 29 | #include "webkit/glue/resource_type.h" |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 30 | |
| 31 | #if defined(OS_WIN) |
| 32 | #include "base/win/scoped_handle.h" |
| 33 | #endif |
| 34 | |
[email protected] | cadaec5 | 2012-02-08 21:53:13 | [diff] [blame] | 35 | class InterstitialPageImpl; |
[email protected] | a53209b | 2012-01-20 16:48:16 | [diff] [blame] | 36 | class SavePackage; |
[email protected] | adbfb8df | 2012-02-24 01:19:43 | [diff] [blame] | 37 | class SessionStorageNamespaceImpl; |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 38 | |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 39 | namespace content { |
[email protected] | da854376 | 2012-03-20 08:52:20 | [diff] [blame] | 40 | class ColorChooser; |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 41 | class DownloadItem; |
[email protected] | 51da7e3 | 2012-01-30 19:24:52 | [diff] [blame] | 42 | class JavaScriptDialogCreator; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 43 | class RenderViewHost; |
| 44 | class RenderViewHostImpl; |
[email protected] | 09d31d5 | 2012-03-11 22:30:27 | [diff] [blame] | 45 | class SiteInstance; |
[email protected] | 80e776ae | 2012-03-23 16:17:20 | [diff] [blame] | 46 | class TestWebContents; |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 47 | class WebContentsDelegate; |
[email protected] | 51da7e3 | 2012-01-30 19:24:52 | [diff] [blame] | 48 | class WebContentsObserver; |
[email protected] | 8643e6d | 2012-01-18 20:26:10 | [diff] [blame] | 49 | class WebContentsView; |
[email protected] | 09d31d5 | 2012-03-11 22:30:27 | [diff] [blame] | 50 | struct LoadNotificationDetails; |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 51 | } |
| 52 | |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 53 | namespace webkit_glue { |
| 54 | struct WebIntentData; |
| 55 | } |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 56 | |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 57 | class CONTENT_EXPORT WebContentsImpl |
[email protected] | 01d6517 | 2011-12-25 04:39:30 | [diff] [blame] | 58 | : public NON_EXPORTED_BASE(content::WebContents), |
[email protected] | b0b67cf | 2012-01-18 21:59:57 | [diff] [blame] | 59 | public content::RenderViewHostDelegate, |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 60 | public RenderViewHostManager::Delegate, |
| 61 | public content::NotificationObserver { |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 62 | public: |
[email protected] | a81343d23 | 2011-12-27 07:39:20 | [diff] [blame] | 63 | // See WebContents::Create for a description of these parameters. |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 64 | WebContentsImpl(content::BrowserContext* browser_context, |
| 65 | content::SiteInstance* site_instance, |
| 66 | int routing_id, |
| 67 | const WebContentsImpl* base_web_contents, |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 68 | WebContentsImpl* opener, |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 69 | SessionStorageNamespaceImpl* session_storage_namespace); |
| 70 | virtual ~WebContentsImpl(); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 71 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 72 | // Returns the content specific prefs for the given RVH. |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 73 | static WebPreferences GetWebkitPrefs( |
| 74 | content::RenderViewHost* rvh, const GURL& url); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 75 | |
[email protected] | c7dd2f6 | 2011-07-18 15:57:59 | [diff] [blame] | 76 | // Returns the SavePackage which manages the page saving job. May be NULL. |
| 77 | SavePackage* save_package() const { return save_package_.get(); } |
| 78 | |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 79 | // Updates the max page ID for the current SiteInstance in this |
| 80 | // WebContentsImpl to be at least |page_id|. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 81 | void UpdateMaxPageID(int32 page_id); |
| 82 | |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 83 | // Updates the max page ID for the given SiteInstance in this WebContentsImpl |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 84 | // to be at least |page_id|. |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 85 | void UpdateMaxPageIDForSiteInstance(content::SiteInstance* site_instance, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 86 | int32 page_id); |
| 87 | |
[email protected] | 91854cd | 2012-01-10 19:43:57 | [diff] [blame] | 88 | // Copy the current map of SiteInstance ID to max page ID from another tab. |
| 89 | // This is necessary when this tab adopts the NavigationEntries from |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 90 | // |web_contents|. |
| 91 | void CopyMaxPageIDsFrom(WebContentsImpl* web_contents); |
[email protected] | 91854cd | 2012-01-10 19:43:57 | [diff] [blame] | 92 | |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 93 | // Called by the NavigationController to cause the WebContentsImpl to navigate |
| 94 | // to the current pending entry. The NavigationController should be called |
| 95 | // back with RendererDidNavigate on success or DiscardPendingEntry on failure. |
[email protected] | 9a7e68c | 2011-05-26 17:35:50 | [diff] [blame] | 96 | // The callbacks can be inside of this function, or at some future time. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 97 | // |
| 98 | // The entry has a PageID of -1 if newly created (corresponding to navigation |
| 99 | // to a new URL). |
| 100 | // |
| 101 | // If this method returns false, then the navigation is discarded (equivalent |
| 102 | // to calling DiscardPendingEntry on the NavigationController). |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 103 | bool NavigateToPendingEntry( |
[email protected] | 71fde35 | 2011-12-29 03:29:56 | [diff] [blame] | 104 | content::NavigationController::ReloadType reload_type); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 105 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 106 | // Sets the passed passed interstitial as the currently showing interstitial. |
| 107 | // |interstitial_page| should be non NULL (use the remove_interstitial_page |
| 108 | // method to unset the interstitial) and no interstitial page should be set |
| 109 | // when there is already a non NULL interstitial page set. |
[email protected] | cadaec5 | 2012-02-08 21:53:13 | [diff] [blame] | 110 | void set_interstitial_page(InterstitialPageImpl* interstitial_page) { |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 111 | render_manager_.set_interstitial_page(interstitial_page); |
| 112 | } |
| 113 | |
| 114 | // Unsets the currently showing interstitial. |
| 115 | void remove_interstitial_page() { |
| 116 | render_manager_.remove_interstitial_page(); |
| 117 | } |
| 118 | |
[email protected] | 01ec4ec | 2012-01-18 04:13:47 | [diff] [blame] | 119 | void set_opener_web_ui_type(content::WebUI::TypeID opener_web_ui_type) { |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 120 | opener_web_ui_type_ = opener_web_ui_type; |
| 121 | } |
| 122 | |
[email protected] | 276b37a2 | 2011-11-08 20:45:46 | [diff] [blame] | 123 | JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const { |
| 124 | return java_bridge_dispatcher_host_manager_.get(); |
| 125 | } |
| 126 | |
[email protected] | 8dd709fb | 2012-04-06 00:49:06 | [diff] [blame] | 127 | content::BrowserPluginWebContentsObserver* |
| 128 | browser_plugin_web_contents_observer() const { |
| 129 | return browser_plugin_web_contents_observer_.get(); |
| 130 | } |
| 131 | |
[email protected] | cdcb1dee | 2012-01-04 00:46:20 | [diff] [blame] | 132 | // Like GetController from WebContents, but returns the concrete object. |
[email protected] | d202a7c | 2012-01-04 07:53:47 | [diff] [blame] | 133 | NavigationControllerImpl& GetControllerImpl(); |
[email protected] | cdcb1dee | 2012-01-04 00:46:20 | [diff] [blame] | 134 | |
[email protected] | 76518718 | 2012-01-11 23:59:28 | [diff] [blame] | 135 | // Expose the render manager for testing. |
| 136 | RenderViewHostManager* GetRenderManagerForTesting(); |
| 137 | |
[email protected] | 58f5d56 | 2011-12-20 17:13:03 | [diff] [blame] | 138 | // content::WebContents ------------------------------------------------------ |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 139 | virtual const base::PropertyBag* GetPropertyBag() const OVERRIDE; |
| 140 | virtual base::PropertyBag* GetPropertyBag() OVERRIDE; |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 141 | virtual content::WebContentsDelegate* GetDelegate() OVERRIDE; |
| 142 | virtual void SetDelegate(content::WebContentsDelegate* delegate) OVERRIDE; |
[email protected] | cdcb1dee | 2012-01-04 00:46:20 | [diff] [blame] | 143 | virtual content::NavigationController& GetController() OVERRIDE; |
| 144 | virtual const content::NavigationController& GetController() const OVERRIDE; |
[email protected] | 627e051 | 2011-12-21 22:55:30 | [diff] [blame] | 145 | virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; |
[email protected] | f5fa20e | 2011-12-21 22:35:56 | [diff] [blame] | 146 | virtual void SetViewType(content::ViewType type) OVERRIDE; |
[email protected] | ea049a0 | 2011-12-25 21:37:09 | [diff] [blame] | 147 | virtual content::ViewType GetViewType() const OVERRIDE; |
[email protected] | f5fa20e | 2011-12-21 22:35:56 | [diff] [blame] | 148 | virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 149 | virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE; |
[email protected] | 5626b089 | 2012-02-20 14:46:58 | [diff] [blame] | 150 | virtual content::RenderWidgetHostView* |
| 151 | GetRenderWidgetHostView() const OVERRIDE; |
[email protected] | 8643e6d | 2012-01-18 20:26:10 | [diff] [blame] | 152 | virtual content::WebContentsView* GetView() const OVERRIDE; |
[email protected] | 01ec4ec | 2012-01-18 04:13:47 | [diff] [blame] | 153 | virtual content::WebUI* CreateWebUI(const GURL& url) OVERRIDE; |
| 154 | virtual content::WebUI* GetWebUI() const OVERRIDE; |
| 155 | virtual content::WebUI* GetCommittedWebUI() const OVERRIDE; |
[email protected] | 86ef6a39 | 2012-05-11 22:03:11 | [diff] [blame^] | 156 | virtual void SetUserAgentOverride(const std::string& override) OVERRIDE; |
| 157 | virtual const std::string& GetUserAgentOverride() const OVERRIDE; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 158 | virtual const string16& GetTitle() const OVERRIDE; |
| 159 | virtual int32 GetMaxPageID() OVERRIDE; |
| 160 | virtual int32 GetMaxPageIDForSiteInstance( |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 161 | content::SiteInstance* site_instance) OVERRIDE; |
| 162 | virtual content::SiteInstance* GetSiteInstance() const OVERRIDE; |
| 163 | virtual content::SiteInstance* GetPendingSiteInstance() const OVERRIDE; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 164 | virtual bool IsLoading() const OVERRIDE; |
| 165 | virtual bool IsWaitingForResponse() const OVERRIDE; |
| 166 | virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE; |
| 167 | virtual const string16& GetLoadStateHost() const OVERRIDE; |
| 168 | virtual uint64 GetUploadSize() const OVERRIDE; |
| 169 | virtual uint64 GetUploadPosition() const OVERRIDE; |
| 170 | virtual const std::string& GetEncoding() const OVERRIDE; |
| 171 | virtual bool DisplayedInsecureContent() const OVERRIDE; |
| 172 | virtual void SetCapturingContents(bool cap) OVERRIDE; |
| 173 | virtual bool IsCrashed() const OVERRIDE; |
| 174 | virtual void SetIsCrashed(base::TerminationStatus status, |
| 175 | int error_code) OVERRIDE; |
| 176 | virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE; |
| 177 | virtual bool IsBeingDestroyed() const OVERRIDE; |
| 178 | virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE; |
| 179 | virtual void DidBecomeSelected() OVERRIDE; |
| 180 | virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE; |
| 181 | virtual void WasHidden() OVERRIDE; |
| 182 | virtual void ShowContents() OVERRIDE; |
| 183 | virtual void HideContents() OVERRIDE; |
| 184 | virtual bool NeedToFireBeforeUnload() OVERRIDE; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 185 | virtual void Stop() OVERRIDE; |
[email protected] | d908348 | 2012-01-06 00:38:46 | [diff] [blame] | 186 | virtual content::WebContents* Clone() OVERRIDE; |
[email protected] | 2a6bc3e | 2011-12-28 23:51:33 | [diff] [blame] | 187 | virtual void AddNewContents(content::WebContents* new_contents, |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 188 | WindowOpenDisposition disposition, |
| 189 | const gfx::Rect& initial_pos, |
| 190 | bool user_gesture) OVERRIDE; |
| 191 | virtual gfx::NativeView GetContentNativeView() const OVERRIDE; |
| 192 | virtual gfx::NativeView GetNativeView() const OVERRIDE; |
| 193 | virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; |
| 194 | virtual void Focus() OVERRIDE; |
| 195 | virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE; |
| 196 | virtual bool ShowingInterstitialPage() const OVERRIDE; |
[email protected] | cadaec5 | 2012-02-08 21:53:13 | [diff] [blame] | 197 | virtual content::InterstitialPage* GetInterstitialPage() const OVERRIDE; |
[email protected] | a53209b | 2012-01-20 16:48:16 | [diff] [blame] | 198 | virtual bool IsSavable() OVERRIDE; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 199 | virtual void OnSavePage() OVERRIDE; |
| 200 | virtual bool SavePage(const FilePath& main_file, |
| 201 | const FilePath& dir_path, |
[email protected] | a53209b | 2012-01-20 16:48:16 | [diff] [blame] | 202 | content::SavePageType save_type) OVERRIDE; |
[email protected] | aa4f397 | 2012-03-01 18:12:12 | [diff] [blame] | 203 | virtual void GenerateMHTML( |
| 204 | const FilePath& file, |
| 205 | const base::Callback<void(const FilePath&, int64)>& callback) OVERRIDE; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 206 | virtual bool IsActiveEntry(int32 page_id) OVERRIDE; |
| 207 | |
| 208 | virtual const std::string& GetContentsMimeType() const OVERRIDE; |
| 209 | virtual bool WillNotifyDisconnection() const OVERRIDE; |
| 210 | virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE; |
| 211 | virtual void ResetOverrideEncoding() OVERRIDE; |
| 212 | virtual content::RendererPreferences* GetMutableRendererPrefs() OVERRIDE; |
| 213 | virtual void SetNewTabStartTime(const base::TimeTicks& time) OVERRIDE; |
| 214 | virtual base::TimeTicks GetNewTabStartTime() const OVERRIDE; |
| 215 | virtual void OnCloseStarted() OVERRIDE; |
| 216 | virtual bool ShouldAcceptDragAndDrop() const OVERRIDE; |
| 217 | virtual void SystemDragEnded() OVERRIDE; |
| 218 | virtual void SetClosedByUserGesture(bool value) OVERRIDE; |
| 219 | virtual bool GetClosedByUserGesture() const OVERRIDE; |
| 220 | virtual double GetZoomLevel() const OVERRIDE; |
| 221 | virtual int GetZoomPercent(bool* enable_increment, |
| 222 | bool* enable_decrement) OVERRIDE; |
| 223 | virtual void ViewSource() OVERRIDE; |
| 224 | virtual void ViewFrameSource(const GURL& url, |
| 225 | const std::string& content_state) OVERRIDE; |
| 226 | virtual int GetMinimumZoomPercent() const OVERRIDE; |
| 227 | virtual int GetMaximumZoomPercent() const OVERRIDE; |
[email protected] | bcd281560 | 2012-01-14 18:17:23 | [diff] [blame] | 228 | virtual gfx::Size GetPreferredSize() const OVERRIDE; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 229 | virtual int GetContentRestrictions() const OVERRIDE; |
[email protected] | 01ec4ec | 2012-01-18 04:13:47 | [diff] [blame] | 230 | virtual content::WebUI::TypeID GetWebUITypeForCurrentState() OVERRIDE; |
| 231 | virtual content::WebUI* GetWebUIForCurrentState() OVERRIDE; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 232 | virtual bool GotResponseToLockMouseRequest(bool allowed) OVERRIDE; |
[email protected] | a0358d7 | 2012-03-09 14:06:50 | [diff] [blame] | 233 | virtual bool HasOpener() const OVERRIDE; |
[email protected] | da854376 | 2012-03-20 08:52:20 | [diff] [blame] | 234 | virtual void DidChooseColorInColorChooser(int color_chooser_id, |
[email protected] | 55578b0a | 2012-04-18 14:31:32 | [diff] [blame] | 235 | SkColor color) OVERRIDE; |
[email protected] | da854376 | 2012-03-20 08:52:20 | [diff] [blame] | 236 | virtual void DidEndColorChooser(int color_chooser_id) OVERRIDE; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 237 | |
| 238 | // Implementation of PageNavigator. |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 239 | virtual content::WebContents* OpenURL( |
| 240 | const content::OpenURLParams& params) OVERRIDE; |
[email protected] | 151a63d | 2011-12-20 22:32:52 | [diff] [blame] | 241 | |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 242 | // RenderViewHostDelegate ---------------------------------------------------- |
| 243 | |
[email protected] | b0b67cf | 2012-01-18 21:59:57 | [diff] [blame] | 244 | virtual content::RenderViewHostDelegate::View* GetViewDelegate() OVERRIDE; |
| 245 | virtual content::RenderViewHostDelegate::RendererManagement* |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 246 | GetRendererManagementDelegate() OVERRIDE; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 247 | virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 248 | virtual const GURL& GetURL() const OVERRIDE; |
[email protected] | 768c547 | 2011-12-26 19:06:17 | [diff] [blame] | 249 | virtual WebContents* GetAsWebContents() OVERRIDE; |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 250 | virtual content::ViewType GetRenderViewType() const OVERRIDE; |
[email protected] | b7a756d4 | 2012-01-23 18:08:17 | [diff] [blame] | 251 | virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 252 | virtual void RenderViewCreated( |
| 253 | content::RenderViewHost* render_view_host) OVERRIDE; |
| 254 | virtual void RenderViewReady( |
| 255 | content::RenderViewHost* render_view_host) OVERRIDE; |
| 256 | virtual void RenderViewGone(content::RenderViewHost* render_view_host, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 257 | base::TerminationStatus status, |
| 258 | int error_code) OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 259 | virtual void RenderViewDeleted( |
| 260 | content::RenderViewHost* render_view_host) OVERRIDE; |
[email protected] | 54047eb5 | 2012-05-08 21:45:57 | [diff] [blame] | 261 | virtual void DidStartProvisionalLoadForFrame( |
| 262 | content::RenderViewHost* render_view_host, |
| 263 | int64 frame_id, |
| 264 | bool main_frame, |
| 265 | const GURL& opener_url, |
| 266 | const GURL& url) OVERRIDE; |
| 267 | virtual void DidRedirectProvisionalLoad( |
| 268 | content::RenderViewHost* render_view_host, |
| 269 | int32 page_id, |
| 270 | const GURL& opener_url, |
| 271 | const GURL& source_url, |
| 272 | const GURL& target_url) OVERRIDE; |
| 273 | virtual void DidFailProvisionalLoadWithError( |
| 274 | content::RenderViewHost* render_view_host, |
| 275 | const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) |
| 276 | OVERRIDE; |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 277 | virtual void DidNavigate( |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 278 | content::RenderViewHost* render_view_host, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 279 | const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 280 | virtual void UpdateState(content::RenderViewHost* render_view_host, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 281 | int32 page_id, |
| 282 | const std::string& state) OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 283 | virtual void UpdateTitle(content::RenderViewHost* render_view_host, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 284 | int32 page_id, |
| 285 | const string16& title, |
| 286 | base::i18n::TextDirection title_direction) OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 287 | virtual void UpdateEncoding(content::RenderViewHost* render_view_host, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 288 | const std::string& encoding) OVERRIDE; |
| 289 | virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 290 | virtual void Close(content::RenderViewHost* render_view_host) OVERRIDE; |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 291 | virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 292 | virtual void SwappedOut(content::RenderViewHost* render_view_host) OVERRIDE; |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 293 | virtual void DidStartLoading() OVERRIDE; |
| 294 | virtual void DidStopLoading() OVERRIDE; |
| 295 | virtual void DidCancelLoading() OVERRIDE; |
| 296 | virtual void DidChangeLoadProgress(double progress) OVERRIDE; |
[email protected] | 87717d0e | 2012-04-26 02:58:43 | [diff] [blame] | 297 | virtual void DocumentAvailableInMainFrame( |
| 298 | content::RenderViewHost* render_view_host) OVERRIDE; |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 299 | virtual void DocumentOnLoadCompletedInMainFrame( |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 300 | content::RenderViewHost* render_view_host, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 301 | int32 page_id) OVERRIDE; |
[email protected] | 196159d | 2012-05-04 17:26:54 | [diff] [blame] | 302 | virtual void RequestOpenURL(content::RenderViewHost* rvh, |
| 303 | const GURL& url, |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 304 | const content::Referrer& referrer, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 305 | WindowOpenDisposition disposition, |
| 306 | int64 source_frame_id) OVERRIDE; |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 307 | virtual void RequestTransferURL( |
| 308 | const GURL& url, |
[email protected] | bce1f1c | 2011-12-05 15:11:58 | [diff] [blame] | 309 | const content::Referrer& referrer, |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 310 | WindowOpenDisposition disposition, |
| 311 | int64 source_frame_id, |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 312 | const content::GlobalRequestID& transferred_global_request_id) OVERRIDE; |
[email protected] | e1c3a55 | 2012-05-04 20:51:32 | [diff] [blame] | 313 | virtual void RouteCloseEvent(content::RenderViewHost* rvh) OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 314 | virtual void RunJavaScriptMessage(content::RenderViewHost* rvh, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 315 | const string16& message, |
| 316 | const string16& default_prompt, |
| 317 | const GURL& frame_url, |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 318 | ui::JavascriptMessageType type, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 319 | IPC::Message* reply_msg, |
| 320 | bool* did_suppress_message) OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 321 | virtual void RunBeforeUnloadConfirm(content::RenderViewHost* rvh, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 322 | const string16& message, |
[email protected] | 3b3301f6 | 2012-02-29 04:32:32 | [diff] [blame] | 323 | bool is_reload, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 324 | IPC::Message* reply_msg) OVERRIDE; |
| 325 | virtual content::RendererPreferences GetRendererPrefs( |
| 326 | content::BrowserContext* browser_context) const OVERRIDE; |
| 327 | virtual WebPreferences GetWebkitPrefs() OVERRIDE; |
| 328 | virtual void OnUserGesture() OVERRIDE; |
| 329 | virtual void OnIgnoredUIEvent() OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 330 | virtual void RendererUnresponsive(content::RenderViewHost* render_view_host, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 331 | bool is_during_unload) OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 332 | virtual void RendererResponsive( |
| 333 | content::RenderViewHost* render_view_host) OVERRIDE; |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 334 | virtual void LoadStateChanged(const GURL& url, |
| 335 | const net::LoadStateWithParam& load_state, |
| 336 | uint64 upload_position, |
| 337 | uint64 upload_size) OVERRIDE; |
| 338 | virtual void WorkerCrashed() OVERRIDE; |
| 339 | virtual void Activate() OVERRIDE; |
| 340 | virtual void Deactivate() OVERRIDE; |
| 341 | virtual void LostCapture() OVERRIDE; |
| 342 | virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 343 | bool* is_keyboard_shortcut) OVERRIDE; |
| 344 | virtual void HandleKeyboardEvent( |
| 345 | const NativeWebKeyboardEvent& event) OVERRIDE; |
| 346 | virtual void HandleMouseDown() OVERRIDE; |
| 347 | virtual void HandleMouseUp() OVERRIDE; |
| 348 | virtual void HandleMouseActivate() OVERRIDE; |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 349 | virtual void RunFileChooser( |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 350 | content::RenderViewHost* render_view_host, |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 351 | const content::FileChooserParams& params) OVERRIDE; |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 352 | virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE; |
| 353 | virtual bool IsFullscreenForCurrentTab() const OVERRIDE; |
| 354 | virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE; |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 355 | virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE; |
[email protected] | 42252e0 | 2012-04-26 16:29:39 | [diff] [blame] | 356 | virtual void RequestToLockMouse(bool user_gesture) OVERRIDE; |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 357 | virtual void LostMouseLock() OVERRIDE; |
| 358 | |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 359 | // RenderViewHostManager::Delegate ------------------------------------------- |
| 360 | |
| 361 | virtual bool CreateRenderViewForRenderManager( |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 362 | content::RenderViewHost* render_view_host, int opener_route_id) OVERRIDE; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 363 | virtual void BeforeUnloadFiredFromRenderManager( |
| 364 | bool proceed, |
| 365 | bool* proceed_to_fire_unload) OVERRIDE; |
| 366 | virtual void DidStartLoadingFromRenderManager( |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 367 | content::RenderViewHost* render_view_host) OVERRIDE; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 368 | virtual void RenderViewGoneFromRenderManager( |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 369 | content::RenderViewHost* render_view_host) OVERRIDE; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 370 | virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE; |
| 371 | virtual void NotifySwappedFromRenderManager() OVERRIDE; |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 372 | virtual int CreateOpenerRenderViewsForRenderManager( |
| 373 | content::SiteInstance* instance) OVERRIDE; |
[email protected] | d202a7c | 2012-01-04 07:53:47 | [diff] [blame] | 374 | virtual NavigationControllerImpl& GetControllerForRenderManager() OVERRIDE; |
[email protected] | d235345 | 2012-01-19 19:53:56 | [diff] [blame] | 375 | virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE; |
[email protected] | ad23a09 | 2011-12-28 07:02:04 | [diff] [blame] | 376 | virtual content::NavigationEntry* |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 377 | GetLastCommittedNavigationEntryForRenderManager() OVERRIDE; |
| 378 | virtual bool FocusLocationBarByDefault() OVERRIDE; |
| 379 | virtual void SetFocusToLocationBar(bool select_all) OVERRIDE; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 380 | virtual void CreateViewAndSetSizeForRVH( |
| 381 | content::RenderViewHost* rvh) OVERRIDE; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 382 | |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 383 | // content::NotificationObserver --------------------------------------------- |
| 384 | |
| 385 | virtual void Observe(int type, |
| 386 | const content::NotificationSource& source, |
| 387 | const content::NotificationDetails& details) OVERRIDE; |
| 388 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 389 | protected: |
[email protected] | d8c66043 | 2011-12-22 20:51:25 | [diff] [blame] | 390 | friend class content::WebContentsObserver; |
[email protected] | 553602e1 | 2011-04-05 17:01:18 | [diff] [blame] | 391 | |
| 392 | // Add and remove observers for page navigation notifications. Adding or |
| 393 | // removing multiple times has no effect. The order in which notifications |
| 394 | // are sent to observers is undefined. Clients must be sure to remove the |
| 395 | // observer before they go away. |
[email protected] | d8c66043 | 2011-12-22 20:51:25 | [diff] [blame] | 396 | void AddObserver(content::WebContentsObserver* observer); |
| 397 | void RemoveObserver(content::WebContentsObserver* observer); |
[email protected] | 553602e1 | 2011-04-05 17:01:18 | [diff] [blame] | 398 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 399 | private: |
[email protected] | d202a7c | 2012-01-04 07:53:47 | [diff] [blame] | 400 | friend class NavigationControllerImpl; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 401 | |
[email protected] | 2db9bd7 | 2012-04-13 20:20:56 | [diff] [blame] | 402 | FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials); |
| 403 | FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle); |
| 404 | FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, |
| 405 | CrossSiteCantPreemptAfterUnload); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 406 | FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles); |
| 407 | FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate); |
| 408 | FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload); |
| 409 | |
[email protected] | cadaec5 | 2012-02-08 21:53:13 | [diff] [blame] | 410 | // So InterstitialPageImpl can access SetIsLoading. |
| 411 | friend class InterstitialPageImpl; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 412 | |
[email protected] | 80e776ae | 2012-03-23 16:17:20 | [diff] [blame] | 413 | // TODO(brettw) TestWebContents shouldn't exist! |
| 414 | friend class content::TestWebContents; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 415 | |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 416 | // Clears this tab's opener if it has been closed. |
| 417 | void OnWebContentsDestroyed(content::WebContents* web_contents); |
| 418 | |
[email protected] | 51da7e3 | 2012-01-30 19:24:52 | [diff] [blame] | 419 | // Callback function when showing JS dialogs. |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 420 | void OnDialogClosed(content::RenderViewHost* rvh, |
[email protected] | 51da7e3 | 2012-01-30 19:24:52 | [diff] [blame] | 421 | IPC::Message* reply_msg, |
| 422 | bool success, |
| 423 | const string16& user_input); |
| 424 | |
[email protected] | d0759f49 | 2012-04-19 22:50:50 | [diff] [blame] | 425 | // IPC message handlers. |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 426 | void OnRegisterIntentService(const string16& action, |
[email protected] | 63c23932 | 2011-10-31 23:56:30 | [diff] [blame] | 427 | const string16& type, |
| 428 | const string16& href, |
| 429 | const string16& title, |
| 430 | const string16& disposition); |
[email protected] | 67810501 | 2011-12-09 04:01:21 | [diff] [blame] | 431 | void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent, |
[email protected] | 63c23932 | 2011-10-31 23:56:30 | [diff] [blame] | 432 | int intent_id); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 433 | void OnDidLoadResourceFromMemoryCache(const GURL& url, |
[email protected] | 7043596 | 2011-08-02 20:13:28 | [diff] [blame] | 434 | const std::string& security_info, |
| 435 | const std::string& http_request, |
| 436 | ResourceType::Type resource_type); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 437 | void OnDidDisplayInsecureContent(); |
| 438 | void OnDidRunInsecureContent(const std::string& security_origin, |
| 439 | const GURL& target_url); |
| 440 | void OnDocumentLoadedInFrame(int64 frame_id); |
[email protected] | 1a55c5be | 2011-11-29 11:36:31 | [diff] [blame] | 441 | void OnDidFinishLoad(int64 frame_id, |
| 442 | const GURL& validated_url, |
| 443 | bool is_main_frame); |
| 444 | void OnDidFailLoadWithError(int64 frame_id, |
| 445 | const GURL& validated_url, |
| 446 | bool is_main_frame, |
| 447 | int error_code, |
| 448 | const string16& error_description); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 449 | void OnUpdateContentRestrictions(int restrictions); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 450 | void OnGoToEntryAtOffset(int offset); |
[email protected] | 21681395 | 2011-05-19 22:21:26 | [diff] [blame] | 451 | void OnUpdateZoomLimits(int minimum_percent, |
| 452 | int maximum_percent, |
| 453 | bool remember); |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 454 | void OnSaveURL(const GURL& url); |
[email protected] | 3a29a6e | 2011-08-24 18:26:21 | [diff] [blame] | 455 | void OnEnumerateDirectory(int request_id, const FilePath& path); |
[email protected] | 7d18902 | 2011-08-25 22:54:20 | [diff] [blame] | 456 | void OnJSOutOfMemory(); |
[email protected] | b7a756d4 | 2012-01-23 18:08:17 | [diff] [blame] | 457 | |
[email protected] | 7d18902 | 2011-08-25 22:54:20 | [diff] [blame] | 458 | void OnRegisterProtocolHandler(const std::string& protocol, |
| 459 | const GURL& url, |
| 460 | const string16& title); |
[email protected] | b888919c | 2011-09-02 00:32:16 | [diff] [blame] | 461 | void OnFindReply(int request_id, int number_of_matches, |
| 462 | const gfx::Rect& selection_rect, int active_match_ordinal, |
| 463 | bool final_update); |
[email protected] | d952a05 | 2011-09-06 18:42:45 | [diff] [blame] | 464 | void OnCrashedPlugin(const FilePath& plugin_path); |
[email protected] | 7fc4bbb | 2011-09-08 21:23:10 | [diff] [blame] | 465 | void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy); |
[email protected] | 55578b0a | 2012-04-18 14:31:32 | [diff] [blame] | 466 | void OnOpenColorChooser(int color_chooser_id, SkColor color); |
[email protected] | da854376 | 2012-03-20 08:52:20 | [diff] [blame] | 467 | void OnEndColorChooser(int color_chooser_id); |
[email protected] | 55578b0a | 2012-04-18 14:31:32 | [diff] [blame] | 468 | void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color); |
[email protected] | 8be4584 | 2012-04-13 19:49:29 | [diff] [blame] | 469 | void OnPepperPluginHung(int plugin_child_id, |
| 470 | const FilePath& path, |
| 471 | bool is_hung); |
[email protected] | d0759f49 | 2012-04-19 22:50:50 | [diff] [blame] | 472 | void OnWebUISend(const GURL& source_url, |
| 473 | const std::string& name, |
| 474 | const base::ListValue& args); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 475 | |
| 476 | // Changes the IsLoading state and notifies delegate as needed |
| 477 | // |details| is used to provide details on the load that just finished |
| 478 | // (but can be null if not applicable). Can be overridden. |
| 479 | void SetIsLoading(bool is_loading, |
[email protected] | 09d31d5 | 2012-03-11 22:30:27 | [diff] [blame] | 480 | content::LoadNotificationDetails* details); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 481 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 482 | // Called by derived classes to indicate that we're no longer waiting for a |
| 483 | // response. This won't actually update the throbber, but it will get picked |
| 484 | // up at the next animation step if the throbber is going. |
| 485 | void SetNotWaitingForResponse() { waiting_for_response_ = false; } |
| 486 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 487 | // Navigation helpers -------------------------------------------------------- |
| 488 | // |
| 489 | // These functions are helpers for Navigate() and DidNavigate(). |
| 490 | |
| 491 | // Handles post-navigation tasks in DidNavigate AFTER the entry has been |
| 492 | // committed to the navigation controller. Note that the navigation entry is |
| 493 | // not provided since it may be invalid/changed after being committed. The |
| 494 | // current navigation entry is in the NavigationController at this point. |
| 495 | void DidNavigateMainFramePostCommit( |
[email protected] | 8286f51a | 2011-05-31 17:39:13 | [diff] [blame] | 496 | const content::LoadCommittedDetails& details, |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 497 | const ViewHostMsg_FrameNavigate_Params& params); |
| 498 | void DidNavigateAnyFramePostCommit( |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 499 | content::RenderViewHost* render_view_host, |
[email protected] | 8286f51a | 2011-05-31 17:39:13 | [diff] [blame] | 500 | const content::LoadCommittedDetails& details, |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 501 | const ViewHostMsg_FrameNavigate_Params& params); |
| 502 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 503 | // If our controller was restored, update the max page ID associated with the |
| 504 | // given RenderViewHost to be larger than the number of restored entries. |
| 505 | // This is called in CreateRenderView before any navigations in the RenderView |
| 506 | // have begun, to prevent any races in updating RenderView::next_page_id. |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 507 | void UpdateMaxPageIDIfNecessary(content::RenderViewHost* rvh); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 508 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 509 | // Saves the given title to the navigation entry and does associated work. It |
| 510 | // will update history and the view for the new title, and also synthesize |
| 511 | // titles for file URLs that have none (so we require that the URL of the |
| 512 | // entry already be set). |
| 513 | // |
| 514 | // This is used as the backend for state updates, which include a new title, |
| 515 | // or the dedicated set title message. It returns true if the new title is |
| 516 | // different and was therefore updated. |
[email protected] | 10f417c5 | 2011-12-28 21:04:23 | [diff] [blame] | 517 | bool UpdateTitleForEntry(content::NavigationEntryImpl* entry, |
| 518 | const string16& title); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 519 | |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 520 | // Causes the WebContentsImpl to navigate in the right renderer to |entry|, |
| 521 | // which must be already part of the entries in the navigation controller. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 522 | // This does not change the NavigationController state. |
[email protected] | 10f417c5 | 2011-12-28 21:04:23 | [diff] [blame] | 523 | bool NavigateToEntry(const content::NavigationEntryImpl& entry, |
[email protected] | 71fde35 | 2011-12-29 03:29:56 | [diff] [blame] | 524 | content::NavigationController::ReloadType reload_type); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 525 | |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 526 | // Sets the history for this WebContentsImpl to |history_length| entries, and |
[email protected] | 796931a9 | 2011-08-10 01:32:14 | [diff] [blame] | 527 | // moves the current page_id to the last entry in the list if it's valid. |
| 528 | // This is mainly used when a prerendered page is swapped into the current |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 529 | // tab. The method is virtual for testing. |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 530 | virtual void SetHistoryLengthAndPrune( |
| 531 | const content::SiteInstance* site_instance, |
| 532 | int merge_history_length, |
| 533 | int32 minimum_page_id); |
[email protected] | 796931a9 | 2011-08-10 01:32:14 | [diff] [blame] | 534 | |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 535 | // Recursively creates swapped out RenderViews for this tab's opener chain |
| 536 | // (including this tab) in the given SiteInstance, allowing other tabs to send |
| 537 | // cross-process JavaScript calls to their opener(s). Returns the route ID of |
| 538 | // this tab's RenderView for |instance|. |
| 539 | int CreateOpenerRenderViews(content::SiteInstance* instance); |
| 540 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 541 | // Misc non-view stuff ------------------------------------------------------- |
| 542 | |
| 543 | // Helper functions for sending notifications. |
| 544 | void NotifySwapped(); |
| 545 | void NotifyConnected(); |
| 546 | void NotifyDisconnected(); |
| 547 | |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 548 | void SetEncoding(const std::string& encoding); |
| 549 | |
[email protected] | 27678b2a | 2012-02-04 22:09:14 | [diff] [blame] | 550 | // Save a URL to the local filesystem. |
[email protected] | e30d68d | 2012-02-09 00:06:26 | [diff] [blame] | 551 | void SaveURL(const GURL& url, const GURL& referrer, bool is_main_frame); |
[email protected] | 27678b2a | 2012-02-04 22:09:14 | [diff] [blame] | 552 | |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 553 | content::RenderViewHostImpl* GetRenderViewHostImpl(); |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 554 | |
[email protected] | 8189899 | 2011-06-14 22:15:00 | [diff] [blame] | 555 | // Stores random bits of data for others to associate with this object. |
| 556 | // WARNING: this needs to be deleted after NavigationController. |
[email protected] | 45644f6 | 2011-11-23 00:58:23 | [diff] [blame] | 557 | base::PropertyBag property_bag_; |
[email protected] | 8189899 | 2011-06-14 22:15:00 | [diff] [blame] | 558 | |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 559 | // Listen for notifications as well. |
| 560 | content::NotificationRegistrar registrar_; |
| 561 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 562 | // Data for core operation --------------------------------------------------- |
| 563 | |
| 564 | // Delegate for notifying our owner about stuff. Not owned by us. |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 565 | content::WebContentsDelegate* delegate_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 566 | |
| 567 | // Handles the back/forward list and loading. |
[email protected] | d202a7c | 2012-01-04 07:53:47 | [diff] [blame] | 568 | NavigationControllerImpl controller_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 569 | |
| 570 | // The corresponding view. |
[email protected] | 8643e6d | 2012-01-18 20:26:10 | [diff] [blame] | 571 | scoped_ptr<content::WebContentsView> view_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 572 | |
[email protected] | 99604297 | 2011-11-08 22:43:59 | [diff] [blame] | 573 | // A list of observers notified when page state changes. Weak references. |
| 574 | // This MUST be listed above render_manager_ since at destruction time the |
| 575 | // latter might cause RenderViewHost's destructor to call us and we might use |
| 576 | // the observer list then. |
[email protected] | d8c66043 | 2011-12-22 20:51:25 | [diff] [blame] | 577 | ObserverList<content::WebContentsObserver> observers_; |
[email protected] | 99604297 | 2011-11-08 22:43:59 | [diff] [blame] | 578 | |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 579 | // The tab that opened this tab, if any. Will be set to null if the opener |
| 580 | // is closed. |
| 581 | WebContentsImpl* opener_; |
| 582 | |
[email protected] | 86ef6a39 | 2012-05-11 22:03:11 | [diff] [blame^] | 583 | // User agent to use if a NavigationEntry requires that the default user agent |
| 584 | // is overridden. |
| 585 | std::string user_agent_override_; |
| 586 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 587 | // Helper classes ------------------------------------------------------------ |
| 588 | |
| 589 | // Manages creation and swapping of render views. |
| 590 | RenderViewHostManager render_manager_; |
| 591 | |
[email protected] | 483623eb | 2011-10-25 09:30:00 | [diff] [blame] | 592 | // Manages injecting Java objects into all RenderViewHosts associated with |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 593 | // this WebContentsImpl. |
[email protected] | 483623eb | 2011-10-25 09:30:00 | [diff] [blame] | 594 | scoped_ptr<JavaBridgeDispatcherHostManager> |
| 595 | java_bridge_dispatcher_host_manager_; |
| 596 | |
[email protected] | 8dd709fb | 2012-04-06 00:49:06 | [diff] [blame] | 597 | scoped_ptr<content::BrowserPluginWebContentsObserver> |
| 598 | browser_plugin_web_contents_observer_; |
[email protected] | c7dd2f6 | 2011-07-18 15:57:59 | [diff] [blame] | 599 | // SavePackage, lazily created. |
| 600 | scoped_refptr<SavePackage> save_package_; |
| 601 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 602 | // Data for loading state ---------------------------------------------------- |
| 603 | |
| 604 | // Indicates whether we're currently loading a resource. |
| 605 | bool is_loading_; |
| 606 | |
| 607 | // Indicates if the tab is considered crashed. |
| 608 | base::TerminationStatus crashed_status_; |
| 609 | int crashed_error_code_; |
| 610 | |
[email protected] | ca13a44 | 2012-04-17 14:00:12 | [diff] [blame] | 611 | // Whether this WebContents is waiting for a first-response for the |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 612 | // main resource of the page. This controls whether the throbber state is |
| 613 | // "waiting" or "loading." |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 614 | bool waiting_for_response_; |
| 615 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 616 | // Map of SiteInstance ID to max page ID for this tab. A page ID is specific |
| 617 | // to a given tab and SiteInstance, and must be valid for the lifetime of the |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 618 | // WebContentsImpl. |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 619 | std::map<int32, int32> max_page_ids_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 620 | |
| 621 | // System time at which the current load was started. |
| 622 | base::TimeTicks current_load_start_; |
| 623 | |
| 624 | // The current load state and the URL associated with it. |
[email protected] | 9c235f04 | 2011-08-10 22:28:21 | [diff] [blame] | 625 | net::LoadStateWithParam load_state_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 626 | string16 load_state_host_; |
| 627 | // Upload progress, for displaying in the status bar. |
| 628 | // Set to zero when there is no significant upload happening. |
| 629 | uint64 upload_size_; |
| 630 | uint64 upload_position_; |
| 631 | |
| 632 | // Data for current page ----------------------------------------------------- |
| 633 | |
[email protected] | 987fc3a | 2011-05-26 14:18:09 | [diff] [blame] | 634 | // When a title cannot be taken from any entry, this title will be used. |
| 635 | string16 page_title_when_no_navigation_entry_; |
| 636 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 637 | // When a navigation occurs, we record its contents MIME type. It can be |
| 638 | // used to check whether we can do something for some special contents. |
| 639 | std::string contents_mime_type_; |
| 640 | |
| 641 | // Character encoding. |
| 642 | std::string encoding_; |
| 643 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 644 | // True if this is a secure page which displayed insecure content. |
| 645 | bool displayed_insecure_content_; |
| 646 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 647 | // Data for misc internal state ---------------------------------------------- |
| 648 | |
[email protected] | ca13a44 | 2012-04-17 14:00:12 | [diff] [blame] | 649 | // Whether the WebContents is currently being screenshotted. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 650 | bool capturing_contents_; |
| 651 | |
| 652 | // See getter above. |
| 653 | bool is_being_destroyed_; |
| 654 | |
| 655 | // Indicates whether we should notify about disconnection of this |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 656 | // WebContentsImpl. This is used to ensure disconnection notifications only |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 657 | // happen if a connection notification has happened and that they happen only |
| 658 | // once. |
| 659 | bool notify_disconnection_; |
| 660 | |
[email protected] | 2e5b90c | 2011-08-16 21:11:55 | [diff] [blame] | 661 | // Pointer to the JavaScript dialog creator, lazily assigned. Used because the |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 662 | // delegate of this WebContentsImpl is nulled before its destructor is called. |
[email protected] | 2e5b90c | 2011-08-16 21:11:55 | [diff] [blame] | 663 | content::JavaScriptDialogCreator* dialog_creator_; |
| 664 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 665 | #if defined(OS_WIN) |
| 666 | // Handle to an event that's set when the page is showing a message box (or |
| 667 | // equivalent constrained window). Plugin processes check this to know if |
| 668 | // they should pump messages then. |
| 669 | base::win::ScopedHandle message_box_active_; |
| 670 | #endif |
| 671 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 672 | // Set to true when there is an active "before unload" dialog. When true, |
| 673 | // we've forced the throbber to start in Navigate, and we need to remember to |
| 674 | // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled. |
| 675 | bool is_showing_before_unload_dialog_; |
| 676 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 677 | // Settings that get passed to the renderer process. |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 678 | content::RendererPreferences renderer_preferences_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 679 | |
| 680 | // If this tab was created from a renderer using window.open, this will be |
| 681 | // non-NULL and represent the WebUI of the opening renderer. |
[email protected] | 01ec4ec | 2012-01-18 04:13:47 | [diff] [blame] | 682 | content::WebUI::TypeID opener_web_ui_type_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 683 | |
| 684 | // The time that we started to create the new tab page. |
| 685 | base::TimeTicks new_tab_start_time_; |
| 686 | |
[email protected] | 3bbacc5b | 2012-04-17 17:46:15 | [diff] [blame] | 687 | // The time that we started to close this WebContents. |
| 688 | base::TimeTicks close_start_time_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 689 | |
| 690 | // The time that this tab was last selected. |
| 691 | base::TimeTicks last_selected_time_; |
| 692 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 693 | // See description above setter. |
| 694 | bool closed_by_user_gesture_; |
| 695 | |
| 696 | // Minimum/maximum zoom percent. |
| 697 | int minimum_zoom_percent_; |
| 698 | int maximum_zoom_percent_; |
| 699 | // If true, the default zoom limits have been overriden for this tab, in which |
| 700 | // case we don't want saved settings to apply to it and we don't want to |
| 701 | // remember it. |
| 702 | bool temporary_zoom_settings_; |
| 703 | |
[email protected] | bcd281560 | 2012-01-14 18:17:23 | [diff] [blame] | 704 | // The intrinsic size of the page. |
| 705 | gfx::Size preferred_size_; |
| 706 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 707 | // Content restrictions, used to disable print/copy etc based on content's |
| 708 | // (full-page plugins for now only) permissions. |
| 709 | int content_restrictions_; |
| 710 | |
[email protected] | e018d3b | 2012-04-17 13:24:15 | [diff] [blame] | 711 | // Our view type. Default is VIEW_TYPE_WEB_CONTENTS. |
[email protected] | 32ded221 | 2011-11-10 18:51:43 | [diff] [blame] | 712 | content::ViewType view_type_; |
| 713 | |
[email protected] | da854376 | 2012-03-20 08:52:20 | [diff] [blame] | 714 | // Color chooser that was opened by this tab. |
| 715 | content::ColorChooser* color_chooser_; |
| 716 | |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 717 | DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 718 | }; |
| 719 | |
[email protected] | 93ddb3c | 2012-04-11 21:44:29 | [diff] [blame] | 720 | #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |