diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-18 19:52:40 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-18 19:52:40 +0000 |
commit | 1ef5ad42064c8ef0d1503b68a7fbac01887ca093 (patch) | |
tree | 34a32b11a9db6f69fef27e7e81863d82a29bcd2d /chrome/browser/tab_contents/tab_contents.h | |
parent | 59b49a66c3cd959fcf9d7b4bd9c6d88c70b39919 (diff) | |
download | chromium_src-1ef5ad42064c8ef0d1503b68a7fbac01887ca093.zip chromium_src-1ef5ad42064c8ef0d1503b68a7fbac01887ca093.tar.gz chromium_src-1ef5ad42064c8ef0d1503b68a7fbac01887ca093.tar.bz2 |
Reverting 14005.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents/tab_contents.h')
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 76 |
1 files changed, 61 insertions, 15 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index aa636f3..26dda95 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -44,8 +44,23 @@ class SkBitmap; class SiteInstance; class WebContents; -// Describes what goes in the main content area of a tab. WebContents is -// the only type of TabContents, and these should be merged together. +// Describes what goes in the main content area of a tab. For example, +// the WebContents is one such thing. +// +// When instantiating a new TabContents explicitly, the TabContents will not +// have an associated NavigationController. To setup a NavigationController +// for the TabContents, its SetupController method should be called. +// +// Once they reside within a NavigationController, TabContents objects are +// owned by that NavigationController. When the active TabContents within that +// NavigationController is closed, that TabContents destroys the +// NavigationController, which then destroys all of the TabContentses in it. +// +// NOTE: When the NavigationController is navigated to an URL corresponding to +// a different type of TabContents (see the TabContents::TypeForURL method), +// the NavigationController makes the active TabContents inactive, notifies the +// TabContentsDelegate that the TabContents is being replaced, and then +// activates the new TabContents. class TabContents : public PageNavigator, public NotificationObserver { public: @@ -62,10 +77,23 @@ class TabContents : public PageNavigator, INVALIDATE_EVERYTHING = 0xFFFFFFFF }; - virtual ~TabContents(); - static void RegisterUserPrefs(PrefService* prefs); + // Creation & destruction ---------------------------------------------------- + + // Request this tab to shut down. This kills the tab's NavigationController, + // which then Destroy()s all tabs it controls. + void CloseContents(); + + // Unregister/shut down any pending tasks involving this tab. + // This is called as the tab is shutting down, before the + // NavigationController (and consequently profile) are gone. + // + // If you override this, be sure to call this implementation at the end + // of yours. + // See also Close(). + virtual void Destroy() = 0; + // Intrinsic tab state ------------------------------------------------------- // Returns the property bag for this tab contents, where callers can add @@ -88,13 +116,27 @@ class TabContents : public PageNavigator, TabContentsDelegate* delegate() const { return delegate_; } void set_delegate(TabContentsDelegate* d) { delegate_ = d; } - // Gets the controller for this tab contents. - NavigationController& controller() { return controller_; } - const NavigationController& controller() const { return controller_; } + // This can only be null if the TabContents has been created but + // SetupController has not been called. The controller should always outlive + // its TabContents. + NavigationController* controller() const { return controller_; } + void set_controller(NavigationController* c) { controller_ = c; } + + // Sets up a new NavigationController for this TabContents. + // |profile| is the user profile that should be associated with + // the new controller. + // + // TODO(brettw) this seems bogus and I couldn't find any legitimate need for + // it. I think it should be passed in the constructor. + void SetupController(Profile* profile); // Returns the user profile associated with this TabContents (via the - // NavigationController). - Profile* profile() const { return controller_.profile(); } + // NavigationController). This will return NULL if there isn't yet a + // NavigationController on this TabContents. + // TODO(darin): make it so that controller_ can never be null + Profile* profile() const { + return controller_ ? controller_->profile() : NULL; + } // Returns whether this tab contents supports the provided URL.This method // matches the tab contents type with the result of TypeForURL(). |url| points @@ -231,10 +273,6 @@ class TabContents : public PageNavigator, // Called on a TabContents when it isn't a popup, but a new window. virtual void DisassociateFromPopupCount() = 0; - // Creates a new TabContents with the same state as this one. The returned - // heap-allocated pointer is owned by the caller. - virtual TabContents* Clone() = 0; - // Window management --------------------------------------------------------- #if defined(OS_WIN) @@ -348,7 +386,15 @@ class TabContents : public PageNavigator, // automation purposes. friend class AutomationProvider; - TabContents(Profile* profile); + TabContents(); + + // NOTE: the TabContents destructor can run after the NavigationController + // has gone away, so any complicated unregistering that expects the profile + // or other shared objects to still be around does not belong in a + // destructor. + // For those purposes, instead see Destroy(). + // Protected so that others don't try to delete this directly. + virtual ~TabContents(); // Changes the IsLoading state and notifies delegate as needed // |details| is used to provide details on the load that just finished @@ -386,7 +432,7 @@ class TabContents : public PageNavigator, // Data ---------------------------------------------------------------------- TabContentsDelegate* delegate_; - NavigationController controller_; + NavigationController* controller_; PropertyBag property_bag_; |