Home | History | Annotate | Download | only in tab_contents
      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 CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_
      6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_
      7 #pragma once
      8 
      9 #ifdef ANDROID
     10 #include "android/autofill/profile_android.h"
     11 #include "base/scoped_ptr.h"
     12 #include "chrome/browser/profiles/profile.h"
     13 #include "chrome/browser/autofill/autofill_host.h"
     14 
     15 // Autofill does not need the entire TabContents class, just
     16 // access to the RenderViewHost and Profile. Later it would
     17 // be nice to create a small class that contains just this
     18 // data for AutoFill. Then Android won't care about this
     19 // file which as it stands does not compile for us.
     20 class RenderViewHost;
     21 class URLRequestContextGetter;
     22 
     23 class TabContents {
     24 public:
     25   TabContents()
     26     : profile_(ProfileImplAndroid::CreateProfile(FilePath()))
     27     , autofill_host_(NULL)
     28   {
     29   }
     30 
     31   Profile* profile() { return profile_.get(); }
     32   void SetProfileRequestContext(URLRequestContextGetter* context) { static_cast<ProfileImplAndroid*>(profile_.get())->SetRequestContext(context); }
     33   AutoFillHost* autofill_host() { return autofill_host_; }
     34   void SetAutoFillHost(AutoFillHost* autofill_host) { autofill_host_ = autofill_host; }
     35 
     36 private:
     37   scoped_ptr<Profile> profile_;
     38   AutoFillHost* autofill_host_;
     39 };
     40 
     41 #else
     42 
     43 #include <deque>
     44 #include <map>
     45 #include <string>
     46 #include <vector>
     47 
     48 #include "base/basictypes.h"
     49 #include "base/gtest_prod_util.h"
     50 #include "base/scoped_ptr.h"
     51 #include "base/string16.h"
     52 #include "chrome/browser/dom_ui/web_ui_factory.h"
     53 #include "chrome/browser/download/save_package.h"
     54 #include "chrome/browser/extensions/image_loading_tracker.h"
     55 #include "chrome/browser/fav_icon_helper.h"
     56 #include "chrome/browser/prefs/pref_change_registrar.h"
     57 #include "chrome/browser/renderer_host/render_view_host_delegate.h"
     58 #include "chrome/browser/tab_contents/constrained_window.h"
     59 #include "chrome/browser/tab_contents/language_state.h"
     60 #include "chrome/browser/tab_contents/navigation_controller.h"
     61 #include "chrome/browser/tab_contents/navigation_entry.h"
     62 #include "chrome/browser/tab_contents/page_navigator.h"
     63 #include "chrome/browser/tab_contents/render_view_host_manager.h"
     64 #include "chrome/browser/tab_contents/tab_specific_content_settings.h"
     65 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h"
     66 #include "chrome/common/notification_registrar.h"
     67 #include "chrome/common/property_bag.h"
     68 #include "chrome/common/renderer_preferences.h"
     69 #include "chrome/common/translate_errors.h"
     70 #include "chrome/common/web_apps.h"
     71 #include "net/base/load_states.h"
     72 #include "ui/gfx/native_widget_types.h"
     73 
     74 #if defined(OS_WIN)
     75 #include "base/win/scoped_handle.h"
     76 #endif
     77 
     78 namespace gfx {
     79 class Rect;
     80 }
     81 
     82 namespace history {
     83 class HistoryAddPageArgs;
     84 }
     85 
     86 namespace printing {
     87 class PrintPreviewMessageHandler;
     88 class PrintViewManager;
     89 }
     90 
     91 class AutocompleteHistoryManager;
     92 class AutoFillManager;
     93 class BlockedContentContainer;
     94 class WebUI;
     95 class DesktopNotificationHandler;
     96 class DownloadItem;
     97 class Extension;
     98 class FileSelectHelper;
     99 class InfoBarDelegate;
    100 class LoadNotificationDetails;
    101 class OmniboxSearchHint;
    102 class PluginObserver;
    103 class Profile;
    104 class PrerenderManager;
    105 class PrerenderPLTRecorder;
    106 class RenderViewHost;
    107 class SessionStorageNamespace;
    108 class SiteInstance;
    109 class SkBitmap;
    110 class TabContents;
    111 class TabContentsDelegate;
    112 class TabContentsObserver;
    113 class TabContentsSSLHelper;
    114 class TabContentsView;
    115 class URLPattern;
    116 struct RendererPreferences;
    117 struct ThumbnailScore;
    118 struct ViewHostMsg_DomMessage_Params;
    119 struct ViewHostMsg_FrameNavigate_Params;
    120 struct ViewHostMsg_RunFileChooser_Params;
    121 struct WebPreferences;
    122 
    123 // Describes what goes in the main content area of a tab. TabContents is
    124 // the only type of TabContents, and these should be merged together.
    125 class TabContents : public PageNavigator,
    126                     public NotificationObserver,
    127                     public RenderViewHostDelegate,
    128                     public RenderViewHostManager::Delegate,
    129                     public JavaScriptAppModalDialogDelegate,
    130                     public ImageLoadingTracker::Observer,
    131                     public TabSpecificContentSettings::Delegate {
    132  public:
    133   // Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it
    134   // what has changed. Combine them to update more than one thing.
    135   enum InvalidateTypes {
    136     INVALIDATE_URL             = 1 << 0,  // The URL has changed.
    137     INVALIDATE_TAB             = 1 << 1,  // The favicon, app icon, or crashed
    138                                           // state changed.
    139     INVALIDATE_LOAD            = 1 << 2,  // The loading state has changed.
    140     INVALIDATE_PAGE_ACTIONS    = 1 << 3,  // Page action icons have changed.
    141     INVALIDATE_BOOKMARK_BAR    = 1 << 4,  // State of ShouldShowBookmarkBar
    142                                           // changed.
    143     INVALIDATE_TITLE           = 1 << 5,  // The title changed.
    144   };
    145 
    146   // |base_tab_contents| is used if we want to size the new tab contents view
    147   // based on an existing tab contents view.  This can be NULL if not needed.
    148   //
    149   // The session storage namespace parameter allows multiple render views and
    150   // tab contentses to share the same session storage (part of the WebStorage
    151   // spec) space. This is useful when restoring tabs, but most callers should
    152   // pass in NULL which will cause a new SessionStorageNamespace to be created.
    153   TabContents(Profile* profile,
    154               SiteInstance* site_instance,
    155               int routing_id,
    156               const TabContents* base_tab_contents,
    157               SessionStorageNamespace* session_storage_namespace);
    158   virtual ~TabContents();
    159 
    160   static void RegisterUserPrefs(PrefService* prefs);
    161 
    162   // Intrinsic tab state -------------------------------------------------------
    163 
    164   // Returns the property bag for this tab contents, where callers can add
    165   // extra data they may wish to associate with the tab. Returns a pointer
    166   // rather than a reference since the PropertyAccessors expect this.
    167   const PropertyBag* property_bag() const { return &property_bag_; }
    168   PropertyBag* property_bag() { return &property_bag_; }
    169 
    170   TabContentsDelegate* delegate() const { return delegate_; }
    171   void set_delegate(TabContentsDelegate* d) { delegate_ = d; }
    172 
    173   // Gets the controller for this tab contents.
    174   NavigationController& controller() { return controller_; }
    175   const NavigationController& controller() const { return controller_; }
    176 
    177   // Returns the user profile associated with this TabContents (via the
    178   // NavigationController).
    179   Profile* profile() const { return controller_.profile(); }
    180 
    181   // Returns true if contains content rendered by an extension.
    182   bool HostsExtension() const;
    183 
    184   // Returns the TabContentsSSLHelper, creating it if necessary.
    185   TabContentsSSLHelper* GetSSLHelper();
    186 
    187   // Returns the SavePackage which manages the page saving job. May be NULL.
    188   SavePackage* save_package() const { return save_package_.get(); }
    189 
    190   // Return the currently active RenderProcessHost and RenderViewHost. Each of
    191   // these may change over time.
    192   RenderProcessHost* GetRenderProcessHost() const;
    193   RenderViewHost* render_view_host() const {
    194     return render_manager_.current_host();
    195   }
    196 
    197   WebUI* web_ui() const {
    198     return render_manager_.web_ui() ? render_manager_.web_ui()
    199         : render_manager_.pending_web_ui();
    200   }
    201 
    202   // Returns the currently active RenderWidgetHostView. This may change over
    203   // time and can be NULL (during setup and teardown).
    204   RenderWidgetHostView* GetRenderWidgetHostView() const {
    205     return render_manager_.GetRenderWidgetHostView();
    206   }
    207 
    208   // The TabContentsView will never change and is guaranteed non-NULL.
    209   TabContentsView* view() const {
    210     return view_.get();
    211   }
    212 
    213   // Returns the FavIconHelper of this TabContents.
    214   FavIconHelper& fav_icon_helper() {
    215     return fav_icon_helper_;
    216   }
    217 
    218   // App extensions ------------------------------------------------------------
    219 
    220   // Sets the extension denoting this as an app. If |extension| is non-null this
    221   // tab becomes an app-tab. TabContents does not listen for unload events for
    222   // the extension. It's up to consumers of TabContents to do that.
    223   //
    224   // NOTE: this should only be manipulated before the tab is added to a browser.
    225   // TODO(sky): resolve if this is the right way to identify an app tab. If it
    226   // is, than this should be passed in the constructor.
    227   void SetExtensionApp(const Extension* extension);
    228 
    229   // Convenience for setting the app extension by id. This does nothing if
    230   // |extension_app_id| is empty, or an extension can't be found given the
    231   // specified id.
    232   void SetExtensionAppById(const std::string& extension_app_id);
    233 
    234   const Extension* extension_app() const { return extension_app_; }
    235   bool is_app() const { return extension_app_ != NULL; }
    236 
    237   // If an app extension has been explicitly set for this TabContents its icon
    238   // is returned.
    239   //
    240   // NOTE: the returned icon is larger than 16x16 (its size is
    241   // Extension::EXTENSION_ICON_SMALLISH).
    242   SkBitmap* GetExtensionAppIcon();
    243 
    244   // Tab navigation state ------------------------------------------------------
    245 
    246   // Returns the current navigation properties, which if a navigation is
    247   // pending may be provisional (e.g., the navigation could result in a
    248   // download, in which case the URL would revert to what it was previously).
    249   virtual const GURL& GetURL() const;
    250   virtual const string16& GetTitle() const;
    251 
    252   // Initial title assigned to NavigationEntries from Navigate.
    253   static string16 GetDefaultTitle();
    254 
    255   // The max PageID of any page that this TabContents has loaded.  PageIDs
    256   // increase with each new page that is loaded by a tab.  If this is a
    257   // TabContents, then the max PageID is kept separately on each SiteInstance.
    258   // Returns -1 if no PageIDs have yet been seen.
    259   int32 GetMaxPageID();
    260 
    261   // Updates the max PageID to be at least the given PageID.
    262   void UpdateMaxPageID(int32 page_id);
    263 
    264   // Returns the site instance associated with the current page. By default,
    265   // there is no site instance. TabContents overrides this to provide proper
    266   // access to its site instance.
    267   virtual SiteInstance* GetSiteInstance() const;
    268 
    269   // Defines whether this tab's URL should be displayed in the browser's URL
    270   // bar. Normally this is true so you can see the URL. This is set to false
    271   // for the new tab page and related pages so that the URL bar is empty and
    272   // the user is invited to type into it.
    273   virtual bool ShouldDisplayURL();
    274 
    275   // Returns the favicon for this tab, or an isNull() bitmap if the tab does not
    276   // have a favicon. The default implementation uses the current navigation
    277   // entry.
    278   SkBitmap GetFavIcon() const;
    279 
    280   // Returns true if we are not using the default favicon.
    281   bool FavIconIsValid() const;
    282 
    283   // Returns whether the favicon should be displayed. If this returns false, no
    284   // space is provided for the favicon, and the favicon is never displayed.
    285   virtual bool ShouldDisplayFavIcon();
    286 
    287   // Returns a human-readable description the tab's loading state.
    288   virtual string16 GetStatusText() const;
    289 
    290   // Add and remove observers for page navigation notifications. Adding or
    291   // removing multiple times has no effect. The order in which notifications
    292   // are sent to observers is undefined. Clients must be sure to remove the
    293   // observer before they go away.
    294   void AddObserver(TabContentsObserver* observer);
    295   void RemoveObserver(TabContentsObserver* observer);
    296 
    297   // Return whether this tab contents is loading a resource.
    298   bool is_loading() const { return is_loading_; }
    299 
    300   // Returns whether this tab contents is waiting for a first-response for the
    301   // main resource of the page. This controls whether the throbber state is
    302   // "waiting" or "loading."
    303   bool waiting_for_response() const { return waiting_for_response_; }
    304 
    305   const std::string& encoding() const { return encoding_; }
    306   void set_encoding(const std::string& encoding);
    307   void reset_encoding() {
    308     encoding_.clear();
    309   }
    310 
    311   const WebApplicationInfo& web_app_info() const {
    312     return web_app_info_;
    313   }
    314 
    315   const SkBitmap& app_icon() const { return app_icon_; }
    316 
    317   // Sets an app icon associated with TabContents and fires an INVALIDATE_TITLE
    318   // navigation state change to trigger repaint of title.
    319   void SetAppIcon(const SkBitmap& app_icon);
    320 
    321   bool displayed_insecure_content() const {
    322     return displayed_insecure_content_;
    323   }
    324 
    325   // Internal state ------------------------------------------------------------
    326 
    327   // This flag indicates whether the tab contents is currently being
    328   // screenshotted by the DraggedTabController.
    329   bool capturing_contents() const { return capturing_contents_; }
    330   void set_capturing_contents(bool cap) { capturing_contents_ = cap; }
    331 
    332   // Indicates whether this tab should be considered crashed. The setter will
    333   // also notify the delegate when the flag is changed.
    334   bool is_crashed() const {
    335     return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED ||
    336             crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
    337             crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
    338   }
    339   base::TerminationStatus crashed_status() const { return crashed_status_; }
    340   int crashed_error_code() const { return crashed_error_code_; }
    341   void SetIsCrashed(base::TerminationStatus status, int error_code);
    342 
    343   // Call this after updating a page action to notify clients about the changes.
    344   void PageActionStateChanged();
    345 
    346   // Whether the tab is in the process of being destroyed.
    347   // Added as a tentative work-around for focus related bug #4633.  This allows
    348   // us not to store focus when a tab is being closed.
    349   bool is_being_destroyed() const { return is_being_destroyed_; }
    350 
    351   // Convenience method for notifying the delegate of a navigation state
    352   // change. See TabContentsDelegate.
    353   void NotifyNavigationStateChanged(unsigned changed_flags);
    354 
    355   // Invoked when the tab contents becomes selected. If you override, be sure
    356   // and invoke super's implementation.
    357   virtual void DidBecomeSelected();
    358   base::TimeTicks last_selected_time() const {
    359     return last_selected_time_;
    360   }
    361 
    362   // Invoked when the tab contents becomes hidden.
    363   // NOTE: If you override this, call the superclass version too!
    364   virtual void WasHidden();
    365 
    366   // Activates this contents within its containing window, bringing that window
    367   // to the foreground if necessary.
    368   void Activate();
    369 
    370   // Deactivates this contents by deactivating its containing window.
    371   void Deactivate();
    372 
    373   // TODO(brettw) document these.
    374   virtual void ShowContents();
    375   virtual void HideContents();
    376 
    377   // Returns true if the before unload and unload listeners need to be
    378   // fired. The value of this changes over time. For example, if true and the
    379   // before unload listener is executed and allows the user to exit, then this
    380   // returns false.
    381   bool NeedToFireBeforeUnload();
    382 
    383 #ifdef UNIT_TEST
    384   // Expose the render manager for testing.
    385   RenderViewHostManager* render_manager() { return &render_manager_; }
    386 #endif
    387 
    388   // In the underlying RenderViewHostManager, swaps in the provided
    389   // RenderViewHost to replace the current RenderViewHost.  The current RVH
    390   // will be shutdown and ultimately deleted.
    391   void SwapInRenderViewHost(RenderViewHost* rvh);
    392 
    393   // Commands ------------------------------------------------------------------
    394 
    395   // Implementation of PageNavigator.
    396   virtual void OpenURL(const GURL& url, const GURL& referrer,
    397                        WindowOpenDisposition disposition,
    398                        PageTransition::Type transition);
    399 
    400   // Called by the NavigationController to cause the TabContents to navigate to
    401   // the current pending entry. The NavigationController should be called back
    402   // with CommitPendingEntry/RendererDidNavigate on success or
    403   // DiscardPendingEntry. The callbacks can be inside of this function, or at
    404   // some future time.
    405   //
    406   // The entry has a PageID of -1 if newly created (corresponding to navigation
    407   // to a new URL).
    408   //
    409   // If this method returns false, then the navigation is discarded (equivalent
    410   // to calling DiscardPendingEntry on the NavigationController).
    411   virtual bool NavigateToPendingEntry(
    412       NavigationController::ReloadType reload_type);
    413 
    414   // Stop any pending navigation.
    415   virtual void Stop();
    416 
    417   // Called on a TabContents when it isn't a popup, but a new window.
    418   virtual void DisassociateFromPopupCount();
    419 
    420   // Creates a new TabContents with the same state as this one. The returned
    421   // heap-allocated pointer is owned by the caller.
    422   virtual TabContents* Clone();
    423 
    424   // Shows the page info.
    425   void ShowPageInfo(const GURL& url,
    426                     const NavigationEntry::SSLStatus& ssl,
    427                     bool show_history);
    428 
    429   // Saves the favicon for the current page.
    430   void SaveFavicon();
    431 
    432   // Window management ---------------------------------------------------------
    433 
    434   // Create a new window constrained to this TabContents' clip and visibility.
    435   // The window is initialized by using the supplied delegate to obtain basic
    436   // window characteristics, and the supplied view for the content. Note that
    437   // the returned ConstrainedWindow might not yet be visible.
    438   ConstrainedWindow* CreateConstrainedDialog(
    439       ConstrainedWindowDelegate* delegate);
    440 
    441   // Adds a new tab or window with the given already-created contents
    442   void AddNewContents(TabContents* new_contents,
    443                       WindowOpenDisposition disposition,
    444                       const gfx::Rect& initial_pos,
    445                       bool user_gesture);
    446 
    447   // Execute code in this tab. Returns true if the message was successfully
    448   // sent.
    449   bool ExecuteCode(int request_id, const std::string& extension_id,
    450                    bool is_js_code, const std::string& code_string,
    451                    bool all_frames);
    452 
    453   // Called when the blocked popup notification is shown or hidden.
    454   virtual void PopupNotificationVisibilityChanged(bool visible);
    455 
    456   // Returns the number of constrained windows in this tab.  Used by tests.
    457   size_t constrained_window_count() { return child_windows_.size(); }
    458 
    459   typedef std::deque<ConstrainedWindow*> ConstrainedWindowList;
    460 
    461   // Return an iterator for the first constrained window in this tab contents.
    462   ConstrainedWindowList::iterator constrained_window_begin()
    463   { return child_windows_.begin(); }
    464 
    465   // Return an iterator for the last constrained window in this tab contents.
    466   ConstrainedWindowList::iterator constrained_window_end()
    467   { return child_windows_.end(); }
    468 
    469   // Views and focus -----------------------------------------------------------
    470   // TODO(brettw): Most of these should be removed and the caller should call
    471   // the view directly.
    472 
    473   // Returns the actual window that is focused when this TabContents is shown.
    474   gfx::NativeView GetContentNativeView() const;
    475 
    476   // Returns the NativeView associated with this TabContents. Outside of
    477   // automation in the context of the UI, this is required to be implemented.
    478   gfx::NativeView GetNativeView() const;
    479 
    480   // Returns the bounds of this TabContents in the screen coordinate system.
    481   void GetContainerBounds(gfx::Rect *out) const;
    482 
    483   // Makes the tab the focused window.
    484   void Focus();
    485 
    486   // Focuses the first (last if |reverse| is true) element in the page.
    487   // Invoked when this tab is getting the focus through tab traversal (|reverse|
    488   // is true when using Shift-Tab).
    489   void FocusThroughTabTraversal(bool reverse);
    490 
    491   // These next two functions are declared on RenderViewHostManager::Delegate
    492   // but also accessed directly by other callers.
    493 
    494   // Returns true if the location bar should be focused by default rather than
    495   // the page contents. The view calls this function when the tab is focused
    496   // to see what it should do.
    497   virtual bool FocusLocationBarByDefault();
    498 
    499   // Focuses the location bar.
    500   virtual void SetFocusToLocationBar(bool select_all);
    501 
    502   // Creates a view and sets the size for the specified RVH.
    503   virtual void CreateViewAndSetSizeForRVH(RenderViewHost* rvh);
    504 
    505   // Infobars ------------------------------------------------------------------
    506 
    507   // Adds an InfoBar for the specified |delegate|.
    508   virtual void AddInfoBar(InfoBarDelegate* delegate);
    509 
    510   // Removes the InfoBar for the specified |delegate|.
    511   void RemoveInfoBar(InfoBarDelegate* delegate);
    512 
    513   // Replaces one infobar with another, without any animation in between.
    514   void ReplaceInfoBar(InfoBarDelegate* old_delegate,
    515                       InfoBarDelegate* new_delegate);
    516 
    517   // Enumeration and access functions.
    518   size_t infobar_count() const { return infobar_delegates_.size(); }
    519   // WARNING: This does not sanity-check |index|!
    520   InfoBarDelegate* GetInfoBarDelegateAt(size_t index) {
    521     return infobar_delegates_[index];
    522   }
    523 
    524   // Toolbars and such ---------------------------------------------------------
    525 
    526   // Returns true if a Bookmark Bar should be shown for this tab.
    527   virtual bool ShouldShowBookmarkBar();
    528 
    529   // Notifies the delegate that a download is about to be started.
    530   // This notification is fired before a local temporary file has been created.
    531   bool CanDownload(int request_id);
    532 
    533   // Notifies the delegate that a download started.
    534   void OnStartDownload(DownloadItem* download);
    535 
    536   // Notify our delegate that some of our content has animated.
    537   void ToolbarSizeChanged(bool is_animating);
    538 
    539   // Called when a ConstrainedWindow we own is about to be closed.
    540   void WillClose(ConstrainedWindow* window);
    541 
    542   // Called when a BlockedContentContainer we own is about to be closed.
    543   void WillCloseBlockedContentContainer(BlockedContentContainer* container);
    544 
    545   // Called when a ConstrainedWindow we own is moved or resized.
    546   void DidMoveOrResize(ConstrainedWindow* window);
    547 
    548   // Interstitials -------------------------------------------------------------
    549 
    550   // Various other systems need to know about our interstitials.
    551   bool showing_interstitial_page() const {
    552     return render_manager_.interstitial_page() != NULL;
    553   }
    554 
    555   // Sets the passed passed interstitial as the currently showing interstitial.
    556   // |interstitial_page| should be non NULL (use the remove_interstitial_page
    557   // method to unset the interstitial) and no interstitial page should be set
    558   // when there is already a non NULL interstitial page set.
    559   void set_interstitial_page(InterstitialPage* interstitial_page) {
    560     render_manager_.set_interstitial_page(interstitial_page);
    561   }
    562 
    563   // Unsets the currently showing interstitial.
    564   void remove_interstitial_page() {
    565     render_manager_.remove_interstitial_page();
    566   }
    567 
    568   // Returns the currently showing interstitial, NULL if no interstitial is
    569   // showing.
    570   InterstitialPage* interstitial_page() const {
    571     return render_manager_.interstitial_page();
    572   }
    573 
    574   // Misc state & callbacks ----------------------------------------------------
    575 
    576   // Set whether the contents should block javascript message boxes or not.
    577   // Default is not to block any message boxes.
    578   void set_suppress_javascript_messages(bool suppress_javascript_messages) {
    579     suppress_javascript_messages_ = suppress_javascript_messages;
    580   }
    581 
    582   // Prepare for saving the current web page to disk.
    583   void OnSavePage();
    584 
    585   // Save page with the main HTML file path, the directory for saving resources,
    586   // and the save type: HTML only or complete web page. Returns true if the
    587   // saving process has been initiated successfully.
    588   bool SavePage(const FilePath& main_file, const FilePath& dir_path,
    589                 SavePackage::SavePackageType save_type);
    590 
    591   // Sets save_package_, taking care to register and unregister the observers.
    592   void SetSavePackage(SavePackage* save_package);
    593 
    594   // Tells the user's email client to open a compose window containing the
    595   // current page's URL.
    596   void EmailPageLocation();
    597 
    598   // Displays asynchronously a print preview (generated by the renderer) if not
    599   // already displayed and ask the user for its preferred print settings with
    600   // the "Print..." dialog box. (managed by the print worker thread).
    601   // TODO(maruel):  Creates a snapshot of the renderer to be used for the new
    602   // tab for the printing facility.
    603   void PrintPreview();
    604 
    605   // Prints the current document immediately. Since the rendering is
    606   // asynchronous, the actual printing will not be completed on the return of
    607   // this function. Returns false if printing is impossible at the moment.
    608   bool PrintNow();
    609 
    610   // Notify the completion of a printing job.
    611   void PrintingDone(int document_cookie, bool success);
    612 
    613   // Returns true if the active NavigationEntry's page_id equals page_id.
    614   bool IsActiveEntry(int32 page_id);
    615 
    616   const std::string& contents_mime_type() const {
    617     return contents_mime_type_;
    618   }
    619 
    620   // Returns true if this TabContents will notify about disconnection.
    621   bool notify_disconnection() const { return notify_disconnection_; }
    622 
    623   // Override the encoding and reload the page by sending down
    624   // ViewMsg_SetPageEncoding to the renderer. |UpdateEncoding| is kinda
    625   // the opposite of this, by which 'browser' is notified of
    626   // the encoding of the current tab from 'renderer' (determined by
    627   // auto-detect, http header, meta, bom detection, etc).
    628   void SetOverrideEncoding(const std::string& encoding);
    629 
    630   // Remove any user-defined override encoding and reload by sending down
    631   // ViewMsg_ResetPageEncodingToDefault to the renderer.
    632   void ResetOverrideEncoding();
    633 
    634   void WindowMoveOrResizeStarted();
    635 
    636   // Sets whether all TabContents added by way of |AddNewContents| should be
    637   // blocked. Transitioning from all blocked to not all blocked results in
    638   // reevaluating any blocked TabContents, which may result in unblocking some
    639   // of the blocked TabContents.
    640   void SetAllContentsBlocked(bool value);
    641 
    642   BlockedContentContainer* blocked_content_container() const {
    643     return blocked_contents_;
    644   }
    645 
    646   RendererPreferences* GetMutableRendererPrefs() {
    647     return &renderer_preferences_;
    648   }
    649 
    650   void set_opener_web_ui_type(WebUITypeID opener_web_ui_type) {
    651     opener_web_ui_type_ = opener_web_ui_type;
    652   }
    653 
    654   // We want to time how long it takes to create a new tab page.  This method
    655   // gets called as parts of the new tab page have loaded.
    656   void LogNewTabTime(const std::string& event_name);
    657 
    658   // Set the time when we started to create the new tab page.  This time is
    659   // from before we created this TabContents.
    660   void set_new_tab_start_time(const base::TimeTicks& time) {
    661     new_tab_start_time_ = time;
    662   }
    663 
    664   // Notification that tab closing has started.  This can be called multiple
    665   // times, subsequent calls are ignored.
    666   void OnCloseStarted();
    667 
    668   LanguageState& language_state() {
    669     return language_state_;
    670   }
    671 
    672   // Returns true if underlying TabContentsView should accept drag-n-drop.
    673   bool ShouldAcceptDragAndDrop() const;
    674 
    675   // A render view-originated drag has ended. Informs the render view host and
    676   // tab contents delegate.
    677   void SystemDragEnded();
    678 
    679   // Indicates if this tab was explicitly closed by the user (control-w, close
    680   // tab menu item...). This is false for actions that indirectly close the tab,
    681   // such as closing the window.  The setter is maintained by TabStripModel, and
    682   // the getter only useful from within TAB_CLOSED notification
    683   void set_closed_by_user_gesture(bool value) {
    684     closed_by_user_gesture_ = value;
    685   }
    686   bool closed_by_user_gesture() const { return closed_by_user_gesture_; }
    687 
    688   // Overridden from JavaScriptAppModalDialogDelegate:
    689   virtual void OnMessageBoxClosed(IPC::Message* reply_msg,
    690                                   bool success,
    691                                   const std::wstring& prompt);
    692   virtual void SetSuppressMessageBoxes(bool suppress_message_boxes);
    693   virtual gfx::NativeWindow GetMessageBoxRootWindow();
    694   virtual TabContents* AsTabContents();
    695   virtual ExtensionHost* AsExtensionHost();
    696 
    697   // The BookmarkDragDelegate is used to forward bookmark drag and drop events
    698   // to extensions.
    699   virtual RenderViewHostDelegate::BookmarkDrag* GetBookmarkDragDelegate();
    700 
    701   // It is up to callers to call SetBookmarkDragDelegate(NULL) when
    702   // |bookmark_drag| is deleted since this class does not take ownership of
    703   // |bookmark_drag|.
    704   virtual void SetBookmarkDragDelegate(
    705       RenderViewHostDelegate::BookmarkDrag* bookmark_drag);
    706 
    707   // The TabSpecificContentSettings object is used to query the blocked content
    708   // state by various UI elements.
    709   TabSpecificContentSettings* GetTabSpecificContentSettings() const;
    710 
    711   // Updates history with the specified navigation. This is called by
    712   // OnMsgNavigate to update history state.
    713   void UpdateHistoryForNavigation(
    714       scoped_refptr<history::HistoryAddPageArgs> add_page_args);
    715 
    716   // Sends the page title to the history service. This is called when we receive
    717   // the page title and we know we want to update history.
    718   void UpdateHistoryPageTitle(const NavigationEntry& entry);
    719 
    720   // Gets the zoom level for this tab.
    721   double GetZoomLevel() const;
    722 
    723   // Gets the zoom percent for this tab.
    724   int GetZoomPercent(bool* enable_increment, bool* enable_decrement);
    725 
    726   // Shows a fade effect over this tab contents. Repeated calls will be ignored
    727   // until the fade is canceled. If |animate| is true the fade should animate.
    728   void FadeForInstant(bool animate);
    729 
    730   // Immediately removes the fade.
    731   void CancelInstantFade();
    732 
    733   // Opens view-source tab for this contents.
    734   void ViewSource();
    735 
    736   // Gets the minimum/maximum zoom percent.
    737   int minimum_zoom_percent() const { return minimum_zoom_percent_; }
    738   int maximum_zoom_percent() const { return maximum_zoom_percent_; }
    739 
    740   int content_restrictions() const { return content_restrictions_; }
    741 
    742   AutocompleteHistoryManager* autocomplete_history_manager() {
    743     return autocomplete_history_manager_.get();
    744   }
    745   AutoFillManager* autofill_manager() { return autofill_manager_.get(); }
    746 
    747  protected:
    748   // from RenderViewHostDelegate.
    749   virtual bool OnMessageReceived(const IPC::Message& message);
    750 
    751  private:
    752   friend class NavigationController;
    753   // Used to access the child_windows_ (ConstrainedWindowList) for testing
    754   // automation purposes.
    755   friend class TestingAutomationProvider;
    756 
    757   FRIEND_TEST_ALL_PREFIXES(TabContentsTest, NoJSMessageOnInterstitials);
    758   FRIEND_TEST_ALL_PREFIXES(TabContentsTest, UpdateTitle);
    759   FRIEND_TEST_ALL_PREFIXES(TabContentsTest, CrossSiteCantPreemptAfterUnload);
    760   FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
    761   FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
    762   FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
    763 
    764   // Temporary until the view/contents separation is complete.
    765   friend class TabContentsView;
    766 #if defined(OS_WIN)
    767   friend class TabContentsViewWin;
    768 #elif defined(OS_MACOSX)
    769   friend class TabContentsViewMac;
    770 #elif defined(TOOLKIT_USES_GTK)
    771   friend class TabContentsViewGtk;
    772 #endif
    773 
    774   // So InterstitialPage can access SetIsLoading.
    775   friend class InterstitialPage;
    776 
    777   // TODO(brettw) TestTabContents shouldn't exist!
    778   friend class TestTabContents;
    779 
    780   // Used to access the CreateHistoryAddPageArgs member function.
    781   friend class ExternalTabContainer;
    782 
    783   // Used to access RVH Delegates.
    784   friend class PrerenderManager;
    785 
    786   // Message handlers.
    787   void OnDidStartProvisionalLoadForFrame(int64 frame_id,
    788                                          bool main_frame,
    789                                          const GURL& url);
    790   void OnDidRedirectProvisionalLoad(int32 page_id,
    791                                     const GURL& source_url,
    792                                     const GURL& target_url);
    793   void OnDidFailProvisionalLoadWithError(int64 frame_id,
    794                                          bool main_frame,
    795                                          int error_code,
    796                                          const GURL& url,
    797                                          bool showing_repost_interstitial);
    798   void OnDidLoadResourceFromMemoryCache(const GURL& url,
    799                                         const std::string& frame_origin,
    800                                         const std::string& main_frame_origin,
    801                                         const std::string& security_info);
    802   void OnDidDisplayInsecureContent();
    803   void OnDidRunInsecureContent(const std::string& security_origin,
    804                                const GURL& target_url);
    805   void OnDocumentLoadedInFrame(int64 frame_id);
    806   void OnDidFinishLoad(int64 frame_id);
    807   void OnUpdateContentRestrictions(int restrictions);
    808   void OnPDFHasUnsupportedFeature();
    809 
    810   void OnGoToEntryAtOffset(int offset);
    811   void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info);
    812   void OnInstallApplication(const WebApplicationInfo& info);
    813   void OnPageContents(const GURL& url,
    814                       int32 page_id,
    815                       const string16& contents,
    816                       const std::string& language,
    817                       bool page_translatable);
    818   void OnPageTranslated(int32 page_id,
    819                         const std::string& original_lang,
    820                         const std::string& translated_lang,
    821                         TranslateErrors::Type error_type);
    822   void OnSetSuggestions(int32 page_id,
    823                         const std::vector<std::string>& suggestions);
    824   void OnInstantSupportDetermined(int32 page_id, bool result);
    825   void OnRunFileChooser(const ViewHostMsg_RunFileChooser_Params& params);
    826 
    827   // Changes the IsLoading state and notifies delegate as needed
    828   // |details| is used to provide details on the load that just finished
    829   // (but can be null if not applicable). Can be overridden.
    830   void SetIsLoading(bool is_loading,
    831                     LoadNotificationDetails* details);
    832 
    833   // Adds the incoming |new_contents| to the |blocked_contents_| container.
    834   void AddPopup(TabContents* new_contents,
    835                 const gfx::Rect& initial_pos);
    836 
    837   // Called by derived classes to indicate that we're no longer waiting for a
    838   // response. This won't actually update the throbber, but it will get picked
    839   // up at the next animation step if the throbber is going.
    840   void SetNotWaitingForResponse() { waiting_for_response_ = false; }
    841 
    842   ConstrainedWindowList child_windows_;
    843 
    844   // Expires InfoBars that need to be expired, according to the state carried
    845   // in |details|, in response to a new NavigationEntry being committed (the
    846   // user navigated to another page).
    847   void ExpireInfoBars(
    848       const NavigationController::LoadCommittedDetails& details);
    849 
    850   // Returns the WebUI for the current state of the tab. This will either be
    851   // the pending WebUI, the committed WebUI, or NULL.
    852   WebUI* GetWebUIForCurrentState();
    853 
    854   // Navigation helpers --------------------------------------------------------
    855   //
    856   // These functions are helpers for Navigate() and DidNavigate().
    857 
    858   // Handles post-navigation tasks in DidNavigate AFTER the entry has been
    859   // committed to the navigation controller. Note that the navigation entry is
    860   // not provided since it may be invalid/changed after being committed. The
    861   // current navigation entry is in the NavigationController at this point.
    862   void DidNavigateMainFramePostCommit(
    863       const NavigationController::LoadCommittedDetails& details,
    864       const ViewHostMsg_FrameNavigate_Params& params);
    865   void DidNavigateAnyFramePostCommit(
    866       RenderViewHost* render_view_host,
    867       const NavigationController::LoadCommittedDetails& details,
    868       const ViewHostMsg_FrameNavigate_Params& params);
    869 
    870   // Closes all constrained windows.
    871   void CloseConstrainedWindows();
    872 
    873   // Send the alternate error page URL to the renderer. This method is virtual
    874   // so special html pages can override this (e.g., the new tab page).
    875   virtual void UpdateAlternateErrorPageURL();
    876 
    877   // Send webkit specific settings to the renderer.
    878   void UpdateWebPreferences();
    879 
    880   // Instruct the renderer to update the zoom level.
    881   void UpdateZoomLevel();
    882 
    883   // If our controller was restored and the page id is > than the site
    884   // instance's page id, the site instances page id is updated as well as the
    885   // renderers max page id.
    886   void UpdateMaxPageIDIfNecessary(SiteInstance* site_instance,
    887                                   RenderViewHost* rvh);
    888 
    889   // Returns the history::HistoryAddPageArgs to use for adding a page to
    890   // history.
    891   scoped_refptr<history::HistoryAddPageArgs> CreateHistoryAddPageArgs(
    892       const GURL& virtual_url,
    893       const NavigationController::LoadCommittedDetails& details,
    894       const ViewHostMsg_FrameNavigate_Params& params);
    895 
    896   // Saves the given title to the navigation entry and does associated work. It
    897   // will update history and the view for the new title, and also synthesize
    898   // titles for file URLs that have none (so we require that the URL of the
    899   // entry already be set).
    900   //
    901   // This is used as the backend for state updates, which include a new title,
    902   // or the dedicated set title message. It returns true if the new title is
    903   // different and was therefore updated.
    904   bool UpdateTitleForEntry(NavigationEntry* entry, const std::wstring& title);
    905 
    906   // Causes the TabContents to navigate in the right renderer to |entry|, which
    907   // must be already part of the entries in the navigation controller.
    908   // This does not change the NavigationController state.
    909   bool NavigateToEntry(const NavigationEntry& entry,
    910                        NavigationController::ReloadType reload_type);
    911 
    912   // Misc non-view stuff -------------------------------------------------------
    913 
    914   // Helper functions for sending notifications.
    915   void NotifySwapped();
    916   void NotifyConnected();
    917   void NotifyDisconnected();
    918 
    919   // If params has a searchable form, this tries to create a new keyword.
    920   void GenerateKeywordIfNecessary(
    921       const ViewHostMsg_FrameNavigate_Params& params);
    922 
    923   // TabSpecificContentSettings::Delegate implementation.
    924   virtual void OnContentSettingsAccessed(bool content_was_blocked);
    925 
    926   // RenderViewHostDelegate ----------------------------------------------------
    927 
    928   // RenderViewHostDelegate implementation.
    929   virtual RenderViewHostDelegate::View* GetViewDelegate();
    930   virtual RenderViewHostDelegate::RendererManagement*
    931       GetRendererManagementDelegate();
    932   virtual RenderViewHostDelegate::ContentSettings* GetContentSettingsDelegate();
    933   virtual RenderViewHostDelegate::SSL* GetSSLDelegate();
    934   virtual AutomationResourceRoutingDelegate*
    935       GetAutomationResourceRoutingDelegate();
    936   virtual TabContents* GetAsTabContents();
    937   virtual ViewType::Type GetRenderViewType() const;
    938   virtual int GetBrowserWindowID() const;
    939   virtual void RenderViewCreated(RenderViewHost* render_view_host);
    940   virtual void RenderViewReady(RenderViewHost* render_view_host);
    941   virtual void RenderViewGone(RenderViewHost* render_view_host,
    942                               base::TerminationStatus status,
    943                               int error_code);
    944   virtual void RenderViewDeleted(RenderViewHost* render_view_host);
    945   virtual void DidNavigate(RenderViewHost* render_view_host,
    946                            const ViewHostMsg_FrameNavigate_Params& params);
    947   virtual void UpdateState(RenderViewHost* render_view_host,
    948                            int32 page_id,
    949                            const std::string& state);
    950   virtual void UpdateTitle(RenderViewHost* render_view_host,
    951                            int32 page_id,
    952                            const std::wstring& title);
    953   virtual void UpdateEncoding(RenderViewHost* render_view_host,
    954                               const std::string& encoding);
    955   virtual void UpdateTargetURL(int32 page_id, const GURL& url);
    956   virtual void UpdateThumbnail(const GURL& url,
    957                                const SkBitmap& bitmap,
    958                                const ThumbnailScore& score);
    959   virtual void UpdateInspectorSetting(const std::string& key,
    960                                       const std::string& value);
    961   virtual void ClearInspectorSettings();
    962   virtual void Close(RenderViewHost* render_view_host);
    963   virtual void RequestMove(const gfx::Rect& new_bounds);
    964   virtual void DidStartLoading();
    965   virtual void DidStopLoading();
    966   virtual void DidChangeLoadProgress(double progress);
    967   virtual void DocumentOnLoadCompletedInMainFrame(
    968       RenderViewHost* render_view_host,
    969       int32 page_id);
    970   virtual void RequestOpenURL(const GURL& url, const GURL& referrer,
    971                               WindowOpenDisposition disposition);
    972   virtual void DomOperationResponse(const std::string& json_string,
    973                                     int automation_id);
    974   virtual void ProcessWebUIMessage(const ViewHostMsg_DomMessage_Params& params);
    975   virtual void ProcessExternalHostMessage(const std::string& message,
    976                                           const std::string& origin,
    977                                           const std::string& target);
    978   virtual void RunJavaScriptMessage(const std::wstring& message,
    979                                     const std::wstring& default_prompt,
    980                                     const GURL& frame_url,
    981                                     const int flags,
    982                                     IPC::Message* reply_msg,
    983                                     bool* did_suppress_message);
    984   virtual void RunBeforeUnloadConfirm(const std::wstring& message,
    985                                       IPC::Message* reply_msg);
    986   virtual void ShowModalHTMLDialog(const GURL& url, int width, int height,
    987                                    const std::string& json_arguments,
    988                                    IPC::Message* reply_msg);
    989   virtual void PageHasOSDD(RenderViewHost* render_view_host,
    990                            int32 page_id,
    991                            const GURL& url,
    992                            const ViewHostMsg_PageHasOSDD_Type& provider_type);
    993   virtual GURL GetAlternateErrorPageURL() const;
    994   virtual RendererPreferences GetRendererPrefs(Profile* profile) const;
    995   virtual WebPreferences GetWebkitPrefs();
    996   virtual void OnUserGesture();
    997   virtual void OnIgnoredUIEvent();
    998   virtual void OnJSOutOfMemory();
    999   virtual void OnCrossSiteResponse(int new_render_process_host_id,
   1000                                    int new_request_id);
   1001   virtual void RendererUnresponsive(RenderViewHost* render_view_host,
   1002                                     bool is_during_unload);
   1003   virtual void RendererResponsive(RenderViewHost* render_view_host);
   1004   virtual void LoadStateChanged(const GURL& url, net::LoadState load_state,
   1005                                 uint64 upload_position, uint64 upload_size);
   1006   virtual bool IsExternalTabContainer() const;
   1007   virtual void DidInsertCSS();
   1008   virtual void FocusedNodeChanged(bool is_editable_node);
   1009   virtual void UpdateZoomLimits(int minimum_percent,
   1010                                 int maximum_percent,
   1011                                 bool remember);
   1012   virtual void WorkerCrashed();
   1013 
   1014   // RenderViewHostManager::Delegate -------------------------------------------
   1015 
   1016   // Blocks/unblocks interaction with renderer process.
   1017   void BlockTabContent(bool blocked);
   1018 
   1019   virtual void BeforeUnloadFiredFromRenderManager(
   1020       bool proceed,
   1021       bool* proceed_to_fire_unload);
   1022   virtual void DidStartLoadingFromRenderManager(
   1023       RenderViewHost* render_view_host);
   1024   virtual void RenderViewGoneFromRenderManager(
   1025       RenderViewHost* render_view_host);
   1026   virtual void UpdateRenderViewSizeForRenderManager();
   1027   virtual void NotifySwappedFromRenderManager();
   1028   virtual NavigationController& GetControllerForRenderManager();
   1029   virtual WebUI* CreateWebUIForRenderManager(const GURL& url);
   1030   virtual NavigationEntry* GetLastCommittedNavigationEntryForRenderManager();
   1031 
   1032   // Initializes the given renderer if necessary and creates the view ID
   1033   // corresponding to this view host. If this method is not called and the
   1034   // process is not shared, then the TabContents will act as though the renderer
   1035   // is not running (i.e., it will render "sad tab"). This method is
   1036   // automatically called from LoadURL.
   1037   //
   1038   // If you are attaching to an already-existing RenderView, you should call
   1039   // InitWithExistingID.
   1040   virtual bool CreateRenderViewForRenderManager(
   1041       RenderViewHost* render_view_host);
   1042 
   1043   // NotificationObserver ------------------------------------------------------
   1044 
   1045   virtual void Observe(NotificationType type,
   1046                        const NotificationSource& source,
   1047                        const NotificationDetails& details);
   1048 
   1049   // App extensions related methods:
   1050 
   1051   // Returns the first extension whose extent contains |url|.
   1052   const Extension* GetExtensionContaining(const GURL& url);
   1053 
   1054   // Resets app_icon_ and if |extension| is non-null creates a new
   1055   // ImageLoadingTracker to load the extension's image.
   1056   void UpdateExtensionAppIcon(const Extension* extension);
   1057 
   1058   // ImageLoadingTracker::Observer.
   1059   virtual void OnImageLoaded(SkBitmap* image, ExtensionResource resource,
   1060                              int index);
   1061 
   1062   // Checks with the PrerenderManager if the specified URL has been preloaded,
   1063   // and if so, swap the RenderViewHost with the preload into this TabContents
   1064   // object.
   1065   bool MaybeUsePreloadedPage(const GURL& url);
   1066 
   1067   // Data for core operation ---------------------------------------------------
   1068 
   1069   // Delegate for notifying our owner about stuff. Not owned by us.
   1070   TabContentsDelegate* delegate_;
   1071 
   1072   // Handles the back/forward list and loading.
   1073   NavigationController controller_;
   1074 
   1075   // The corresponding view.
   1076   scoped_ptr<TabContentsView> view_;
   1077 
   1078   // Helper classes ------------------------------------------------------------
   1079 
   1080   // Manages creation and swapping of render views.
   1081   RenderViewHostManager render_manager_;
   1082 
   1083   // Stores random bits of data for others to associate with this object.
   1084   PropertyBag property_bag_;
   1085 
   1086   // Registers and unregisters us for notifications.
   1087   NotificationRegistrar registrar_;
   1088 
   1089   // Registers and unregisters for pref notifications.
   1090   PrefChangeRegistrar pref_change_registrar_;
   1091 
   1092   // Handles print job for this contents.
   1093   scoped_ptr<printing::PrintViewManager> printing_;
   1094 
   1095   // Handles print preview for this contents.
   1096   scoped_ptr<printing::PrintPreviewMessageHandler> print_preview_;
   1097 
   1098   // SavePackage, lazily created.
   1099   scoped_refptr<SavePackage> save_package_;
   1100 
   1101   // AutocompleteHistoryManager.
   1102   scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_;
   1103 
   1104   // AutoFillManager.
   1105   scoped_ptr<AutoFillManager> autofill_manager_;
   1106 
   1107   // Handles plugin messages.
   1108   scoped_ptr<PluginObserver> plugin_observer_;
   1109 
   1110   // Prerender PageLoadTime Recorder.
   1111   scoped_ptr<PrerenderPLTRecorder> prerender_plt_recorder_;
   1112 
   1113   // TabContentsSSLHelper, lazily created.
   1114   scoped_ptr<TabContentsSSLHelper> ssl_helper_;
   1115 
   1116   // FileSelectHelper, lazily created.
   1117   scoped_ptr<FileSelectHelper> file_select_helper_;
   1118 
   1119   // Handles drag and drop event forwarding to extensions.
   1120   BookmarkDrag* bookmark_drag_;
   1121 
   1122   // Handles downloading favicons.
   1123   FavIconHelper fav_icon_helper_;
   1124 
   1125   // Cached web app info data.
   1126   WebApplicationInfo web_app_info_;
   1127 
   1128   // Cached web app icon.
   1129   SkBitmap app_icon_;
   1130 
   1131   // RenderViewHost::ContentSettingsDelegate.
   1132   scoped_ptr<TabSpecificContentSettings> content_settings_delegate_;
   1133 
   1134   // Handles desktop notification IPCs.
   1135   scoped_ptr<DesktopNotificationHandler> desktop_notification_handler_;
   1136 
   1137 
   1138   // Data for loading state ----------------------------------------------------
   1139 
   1140   // Indicates whether we're currently loading a resource.
   1141   bool is_loading_;
   1142 
   1143   // Indicates if the tab is considered crashed.
   1144   base::TerminationStatus crashed_status_;
   1145   int crashed_error_code_;
   1146 
   1147   // See waiting_for_response() above.
   1148   bool waiting_for_response_;
   1149 
   1150   // Indicates the largest PageID we've seen.  This field is ignored if we are
   1151   // a TabContents, in which case the max page ID is stored separately with
   1152   // each SiteInstance.
   1153   // TODO(brettw) this seems like it can be removed according to the comment.
   1154   int32 max_page_id_;
   1155 
   1156   // System time at which the current load was started.
   1157   base::TimeTicks current_load_start_;
   1158 
   1159   // The current load state and the URL associated with it.
   1160   net::LoadState load_state_;
   1161   string16 load_state_host_;
   1162   // Upload progress, for displaying in the status bar.
   1163   // Set to zero when there is no significant upload happening.
   1164   uint64 upload_size_;
   1165   uint64 upload_position_;
   1166 
   1167   // Data for current page -----------------------------------------------------
   1168 
   1169   // Whether we have a (non-empty) title for the current page.
   1170   // Used to prevent subsequent title updates from affecting history. This
   1171   // prevents some weirdness because some AJAXy apps use titles for status
   1172   // messages.
   1173   bool received_page_title_;
   1174 
   1175   // When a navigation occurs, we record its contents MIME type. It can be
   1176   // used to check whether we can do something for some special contents.
   1177   std::string contents_mime_type_;
   1178 
   1179   // Character encoding.
   1180   std::string encoding_;
   1181 
   1182   // Object that holds any blocked TabContents spawned from this TabContents.
   1183   BlockedContentContainer* blocked_contents_;
   1184 
   1185   // Should we block all child TabContents this attempts to spawn.
   1186   bool all_contents_blocked_;
   1187 
   1188   // TODO(pkasting): Hack to try and fix Linux browser tests.
   1189   bool dont_notify_render_view_;
   1190 
   1191   // True if this is a secure page which displayed insecure content.
   1192   bool displayed_insecure_content_;
   1193 
   1194   // Data for shelves and stuff ------------------------------------------------
   1195 
   1196   // Delegates for InfoBars associated with this TabContents.
   1197   std::vector<InfoBarDelegate*> infobar_delegates_;
   1198 
   1199   // Data for app extensions ---------------------------------------------------
   1200 
   1201   // If non-null this tab is an app tab and this is the extension the tab was
   1202   // created for.
   1203   const Extension* extension_app_;
   1204 
   1205   // Icon for extension_app_ (if non-null) or extension_for_current_page_.
   1206   SkBitmap extension_app_icon_;
   1207 
   1208   // Used for loading extension_app_icon_.
   1209   scoped_ptr<ImageLoadingTracker> extension_app_image_loader_;
   1210 
   1211   // Data for misc internal state ----------------------------------------------
   1212 
   1213   // See capturing_contents() above.
   1214   bool capturing_contents_;
   1215 
   1216   // See getter above.
   1217   bool is_being_destroyed_;
   1218 
   1219   // Indicates whether we should notify about disconnection of this
   1220   // TabContents. This is used to ensure disconnection notifications only
   1221   // happen if a connection notification has happened and that they happen only
   1222   // once.
   1223   bool notify_disconnection_;
   1224 
   1225   // Maps from handle to page_id.
   1226   typedef std::map<FaviconService::Handle, int32> HistoryRequestMap;
   1227   HistoryRequestMap history_requests_;
   1228 
   1229 #if defined(OS_WIN)
   1230   // Handle to an event that's set when the page is showing a message box (or
   1231   // equivalent constrained window).  Plugin processes check this to know if
   1232   // they should pump messages then.
   1233   base::win::ScopedHandle message_box_active_;
   1234 #endif
   1235 
   1236   // The time that the last javascript message was dismissed.
   1237   base::TimeTicks last_javascript_message_dismissal_;
   1238 
   1239   // True if the user has decided to block future javascript messages. This is
   1240   // reset on navigations to false on navigations.
   1241   bool suppress_javascript_messages_;
   1242 
   1243   // Set to true when there is an active "before unload" dialog.  When true,
   1244   // we've forced the throbber to start in Navigate, and we need to remember to
   1245   // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
   1246   bool is_showing_before_unload_dialog_;
   1247 
   1248   // Shows an info-bar to users when they search from a known search engine and
   1249   // have never used the monibox for search before.
   1250   scoped_ptr<OmniboxSearchHint> omnibox_search_hint_;
   1251 
   1252   // Settings that get passed to the renderer process.
   1253   RendererPreferences renderer_preferences_;
   1254 
   1255   // If this tab was created from a renderer using window.open, this will be
   1256   // non-NULL and represent the WebUI of the opening renderer.
   1257   WebUITypeID opener_web_ui_type_;
   1258 
   1259   // The time that we started to create the new tab page.
   1260   base::TimeTicks new_tab_start_time_;
   1261 
   1262   // The time that we started to close the tab.
   1263   base::TimeTicks tab_close_start_time_;
   1264 
   1265   // The time that this tab was last selected.
   1266   base::TimeTicks last_selected_time_;
   1267 
   1268   // Information about the language the page is in and has been translated to.
   1269   LanguageState language_state_;
   1270 
   1271   // See description above setter.
   1272   bool closed_by_user_gesture_;
   1273 
   1274   // Minimum/maximum zoom percent.
   1275   int minimum_zoom_percent_;
   1276   int maximum_zoom_percent_;
   1277   // If true, the default zoom limits have been overriden for this tab, in which
   1278   // case we don't want saved settings to apply to it and we don't want to
   1279   // remember it.
   1280   bool temporary_zoom_settings_;
   1281 
   1282   // A list of observers notified when page state changes. Weak references.
   1283   ObserverList<TabContentsObserver> observers_;
   1284 
   1285   // Content restrictions, used to disable print/copy etc based on content's
   1286   // (full-page plugins for now only) permissions.
   1287   int content_restrictions_;
   1288 
   1289   DISALLOW_COPY_AND_ASSIGN(TabContents);
   1290 };
   1291 
   1292 #endif // !ANDROID
   1293 
   1294 #endif  // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_
   1295