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