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