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