[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 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 | |
| 13 | #include "base/basictypes.h" |
| 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] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 18 | #include "base/string16.h" |
[email protected] | c7dd2f6 | 2011-07-18 15:57:59 | [diff] [blame] | 19 | #include "content/browser/download/save_package.h" |
[email protected] | 3ab9cb8 | 2011-06-03 18:02:07 | [diff] [blame] | 20 | #include "content/browser/javascript_dialogs.h" |
[email protected] | 0716190 | 2011-11-11 09:57:42 | [diff] [blame] | 21 | #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager.h" |
[email protected] | 5de63471 | 2011-03-02 00:20:19 | [diff] [blame] | 22 | #include "content/browser/renderer_host/render_view_host_delegate.h" |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 23 | #include "content/browser/tab_contents/navigation_controller.h" |
| 24 | #include "content/browser/tab_contents/navigation_entry.h" |
| 25 | #include "content/browser/tab_contents/page_navigator.h" |
| 26 | #include "content/browser/tab_contents/render_view_host_manager.h" |
[email protected] | 553602e1 | 2011-04-05 17:01:18 | [diff] [blame] | 27 | #include "content/browser/tab_contents/tab_contents_observer.h" |
[email protected] | 1fd1a50 | 2011-03-30 16:55:56 | [diff] [blame] | 28 | #include "content/browser/webui/web_ui.h" |
[email protected] | 8d128d6 | 2011-09-13 22:11:57 | [diff] [blame] | 29 | #include "content/common/content_export.h" |
[email protected] | 58f5d56 | 2011-12-20 17:13:03 | [diff] [blame] | 30 | #include "content/public/browser/web_contents.h" |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 31 | #include "content/public/common/renderer_preferences.h" |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 32 | #include "net/base/load_states.h" |
| 33 | #include "ui/gfx/native_widget_types.h" |
[email protected] | 7043596 | 2011-08-02 20:13:28 | [diff] [blame] | 34 | #include "webkit/glue/resource_type.h" |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 35 | |
| 36 | #if defined(OS_WIN) |
| 37 | #include "base/win/scoped_handle.h" |
| 38 | #endif |
| 39 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 40 | class LoadNotificationDetails; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 41 | class RenderViewHost; |
| 42 | class SessionStorageNamespace; |
| 43 | class SiteInstance; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 44 | class TabContentsObserver; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 45 | class TabContentsView; |
[email protected] | d7b175e | 2011-10-11 15:31:58 | [diff] [blame] | 46 | struct ViewHostMsg_DidFailProvisionalLoadWithError_Params; |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 47 | |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 48 | namespace content { |
| 49 | class DownloadItem; |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 50 | class WebContentsDelegate; |
[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] | 58f5d56 | 2011-12-20 17:13:03 | [diff] [blame] | 57 | class CONTENT_EXPORT TabContents : public content::WebContents, |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 58 | public PageNavigator, |
[email protected] | 8d128d6 | 2011-09-13 22:11:57 | [diff] [blame] | 59 | public RenderViewHostDelegate, |
| 60 | public RenderViewHostManager::Delegate, |
| 61 | public content::JavaScriptDialogDelegate { |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 62 | public: |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 63 | // Flags passed to the WebContentsDelegate.NavigationStateChanged to tell it |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 64 | // what has changed. Combine them to update more than one thing. |
| 65 | enum InvalidateTypes { |
| 66 | INVALIDATE_URL = 1 << 0, // The URL has changed. |
| 67 | INVALIDATE_TAB = 1 << 1, // The favicon, app icon, or crashed |
| 68 | // state changed. |
| 69 | INVALIDATE_LOAD = 1 << 2, // The loading state has changed. |
| 70 | INVALIDATE_PAGE_ACTIONS = 1 << 3, // Page action icons have changed. |
[email protected] | 93f230e0 | 2011-06-01 14:40:00 | [diff] [blame] | 71 | INVALIDATE_TITLE = 1 << 4, // The title changed. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | // |base_tab_contents| is used if we want to size the new tab contents view |
| 75 | // based on an existing tab contents view. This can be NULL if not needed. |
| 76 | // |
| 77 | // The session storage namespace parameter allows multiple render views and |
| 78 | // tab contentses to share the same session storage (part of the WebStorage |
| 79 | // spec) space. This is useful when restoring tabs, but most callers should |
| 80 | // pass in NULL which will cause a new SessionStorageNamespace to be created. |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 81 | TabContents(content::BrowserContext* browser_context, |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 82 | SiteInstance* site_instance, |
| 83 | int routing_id, |
| 84 | const TabContents* base_tab_contents, |
| 85 | SessionStorageNamespace* session_storage_namespace); |
| 86 | virtual ~TabContents(); |
| 87 | |
| 88 | // Intrinsic tab state ------------------------------------------------------- |
| 89 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 90 | // Returns the user browser context associated with this TabContents (via the |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 91 | // NavigationController). |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 92 | content::BrowserContext* browser_context() const { |
| 93 | return controller_.browser_context(); |
| 94 | } |
| 95 | |
[email protected] | c7dd2f6 | 2011-07-18 15:57:59 | [diff] [blame] | 96 | // Returns the SavePackage which manages the page saving job. May be NULL. |
| 97 | SavePackage* save_package() const { return save_package_.get(); } |
| 98 | |
[email protected] | 93f230e0 | 2011-06-01 14:40:00 | [diff] [blame] | 99 | WebUI* committed_web_ui() const { |
| 100 | return render_manager_.web_ui(); |
| 101 | } |
| 102 | |
[email protected] | 6e5a00a | 2011-10-13 17:47:16 | [diff] [blame] | 103 | // Returns the committed WebUI if one exists, otherwise the pending one. |
| 104 | // Callers who want to use the pending WebUI for the pending navigation entry |
| 105 | // should use GetWebUIForCurrentState instead. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 106 | WebUI* web_ui() const { |
| 107 | return render_manager_.web_ui() ? render_manager_.web_ui() |
| 108 | : render_manager_.pending_web_ui(); |
| 109 | } |
| 110 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 111 | // Tab navigation state ------------------------------------------------------ |
| 112 | |
| 113 | // Returns the current navigation properties, which if a navigation is |
| 114 | // pending may be provisional (e.g., the navigation could result in a |
| 115 | // download, in which case the URL would revert to what it was previously). |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 116 | virtual const GURL& GetURL() const OVERRIDE; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 117 | virtual const string16& GetTitle() const; |
| 118 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 119 | // The max page ID for any page that the current SiteInstance has loaded in |
| 120 | // this TabContents. Page IDs are specific to a given SiteInstance and |
| 121 | // TabContents, corresponding to a specific RenderView in the renderer. |
| 122 | // Page IDs increase with each new page that is loaded by a tab. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 123 | int32 GetMaxPageID(); |
| 124 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 125 | // The max page ID for any page that the given SiteInstance has loaded in |
| 126 | // this TabContents. |
| 127 | int32 GetMaxPageIDForSiteInstance(SiteInstance* site_instance); |
| 128 | |
| 129 | // Updates the max page ID for the current SiteInstance in this TabContents |
| 130 | // to be at least |page_id|. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 131 | void UpdateMaxPageID(int32 page_id); |
| 132 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 133 | // Updates the max page ID for the given SiteInstance in this TabContents |
| 134 | // to be at least |page_id|. |
| 135 | void UpdateMaxPageIDForSiteInstance(SiteInstance* site_instance, |
| 136 | int32 page_id); |
| 137 | |
| 138 | // Returns the SiteInstance associated with the current page. |
| 139 | SiteInstance* GetSiteInstance() const; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 140 | |
[email protected] | 77362eb | 2011-08-01 17:18:38 | [diff] [blame] | 141 | // Returns the SiteInstance for the pending navigation, if any. Otherwise |
| 142 | // returns the current SiteInstance. |
| 143 | SiteInstance* GetPendingSiteInstance() const; |
| 144 | |
[email protected] | 755d174b | 2011-11-07 23:33:30 | [diff] [blame] | 145 | // Return whether this tab contents is loading a resource. |
| 146 | bool IsLoading() const { return is_loading_; } |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 147 | |
| 148 | // Returns whether this tab contents is waiting for a first-response for the |
| 149 | // main resource of the page. This controls whether the throbber state is |
| 150 | // "waiting" or "loading." |
| 151 | bool waiting_for_response() const { return waiting_for_response_; } |
| 152 | |
[email protected] | 9c235f04 | 2011-08-10 22:28:21 | [diff] [blame] | 153 | const net::LoadStateWithParam& load_state() const { return load_state_; } |
| 154 | const string16& load_state_host() const { return load_state_host_; } |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 155 | uint64 upload_size() const { return upload_size_; } |
| 156 | uint64 upload_position() const { return upload_position_; } |
| 157 | |
| 158 | const std::string& encoding() const { return encoding_; } |
| 159 | void set_encoding(const std::string& encoding); |
| 160 | void reset_encoding() { |
| 161 | encoding_.clear(); |
| 162 | } |
| 163 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 164 | bool displayed_insecure_content() const { |
| 165 | return displayed_insecure_content_; |
| 166 | } |
| 167 | |
| 168 | // Internal state ------------------------------------------------------------ |
| 169 | |
| 170 | // This flag indicates whether the tab contents is currently being |
| 171 | // screenshotted by the DraggedTabController. |
| 172 | bool capturing_contents() const { return capturing_contents_; } |
| 173 | void set_capturing_contents(bool cap) { capturing_contents_ = cap; } |
| 174 | |
| 175 | // Indicates whether this tab should be considered crashed. The setter will |
| 176 | // also notify the delegate when the flag is changed. |
| 177 | bool is_crashed() const { |
| 178 | return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || |
| 179 | crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || |
| 180 | crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); |
| 181 | } |
| 182 | base::TerminationStatus crashed_status() const { return crashed_status_; } |
| 183 | int crashed_error_code() const { return crashed_error_code_; } |
| 184 | void SetIsCrashed(base::TerminationStatus status, int error_code); |
| 185 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 186 | // Whether the tab is in the process of being destroyed. |
| 187 | // Added as a tentative work-around for focus related bug #4633. This allows |
| 188 | // us not to store focus when a tab is being closed. |
| 189 | bool is_being_destroyed() const { return is_being_destroyed_; } |
| 190 | |
| 191 | // Convenience method for notifying the delegate of a navigation state |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 192 | // change. See WebContentsDelegate. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 193 | void NotifyNavigationStateChanged(unsigned changed_flags); |
| 194 | |
| 195 | // Invoked when the tab contents becomes selected. If you override, be sure |
| 196 | // and invoke super's implementation. |
| 197 | virtual void DidBecomeSelected(); |
| 198 | base::TimeTicks last_selected_time() const { |
| 199 | return last_selected_time_; |
| 200 | } |
| 201 | |
| 202 | // Invoked when the tab contents becomes hidden. |
| 203 | // NOTE: If you override this, call the superclass version too! |
| 204 | virtual void WasHidden(); |
| 205 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 206 | // TODO(brettw) document these. |
| 207 | virtual void ShowContents(); |
| 208 | virtual void HideContents(); |
| 209 | |
| 210 | // Returns true if the before unload and unload listeners need to be |
| 211 | // fired. The value of this changes over time. For example, if true and the |
| 212 | // before unload listener is executed and allows the user to exit, then this |
| 213 | // returns false. |
| 214 | bool NeedToFireBeforeUnload(); |
| 215 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 216 | // Expose the render manager for testing. |
[email protected] | 03ff5e5 | 2011-09-30 00:28:14 | [diff] [blame] | 217 | RenderViewHostManager* render_manager_for_testing() { |
| 218 | return &render_manager_; |
| 219 | } |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 220 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 221 | // Commands ------------------------------------------------------------------ |
| 222 | |
| 223 | // Implementation of PageNavigator. |
[email protected] | 00c37fc | 2011-08-02 00:22:50 | [diff] [blame] | 224 | |
| 225 | // Deprecated. Please use the one-argument variant instead. |
| 226 | // TODO(adriansc): Remove this method once refactoring changed all call sites. |
[email protected] | 992e454 | 2011-07-20 23:09:25 | [diff] [blame] | 227 | virtual TabContents* OpenURL(const GURL& url, |
| 228 | const GURL& referrer, |
| 229 | WindowOpenDisposition disposition, |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 230 | content::PageTransition transition) OVERRIDE; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 231 | |
[email protected] | 00c37fc | 2011-08-02 00:22:50 | [diff] [blame] | 232 | virtual TabContents* OpenURL(const OpenURLParams& params) OVERRIDE; |
| 233 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 234 | // Called by the NavigationController to cause the TabContents to navigate to |
| 235 | // the current pending entry. The NavigationController should be called back |
[email protected] | 9a7e68c | 2011-05-26 17:35:50 | [diff] [blame] | 236 | // with RendererDidNavigate on success or DiscardPendingEntry on failure. |
| 237 | // The callbacks can be inside of this function, or at some future time. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 238 | // |
| 239 | // The entry has a PageID of -1 if newly created (corresponding to navigation |
| 240 | // to a new URL). |
| 241 | // |
| 242 | // If this method returns false, then the navigation is discarded (equivalent |
| 243 | // to calling DiscardPendingEntry on the NavigationController). |
| 244 | virtual bool NavigateToPendingEntry( |
| 245 | NavigationController::ReloadType reload_type); |
| 246 | |
| 247 | // Stop any pending navigation. |
| 248 | virtual void Stop(); |
| 249 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 250 | // Creates a new TabContents with the same state as this one. The returned |
| 251 | // heap-allocated pointer is owned by the caller. |
| 252 | virtual TabContents* Clone(); |
| 253 | |
| 254 | // Shows the page info. |
| 255 | void ShowPageInfo(const GURL& url, |
| 256 | const NavigationEntry::SSLStatus& ssl, |
| 257 | bool show_history); |
| 258 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 259 | // Window management --------------------------------------------------------- |
| 260 | |
[email protected] | 47317494 | 2011-04-19 22:52:35 | [diff] [blame] | 261 | // Adds a new tab or window with the given already-created contents. |
[email protected] | e7cfdbd | 2011-04-22 14:41:37 | [diff] [blame] | 262 | void AddNewContents(TabContents* new_contents, |
| 263 | WindowOpenDisposition disposition, |
| 264 | const gfx::Rect& initial_pos, |
| 265 | bool user_gesture); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 266 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 267 | // Views and focus ----------------------------------------------------------- |
| 268 | // TODO(brettw): Most of these should be removed and the caller should call |
| 269 | // the view directly. |
| 270 | |
| 271 | // Returns the actual window that is focused when this TabContents is shown. |
| 272 | gfx::NativeView GetContentNativeView() const; |
| 273 | |
| 274 | // Returns the NativeView associated with this TabContents. Outside of |
| 275 | // automation in the context of the UI, this is required to be implemented. |
| 276 | gfx::NativeView GetNativeView() const; |
| 277 | |
| 278 | // Returns the bounds of this TabContents in the screen coordinate system. |
| 279 | void GetContainerBounds(gfx::Rect *out) const; |
| 280 | |
| 281 | // Makes the tab the focused window. |
| 282 | void Focus(); |
| 283 | |
| 284 | // Focuses the first (last if |reverse| is true) element in the page. |
| 285 | // Invoked when this tab is getting the focus through tab traversal (|reverse| |
| 286 | // is true when using Shift-Tab). |
| 287 | void FocusThroughTabTraversal(bool reverse); |
| 288 | |
| 289 | // These next two functions are declared on RenderViewHostManager::Delegate |
| 290 | // but also accessed directly by other callers. |
| 291 | |
| 292 | // Returns true if the location bar should be focused by default rather than |
| 293 | // the page contents. The view calls this function when the tab is focused |
| 294 | // to see what it should do. |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 295 | virtual bool FocusLocationBarByDefault() OVERRIDE; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 296 | |
| 297 | // Focuses the location bar. |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 298 | virtual void SetFocusToLocationBar(bool select_all) OVERRIDE; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 299 | |
| 300 | // Creates a view and sets the size for the specified RVH. |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 301 | virtual void CreateViewAndSetSizeForRVH(RenderViewHost* rvh) OVERRIDE; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 302 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 303 | // Toolbars and such --------------------------------------------------------- |
| 304 | |
[email protected] | 68649314 | 2011-07-15 21:47:22 | [diff] [blame] | 305 | // Notifies the delegate that a download is about to be started. |
| 306 | // This notification is fired before a local temporary file has been created. |
| 307 | bool CanDownload(int request_id); |
| 308 | |
| 309 | // Notifies the delegate that a download started. |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 310 | void OnStartDownload(content::DownloadItem* download); |
[email protected] | 68649314 | 2011-07-15 21:47:22 | [diff] [blame] | 311 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 312 | // Interstitials ------------------------------------------------------------- |
| 313 | |
| 314 | // Various other systems need to know about our interstitials. |
| 315 | bool showing_interstitial_page() const { |
| 316 | return render_manager_.interstitial_page() != NULL; |
| 317 | } |
| 318 | |
| 319 | // Sets the passed passed interstitial as the currently showing interstitial. |
| 320 | // |interstitial_page| should be non NULL (use the remove_interstitial_page |
| 321 | // method to unset the interstitial) and no interstitial page should be set |
| 322 | // when there is already a non NULL interstitial page set. |
| 323 | void set_interstitial_page(InterstitialPage* interstitial_page) { |
| 324 | render_manager_.set_interstitial_page(interstitial_page); |
| 325 | } |
| 326 | |
| 327 | // Unsets the currently showing interstitial. |
| 328 | void remove_interstitial_page() { |
| 329 | render_manager_.remove_interstitial_page(); |
| 330 | } |
| 331 | |
| 332 | // Returns the currently showing interstitial, NULL if no interstitial is |
| 333 | // showing. |
| 334 | InterstitialPage* interstitial_page() const { |
| 335 | return render_manager_.interstitial_page(); |
| 336 | } |
| 337 | |
| 338 | // Misc state & callbacks ---------------------------------------------------- |
| 339 | |
[email protected] | c7dd2f6 | 2011-07-18 15:57:59 | [diff] [blame] | 340 | // Prepare for saving the current web page to disk. |
| 341 | void OnSavePage(); |
| 342 | |
| 343 | // Save page with the main HTML file path, the directory for saving resources, |
| 344 | // and the save type: HTML only or complete web page. Returns true if the |
| 345 | // saving process has been initiated successfully. |
| 346 | bool SavePage(const FilePath& main_file, const FilePath& dir_path, |
| 347 | SavePackage::SavePackageType save_type); |
| 348 | |
| 349 | // Prepare for saving the URL to disk. |
| 350 | // URL may refer to the iframe on the page. |
| 351 | void OnSaveURL(const GURL& url); |
| 352 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 353 | // Returns true if the active NavigationEntry's page_id equals page_id. |
| 354 | bool IsActiveEntry(int32 page_id); |
| 355 | |
| 356 | const std::string& contents_mime_type() const { |
| 357 | return contents_mime_type_; |
| 358 | } |
| 359 | |
| 360 | // Returns true if this TabContents will notify about disconnection. |
| 361 | bool notify_disconnection() const { return notify_disconnection_; } |
| 362 | |
| 363 | // Override the encoding and reload the page by sending down |
| 364 | // ViewMsg_SetPageEncoding to the renderer. |UpdateEncoding| is kinda |
| 365 | // the opposite of this, by which 'browser' is notified of |
| 366 | // the encoding of the current tab from 'renderer' (determined by |
| 367 | // auto-detect, http header, meta, bom detection, etc). |
| 368 | void SetOverrideEncoding(const std::string& encoding); |
| 369 | |
| 370 | // Remove any user-defined override encoding and reload by sending down |
| 371 | // ViewMsg_ResetPageEncodingToDefault to the renderer. |
| 372 | void ResetOverrideEncoding(); |
| 373 | |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 374 | content::RendererPreferences* GetMutableRendererPrefs() { |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 375 | return &renderer_preferences_; |
| 376 | } |
| 377 | |
[email protected] | 1fd1a50 | 2011-03-30 16:55:56 | [diff] [blame] | 378 | void set_opener_web_ui_type(WebUI::TypeID opener_web_ui_type) { |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 379 | opener_web_ui_type_ = opener_web_ui_type; |
| 380 | } |
| 381 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 382 | // Set the time when we started to create the new tab page. This time is |
| 383 | // from before we created this TabContents. |
| 384 | void set_new_tab_start_time(const base::TimeTicks& time) { |
| 385 | new_tab_start_time_ = time; |
| 386 | } |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 387 | base::TimeTicks new_tab_start_time() const { return new_tab_start_time_; } |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 388 | |
| 389 | // Notification that tab closing has started. This can be called multiple |
| 390 | // times, subsequent calls are ignored. |
| 391 | void OnCloseStarted(); |
| 392 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 393 | // Returns true if underlying TabContentsView should accept drag-n-drop. |
| 394 | bool ShouldAcceptDragAndDrop() const; |
| 395 | |
| 396 | // A render view-originated drag has ended. Informs the render view host and |
| 397 | // tab contents delegate. |
| 398 | void SystemDragEnded(); |
| 399 | |
| 400 | // Indicates if this tab was explicitly closed by the user (control-w, close |
| 401 | // tab menu item...). This is false for actions that indirectly close the tab, |
| 402 | // such as closing the window. The setter is maintained by TabStripModel, and |
| 403 | // the getter only useful from within TAB_CLOSED notification |
| 404 | void set_closed_by_user_gesture(bool value) { |
| 405 | closed_by_user_gesture_ = value; |
| 406 | } |
| 407 | bool closed_by_user_gesture() const { return closed_by_user_gesture_; } |
| 408 | |
[email protected] | 3ab9cb8 | 2011-06-03 18:02:07 | [diff] [blame] | 409 | // Overridden from JavaScriptDialogDelegate: |
| 410 | virtual void OnDialogClosed(IPC::Message* reply_msg, |
| 411 | bool success, |
| 412 | const string16& user_input) OVERRIDE; |
[email protected] | 0b08add | 2011-11-29 03:27:06 | [diff] [blame] | 413 | virtual gfx::NativeWindow GetDialogRootWindow() const OVERRIDE; |
[email protected] | a1e97f0 | 2011-06-30 14:04:34 | [diff] [blame] | 414 | virtual void OnDialogShown() OVERRIDE; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 415 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 416 | // Gets the zoom level for this tab. |
| 417 | double GetZoomLevel() const; |
| 418 | |
| 419 | // Gets the zoom percent for this tab. |
| 420 | int GetZoomPercent(bool* enable_increment, bool* enable_decrement); |
| 421 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 422 | // Opens view-source tab for this contents. |
| 423 | void ViewSource(); |
| 424 | |
[email protected] | 932b7a1 | 2011-03-09 12:50:27 | [diff] [blame] | 425 | void ViewFrameSource(const GURL& url, |
| 426 | const std::string& content_state); |
| 427 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 428 | // Gets the minimum/maximum zoom percent. |
| 429 | int minimum_zoom_percent() const { return minimum_zoom_percent_; } |
| 430 | int maximum_zoom_percent() const { return maximum_zoom_percent_; } |
| 431 | |
| 432 | int content_restrictions() const { return content_restrictions_; } |
[email protected] | c40d623 | 2011-03-25 00:16:21 | [diff] [blame] | 433 | void SetContentRestrictions(int restrictions); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 434 | |
[email protected] | 1fd1a50 | 2011-03-30 16:55:56 | [diff] [blame] | 435 | // Query the WebUIFactory for the TypeID for the current URL. |
| 436 | WebUI::TypeID GetWebUITypeForCurrentState(); |
| 437 | |
[email protected] | b375c5d | 2011-05-03 21:15:04 | [diff] [blame] | 438 | // Returns the WebUI for the current state of the tab. This will either be |
| 439 | // the pending WebUI, the committed WebUI, or NULL. |
| 440 | WebUI* GetWebUIForCurrentState(); |
| 441 | |
[email protected] | e962111 | 2011-10-17 05:38:37 | [diff] [blame] | 442 | // Called when the reponse to a pending mouse lock request has arrived. |
| 443 | // Returns true if |allowed| is true and the mouse has been successfully |
| 444 | // locked. |
| 445 | bool GotResponseToLockMouseRequest(bool allowed); |
| 446 | |
[email protected] | 276b37a2 | 2011-11-08 20:45:46 | [diff] [blame] | 447 | JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const { |
| 448 | return java_bridge_dispatcher_host_manager_.get(); |
| 449 | } |
| 450 | |
[email protected] | 58f5d56 | 2011-12-20 17:13:03 | [diff] [blame] | 451 | // content::WebContents ------------------------------------------------------ |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 452 | virtual const base::PropertyBag* GetPropertyBag() const OVERRIDE; |
| 453 | virtual base::PropertyBag* GetPropertyBag() OVERRIDE; |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 454 | virtual content::WebContentsDelegate* GetDelegate() OVERRIDE; |
| 455 | virtual void SetDelegate(content::WebContentsDelegate* delegate) OVERRIDE; |
[email protected] | f5fa20e | 2011-12-21 22:35:56 | [diff] [blame] | 456 | virtual NavigationController& GetController() OVERRIDE; |
| 457 | virtual const NavigationController& GetController() const OVERRIDE; |
[email protected] | 627e051 | 2011-12-21 22:55:30 | [diff] [blame^] | 458 | virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; |
[email protected] | f5fa20e | 2011-12-21 22:35:56 | [diff] [blame] | 459 | virtual void SetViewType(content::ViewType type) OVERRIDE; |
| 460 | virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE; |
[email protected] | 151a63d | 2011-12-20 22:32:52 | [diff] [blame] | 461 | virtual RenderViewHost* GetRenderViewHost() const OVERRIDE; |
[email protected] | d487beefe | 2011-12-21 05:41:21 | [diff] [blame] | 462 | // TODO(jam): webui stuff goes here |
| 463 | virtual RenderWidgetHostView* GetRenderWidgetHostView() const OVERRIDE; |
| 464 | virtual TabContentsView* GetView() const OVERRIDE; |
[email protected] | 151a63d | 2011-12-20 22:32:52 | [diff] [blame] | 465 | |
| 466 | |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 467 | // RenderViewHostDelegate ---------------------------------------------------- |
| 468 | |
| 469 | virtual RenderViewHostDelegate::View* GetViewDelegate() OVERRIDE; |
| 470 | virtual RenderViewHostDelegate::RendererManagement* |
| 471 | GetRendererManagementDelegate() OVERRIDE; |
| 472 | virtual TabContents* GetAsTabContents() OVERRIDE; |
| 473 | virtual content::ViewType GetRenderViewType() const OVERRIDE; |
| 474 | virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
| 475 | virtual void RenderViewReady(RenderViewHost* render_view_host) OVERRIDE; |
| 476 | virtual void RenderViewGone(RenderViewHost* render_view_host, |
| 477 | base::TerminationStatus status, |
| 478 | int error_code) OVERRIDE; |
| 479 | virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; |
| 480 | virtual void DidNavigate( |
| 481 | RenderViewHost* render_view_host, |
| 482 | const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; |
| 483 | virtual void UpdateState(RenderViewHost* render_view_host, |
| 484 | int32 page_id, |
| 485 | const std::string& state) OVERRIDE; |
| 486 | virtual void UpdateTitle(RenderViewHost* render_view_host, |
| 487 | int32 page_id, |
| 488 | const string16& title, |
| 489 | base::i18n::TextDirection title_direction) OVERRIDE; |
| 490 | virtual void UpdateEncoding(RenderViewHost* render_view_host, |
| 491 | const std::string& encoding) OVERRIDE; |
| 492 | virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE; |
| 493 | virtual void Close(RenderViewHost* render_view_host) OVERRIDE; |
| 494 | virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE; |
| 495 | virtual void SwappedOut(RenderViewHost* render_view_host) OVERRIDE; |
| 496 | virtual void DidStartLoading() OVERRIDE; |
| 497 | virtual void DidStopLoading() OVERRIDE; |
| 498 | virtual void DidCancelLoading() OVERRIDE; |
| 499 | virtual void DidChangeLoadProgress(double progress) OVERRIDE; |
| 500 | virtual void DocumentAvailableInMainFrame( |
| 501 | RenderViewHost* render_view_host) OVERRIDE; |
| 502 | virtual void DocumentOnLoadCompletedInMainFrame( |
| 503 | RenderViewHost* render_view_host, |
| 504 | int32 page_id) OVERRIDE; |
| 505 | virtual void RequestOpenURL(const GURL& url, |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 506 | const content::Referrer& referrer, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 507 | WindowOpenDisposition disposition, |
| 508 | int64 source_frame_id) OVERRIDE; |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 509 | virtual void RequestTransferURL( |
| 510 | const GURL& url, |
[email protected] | bce1f1c | 2011-12-05 15:11:58 | [diff] [blame] | 511 | const content::Referrer& referrer, |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 512 | WindowOpenDisposition disposition, |
| 513 | int64 source_frame_id, |
| 514 | const GlobalRequestID& transferred_global_request_id) OVERRIDE; |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 515 | virtual void RunJavaScriptMessage(const RenderViewHost* rvh, |
| 516 | const string16& message, |
| 517 | const string16& default_prompt, |
| 518 | const GURL& frame_url, |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 519 | ui::JavascriptMessageType type, |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 520 | IPC::Message* reply_msg, |
| 521 | bool* did_suppress_message) OVERRIDE; |
| 522 | virtual void RunBeforeUnloadConfirm(const RenderViewHost* rvh, |
| 523 | const string16& message, |
| 524 | IPC::Message* reply_msg) OVERRIDE; |
| 525 | virtual content::RendererPreferences GetRendererPrefs( |
| 526 | content::BrowserContext* browser_context) const OVERRIDE; |
| 527 | virtual WebPreferences GetWebkitPrefs() OVERRIDE; |
| 528 | virtual void OnUserGesture() OVERRIDE; |
| 529 | virtual void OnIgnoredUIEvent() OVERRIDE; |
| 530 | virtual void RendererUnresponsive(RenderViewHost* render_view_host, |
| 531 | bool is_during_unload) OVERRIDE; |
| 532 | virtual void RendererResponsive(RenderViewHost* render_view_host) OVERRIDE; |
| 533 | virtual void LoadStateChanged(const GURL& url, |
| 534 | const net::LoadStateWithParam& load_state, |
| 535 | uint64 upload_position, |
| 536 | uint64 upload_size) OVERRIDE; |
| 537 | virtual void WorkerCrashed() OVERRIDE; |
| 538 | virtual void Activate() OVERRIDE; |
| 539 | virtual void Deactivate() OVERRIDE; |
| 540 | virtual void LostCapture() OVERRIDE; |
| 541 | virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 542 | bool* is_keyboard_shortcut) OVERRIDE; |
| 543 | virtual void HandleKeyboardEvent( |
| 544 | const NativeWebKeyboardEvent& event) OVERRIDE; |
| 545 | virtual void HandleMouseDown() OVERRIDE; |
| 546 | virtual void HandleMouseUp() OVERRIDE; |
| 547 | virtual void HandleMouseActivate() OVERRIDE; |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 548 | virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 549 | virtual void RunFileChooser( |
| 550 | RenderViewHost* render_view_host, |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 551 | const content::FileChooserParams& params) OVERRIDE; |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 552 | virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE; |
| 553 | virtual bool IsFullscreenForCurrentTab() const OVERRIDE; |
| 554 | virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE; |
| 555 | virtual void WebUISend(RenderViewHost* render_view_host, |
| 556 | const GURL& source_url, |
| 557 | const std::string& name, |
| 558 | const base::ListValue& args) OVERRIDE; |
| 559 | virtual void RequestToLockMouse() OVERRIDE; |
| 560 | virtual void LostMouseLock() OVERRIDE; |
| 561 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 562 | protected: |
[email protected] | 553602e1 | 2011-04-05 17:01:18 | [diff] [blame] | 563 | friend class TabContentsObserver; |
[email protected] | 553602e1 | 2011-04-05 17:01:18 | [diff] [blame] | 564 | |
| 565 | // Add and remove observers for page navigation notifications. Adding or |
| 566 | // removing multiple times has no effect. The order in which notifications |
| 567 | // are sent to observers is undefined. Clients must be sure to remove the |
| 568 | // observer before they go away. |
| 569 | void AddObserver(TabContentsObserver* observer); |
| 570 | void RemoveObserver(TabContentsObserver* observer); |
| 571 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 572 | private: |
| 573 | friend class NavigationController; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 574 | |
| 575 | FRIEND_TEST_ALL_PREFIXES(TabContentsTest, NoJSMessageOnInterstitials); |
| 576 | FRIEND_TEST_ALL_PREFIXES(TabContentsTest, UpdateTitle); |
| 577 | FRIEND_TEST_ALL_PREFIXES(TabContentsTest, CrossSiteCantPreemptAfterUnload); |
| 578 | FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles); |
| 579 | FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate); |
| 580 | FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload); |
| 581 | |
| 582 | // Temporary until the view/contents separation is complete. |
| 583 | friend class TabContentsView; |
[email protected] | 9a56a0d | 2011-05-13 19:03:31 | [diff] [blame] | 584 | #if defined(TOOLKIT_VIEWS) |
[email protected] | 7e2cef5 | 2011-04-11 21:47:23 | [diff] [blame] | 585 | friend class TabContentsViewViews; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 586 | #elif defined(OS_MACOSX) |
| 587 | friend class TabContentsViewMac; |
| 588 | #elif defined(TOOLKIT_USES_GTK) |
| 589 | friend class TabContentsViewGtk; |
| 590 | #endif |
| 591 | |
| 592 | // So InterstitialPage can access SetIsLoading. |
| 593 | friend class InterstitialPage; |
| 594 | |
| 595 | // TODO(brettw) TestTabContents shouldn't exist! |
| 596 | friend class TestTabContents; |
| 597 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 598 | // Message handlers. |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 599 | void OnRegisterIntentService(const string16& action, |
[email protected] | 63c23932 | 2011-10-31 23:56:30 | [diff] [blame] | 600 | const string16& type, |
| 601 | const string16& href, |
| 602 | const string16& title, |
| 603 | const string16& disposition); |
[email protected] | 67810501 | 2011-12-09 04:01:21 | [diff] [blame] | 604 | void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent, |
[email protected] | 63c23932 | 2011-10-31 23:56:30 | [diff] [blame] | 605 | int intent_id); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 606 | void OnDidStartProvisionalLoadForFrame(int64 frame_id, |
| 607 | bool main_frame, |
[email protected] | 57b9396c | 2011-10-07 19:11:59 | [diff] [blame] | 608 | const GURL& opener_url, |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 609 | const GURL& url); |
| 610 | void OnDidRedirectProvisionalLoad(int32 page_id, |
[email protected] | 57b9396c | 2011-10-07 19:11:59 | [diff] [blame] | 611 | const GURL& opener_url, |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 612 | const GURL& source_url, |
| 613 | const GURL& target_url); |
[email protected] | d7b175e | 2011-10-11 15:31:58 | [diff] [blame] | 614 | void OnDidFailProvisionalLoadWithError( |
| 615 | const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 616 | void OnDidLoadResourceFromMemoryCache(const GURL& url, |
[email protected] | 7043596 | 2011-08-02 20:13:28 | [diff] [blame] | 617 | const std::string& security_info, |
| 618 | const std::string& http_request, |
| 619 | ResourceType::Type resource_type); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 620 | void OnDidDisplayInsecureContent(); |
| 621 | void OnDidRunInsecureContent(const std::string& security_origin, |
| 622 | const GURL& target_url); |
| 623 | void OnDocumentLoadedInFrame(int64 frame_id); |
[email protected] | 1a55c5be | 2011-11-29 11:36:31 | [diff] [blame] | 624 | void OnDidFinishLoad(int64 frame_id, |
| 625 | const GURL& validated_url, |
| 626 | bool is_main_frame); |
| 627 | void OnDidFailLoadWithError(int64 frame_id, |
| 628 | const GURL& validated_url, |
| 629 | bool is_main_frame, |
| 630 | int error_code, |
| 631 | const string16& error_description); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 632 | void OnUpdateContentRestrictions(int restrictions); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 633 | void OnGoToEntryAtOffset(int offset); |
[email protected] | 21681395 | 2011-05-19 22:21:26 | [diff] [blame] | 634 | void OnUpdateZoomLimits(int minimum_percent, |
| 635 | int maximum_percent, |
| 636 | bool remember); |
[email protected] | 3a29a6e | 2011-08-24 18:26:21 | [diff] [blame] | 637 | void OnEnumerateDirectory(int request_id, const FilePath& path); |
[email protected] | 7d18902 | 2011-08-25 22:54:20 | [diff] [blame] | 638 | void OnJSOutOfMemory(); |
| 639 | void OnRegisterProtocolHandler(const std::string& protocol, |
| 640 | const GURL& url, |
| 641 | const string16& title); |
[email protected] | b888919c | 2011-09-02 00:32:16 | [diff] [blame] | 642 | void OnFindReply(int request_id, int number_of_matches, |
| 643 | const gfx::Rect& selection_rect, int active_match_ordinal, |
| 644 | bool final_update); |
[email protected] | d952a05 | 2011-09-06 18:42:45 | [diff] [blame] | 645 | void OnCrashedPlugin(const FilePath& plugin_path); |
[email protected] | 7fc4bbb | 2011-09-08 21:23:10 | [diff] [blame] | 646 | void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 647 | |
| 648 | // Changes the IsLoading state and notifies delegate as needed |
| 649 | // |details| is used to provide details on the load that just finished |
| 650 | // (but can be null if not applicable). Can be overridden. |
| 651 | void SetIsLoading(bool is_loading, |
| 652 | LoadNotificationDetails* details); |
| 653 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 654 | // Called by derived classes to indicate that we're no longer waiting for a |
| 655 | // response. This won't actually update the throbber, but it will get picked |
| 656 | // up at the next animation step if the throbber is going. |
| 657 | void SetNotWaitingForResponse() { waiting_for_response_ = false; } |
| 658 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 659 | // Navigation helpers -------------------------------------------------------- |
| 660 | // |
| 661 | // These functions are helpers for Navigate() and DidNavigate(). |
| 662 | |
| 663 | // Handles post-navigation tasks in DidNavigate AFTER the entry has been |
| 664 | // committed to the navigation controller. Note that the navigation entry is |
| 665 | // not provided since it may be invalid/changed after being committed. The |
| 666 | // current navigation entry is in the NavigationController at this point. |
| 667 | void DidNavigateMainFramePostCommit( |
[email protected] | 8286f51a | 2011-05-31 17:39:13 | [diff] [blame] | 668 | const content::LoadCommittedDetails& details, |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 669 | const ViewHostMsg_FrameNavigate_Params& params); |
| 670 | void DidNavigateAnyFramePostCommit( |
| 671 | RenderViewHost* render_view_host, |
[email protected] | 8286f51a | 2011-05-31 17:39:13 | [diff] [blame] | 672 | const content::LoadCommittedDetails& details, |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 673 | const ViewHostMsg_FrameNavigate_Params& params); |
| 674 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 675 | // If our controller was restored, update the max page ID associated with the |
| 676 | // given RenderViewHost to be larger than the number of restored entries. |
| 677 | // This is called in CreateRenderView before any navigations in the RenderView |
| 678 | // have begun, to prevent any races in updating RenderView::next_page_id. |
| 679 | void UpdateMaxPageIDIfNecessary(RenderViewHost* rvh); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 680 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 681 | // Saves the given title to the navigation entry and does associated work. It |
| 682 | // will update history and the view for the new title, and also synthesize |
| 683 | // titles for file URLs that have none (so we require that the URL of the |
| 684 | // entry already be set). |
| 685 | // |
| 686 | // This is used as the backend for state updates, which include a new title, |
| 687 | // or the dedicated set title message. It returns true if the new title is |
| 688 | // different and was therefore updated. |
[email protected] | acafd27 | 2011-07-26 17:35:57 | [diff] [blame] | 689 | bool UpdateTitleForEntry(NavigationEntry* entry, const string16& title); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 690 | |
| 691 | // Causes the TabContents to navigate in the right renderer to |entry|, which |
| 692 | // must be already part of the entries in the navigation controller. |
| 693 | // This does not change the NavigationController state. |
[email protected] | dd11de5 | 2011-11-03 22:54:27 | [diff] [blame] | 694 | bool NavigateToEntry(const NavigationEntry& entry, |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 695 | NavigationController::ReloadType reload_type); |
| 696 | |
[email protected] | 796931a9 | 2011-08-10 01:32:14 | [diff] [blame] | 697 | // Sets the history for this tab_contents to |history_length| entries, and |
| 698 | // moves the current page_id to the last entry in the list if it's valid. |
| 699 | // This is mainly used when a prerendered page is swapped into the current |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 700 | // tab. The method is virtual for testing. |
| 701 | virtual void SetHistoryLengthAndPrune(const SiteInstance* site_instance, |
| 702 | int merge_history_length, |
| 703 | int32 minimum_page_id); |
[email protected] | 796931a9 | 2011-08-10 01:32:14 | [diff] [blame] | 704 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 705 | // Misc non-view stuff ------------------------------------------------------- |
| 706 | |
| 707 | // Helper functions for sending notifications. |
| 708 | void NotifySwapped(); |
| 709 | void NotifyConnected(); |
| 710 | void NotifyDisconnected(); |
| 711 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 712 | // RenderViewHostManager::Delegate ------------------------------------------- |
| 713 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 714 | virtual void BeforeUnloadFiredFromRenderManager( |
| 715 | bool proceed, |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 716 | bool* proceed_to_fire_unload) OVERRIDE; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 717 | virtual void DidStartLoadingFromRenderManager( |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 718 | RenderViewHost* render_view_host) OVERRIDE; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 719 | virtual void RenderViewGoneFromRenderManager( |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 720 | RenderViewHost* render_view_host) OVERRIDE; |
| 721 | virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE; |
| 722 | virtual void NotifySwappedFromRenderManager() OVERRIDE; |
| 723 | virtual NavigationController& GetControllerForRenderManager() OVERRIDE; |
| 724 | virtual WebUI* CreateWebUIForRenderManager(const GURL& url) OVERRIDE; |
| 725 | virtual NavigationEntry* |
| 726 | GetLastCommittedNavigationEntryForRenderManager() OVERRIDE; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 727 | |
| 728 | // Initializes the given renderer if necessary and creates the view ID |
| 729 | // corresponding to this view host. If this method is not called and the |
| 730 | // process is not shared, then the TabContents will act as though the renderer |
| 731 | // is not running (i.e., it will render "sad tab"). This method is |
| 732 | // automatically called from LoadURL. |
| 733 | // |
| 734 | // If you are attaching to an already-existing RenderView, you should call |
| 735 | // InitWithExistingID. |
| 736 | virtual bool CreateRenderViewForRenderManager( |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 737 | RenderViewHost* render_view_host) OVERRIDE; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 738 | |
[email protected] | 8189899 | 2011-06-14 22:15:00 | [diff] [blame] | 739 | // Stores random bits of data for others to associate with this object. |
| 740 | // WARNING: this needs to be deleted after NavigationController. |
[email protected] | 45644f6 | 2011-11-23 00:58:23 | [diff] [blame] | 741 | base::PropertyBag property_bag_; |
[email protected] | 8189899 | 2011-06-14 22:15:00 | [diff] [blame] | 742 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 743 | // Data for core operation --------------------------------------------------- |
| 744 | |
| 745 | // Delegate for notifying our owner about stuff. Not owned by us. |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 746 | content::WebContentsDelegate* delegate_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 747 | |
| 748 | // Handles the back/forward list and loading. |
| 749 | NavigationController controller_; |
| 750 | |
| 751 | // The corresponding view. |
| 752 | scoped_ptr<TabContentsView> view_; |
| 753 | |
[email protected] | 99604297 | 2011-11-08 22:43:59 | [diff] [blame] | 754 | // A list of observers notified when page state changes. Weak references. |
| 755 | // This MUST be listed above render_manager_ since at destruction time the |
| 756 | // latter might cause RenderViewHost's destructor to call us and we might use |
| 757 | // the observer list then. |
| 758 | ObserverList<TabContentsObserver> observers_; |
| 759 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 760 | // Helper classes ------------------------------------------------------------ |
| 761 | |
| 762 | // Manages creation and swapping of render views. |
| 763 | RenderViewHostManager render_manager_; |
| 764 | |
[email protected] | 483623eb | 2011-10-25 09:30:00 | [diff] [blame] | 765 | // Manages injecting Java objects into all RenderViewHosts associated with |
| 766 | // this TabContents. |
| 767 | scoped_ptr<JavaBridgeDispatcherHostManager> |
| 768 | java_bridge_dispatcher_host_manager_; |
| 769 | |
[email protected] | c7dd2f6 | 2011-07-18 15:57:59 | [diff] [blame] | 770 | // SavePackage, lazily created. |
| 771 | scoped_refptr<SavePackage> save_package_; |
| 772 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 773 | // Data for loading state ---------------------------------------------------- |
| 774 | |
| 775 | // Indicates whether we're currently loading a resource. |
| 776 | bool is_loading_; |
| 777 | |
| 778 | // Indicates if the tab is considered crashed. |
| 779 | base::TerminationStatus crashed_status_; |
| 780 | int crashed_error_code_; |
| 781 | |
| 782 | // See waiting_for_response() above. |
| 783 | bool waiting_for_response_; |
| 784 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 785 | // Map of SiteInstance ID to max page ID for this tab. A page ID is specific |
| 786 | // to a given tab and SiteInstance, and must be valid for the lifetime of the |
| 787 | // TabContents. |
| 788 | std::map<int32, int32> max_page_ids_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 789 | |
| 790 | // System time at which the current load was started. |
| 791 | base::TimeTicks current_load_start_; |
| 792 | |
| 793 | // The current load state and the URL associated with it. |
[email protected] | 9c235f04 | 2011-08-10 22:28:21 | [diff] [blame] | 794 | net::LoadStateWithParam load_state_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 795 | string16 load_state_host_; |
| 796 | // Upload progress, for displaying in the status bar. |
| 797 | // Set to zero when there is no significant upload happening. |
| 798 | uint64 upload_size_; |
| 799 | uint64 upload_position_; |
| 800 | |
| 801 | // Data for current page ----------------------------------------------------- |
| 802 | |
[email protected] | 987fc3a | 2011-05-26 14:18:09 | [diff] [blame] | 803 | // When a title cannot be taken from any entry, this title will be used. |
| 804 | string16 page_title_when_no_navigation_entry_; |
| 805 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 806 | // When a navigation occurs, we record its contents MIME type. It can be |
| 807 | // used to check whether we can do something for some special contents. |
| 808 | std::string contents_mime_type_; |
| 809 | |
| 810 | // Character encoding. |
| 811 | std::string encoding_; |
| 812 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 813 | // True if this is a secure page which displayed insecure content. |
| 814 | bool displayed_insecure_content_; |
| 815 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 816 | // Data for misc internal state ---------------------------------------------- |
| 817 | |
| 818 | // See capturing_contents() above. |
| 819 | bool capturing_contents_; |
| 820 | |
| 821 | // See getter above. |
| 822 | bool is_being_destroyed_; |
| 823 | |
| 824 | // Indicates whether we should notify about disconnection of this |
| 825 | // TabContents. This is used to ensure disconnection notifications only |
| 826 | // happen if a connection notification has happened and that they happen only |
| 827 | // once. |
| 828 | bool notify_disconnection_; |
| 829 | |
[email protected] | 2e5b90c | 2011-08-16 21:11:55 | [diff] [blame] | 830 | // Pointer to the JavaScript dialog creator, lazily assigned. Used because the |
| 831 | // delegate of this TabContents is nulled before its destructor is called. |
| 832 | content::JavaScriptDialogCreator* dialog_creator_; |
| 833 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 834 | #if defined(OS_WIN) |
| 835 | // Handle to an event that's set when the page is showing a message box (or |
| 836 | // equivalent constrained window). Plugin processes check this to know if |
| 837 | // they should pump messages then. |
| 838 | base::win::ScopedHandle message_box_active_; |
| 839 | #endif |
| 840 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 841 | // Set to true when there is an active "before unload" dialog. When true, |
| 842 | // we've forced the throbber to start in Navigate, and we need to remember to |
| 843 | // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled. |
| 844 | bool is_showing_before_unload_dialog_; |
| 845 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 846 | // Settings that get passed to the renderer process. |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 847 | content::RendererPreferences renderer_preferences_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 848 | |
| 849 | // If this tab was created from a renderer using window.open, this will be |
| 850 | // non-NULL and represent the WebUI of the opening renderer. |
[email protected] | 1fd1a50 | 2011-03-30 16:55:56 | [diff] [blame] | 851 | WebUI::TypeID opener_web_ui_type_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 852 | |
| 853 | // The time that we started to create the new tab page. |
| 854 | base::TimeTicks new_tab_start_time_; |
| 855 | |
| 856 | // The time that we started to close the tab. |
| 857 | base::TimeTicks tab_close_start_time_; |
| 858 | |
| 859 | // The time that this tab was last selected. |
| 860 | base::TimeTicks last_selected_time_; |
| 861 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 862 | // See description above setter. |
| 863 | bool closed_by_user_gesture_; |
| 864 | |
| 865 | // Minimum/maximum zoom percent. |
| 866 | int minimum_zoom_percent_; |
| 867 | int maximum_zoom_percent_; |
| 868 | // If true, the default zoom limits have been overriden for this tab, in which |
| 869 | // case we don't want saved settings to apply to it and we don't want to |
| 870 | // remember it. |
| 871 | bool temporary_zoom_settings_; |
| 872 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 873 | // Content restrictions, used to disable print/copy etc based on content's |
| 874 | // (full-page plugins for now only) permissions. |
| 875 | int content_restrictions_; |
| 876 | |
[email protected] | 32ded221 | 2011-11-10 18:51:43 | [diff] [blame] | 877 | // Our view type. Default is VIEW_TYPE_TAB_CONTENTS. |
| 878 | content::ViewType view_type_; |
| 879 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 880 | DISALLOW_COPY_AND_ASSIGN(TabContents); |
| 881 | }; |
| 882 | |
| 883 | #endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ |