| Index: chrome/browser/sidebar/sidebar_manager.h
|
| ===================================================================
|
| --- chrome/browser/sidebar/sidebar_manager.h (revision 74134)
|
| +++ chrome/browser/sidebar/sidebar_manager.h (working copy)
|
| @@ -7,19 +7,19 @@
|
|
|
| #include <map>
|
| #include <string>
|
| +#include <vector>
|
|
|
| #include "base/ref_counted.h"
|
| #include "base/string16.h"
|
| #include "chrome/browser/sidebar/sidebar_container.h"
|
| +#include "chrome/browser/sidebar/sidebar_model.h"
|
| #include "chrome/common/notification_observer.h"
|
| #include "chrome/common/notification_registrar.h"
|
|
|
| class GURL;
|
| -class PrefService;
|
| -class Profile;
|
| -class SidebarContainer;
|
| class SkBitmap;
|
| class TabContents;
|
| +class TabContentsWrapper;
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // SidebarManager
|
| @@ -27,7 +27,8 @@
|
| // This class is a singleton that manages SidebarContainer instances and
|
| // maintains a connection between tabs and sidebars.
|
| //
|
| -class SidebarManager : public NotificationObserver,
|
| +class SidebarManager : public SidebarModel,
|
| + public NotificationObserver,
|
| public base::RefCounted<SidebarManager>,
|
| private SidebarContainer::Delegate {
|
| public:
|
| @@ -39,60 +40,45 @@
|
|
|
| SidebarManager();
|
|
|
| - // Returns SidebarContainer registered for |tab| and active or NULL if
|
| - // there is no alive and active SidebarContainer registered for |tab|.
|
| - SidebarContainer* GetActiveSidebarContainerFor(TabContents* tab);
|
| + // SidebarModel overrides.
|
| + virtual std::vector<SidebarContainer*> GetAllSidebarsFor(
|
| + TabContentsWrapper* tab);
|
| + virtual SidebarContainer* GetActiveSidebarContainerFor(
|
| + TabContentsWrapper* tab);
|
| + virtual SidebarContainer* GetSidebarContainerFor(
|
| + TabContentsWrapper* tab, const std::string& content_id);
|
| + virtual TabContents* GetSidebarTabContents(
|
| + TabContentsWrapper* tab, const std::string& content_id);
|
| + virtual void ToggleSidebar(
|
| + TabContentsWrapper* tab, const std::string& content_id);
|
| + virtual void NotifyStateChanges(
|
| + TabContents* was_active_sidebar_contents,
|
| + TabContents* active_sidebar_contents);
|
| + virtual void ShowSidebar(TabContentsWrapper* tab,
|
| + const std::string& content_id);
|
| + virtual void ExpandSidebar(TabContentsWrapper* tab,
|
| + const std::string& content_id);
|
| + virtual void CollapseSidebar(TabContentsWrapper* tab,
|
| + const std::string& content_id);
|
| + virtual void HideSidebar(TabContentsWrapper* tab,
|
| + const std::string& content_id);
|
| + virtual void NavigateSidebar(TabContentsWrapper* tab,
|
| + const std::string& content_id,
|
| + const GURL& url);
|
| + virtual void SetSidebarBadgeText(TabContentsWrapper* tab,
|
| + const std::string& content_id,
|
| + const string16& badge_text);
|
| + virtual void SetSidebarIcon(TabContentsWrapper* tab,
|
| + const std::string& content_id,
|
| + const SkBitmap& bitmap);
|
| + virtual void SetSidebarTitle(TabContentsWrapper* tab,
|
| + const std::string& content_id,
|
| + const string16& title);
|
|
|
| - // Returns SidebarContainer registered for |tab| and |content_id| or NULL if
|
| - // there is no such SidebarContainer registered.
|
| - SidebarContainer* GetSidebarContainerFor(TabContents* tab,
|
| - const std::string& content_id);
|
| + // More efficient than GetAllSidebarsFor when all you need to know
|
| + // is whether any sidebar is defined for the |tab| or not.
|
| + bool IsAnySidebarDefinedFor(TabContentsWrapper* tab);
|
|
|
| - // Returns sidebar's TabContents registered for |tab| and |content_id|.
|
| - TabContents* GetSidebarTabContents(TabContents* tab,
|
| - const std::string& content_id);
|
| -
|
| - // Sends sidebar state change notification to extensions.
|
| - void NotifyStateChanges(TabContents* was_active_sidebar_contents,
|
| - TabContents* active_sidebar_contents);
|
| -
|
| - // Functions supporting chrome.experimental.sidebar API.
|
| -
|
| - // Shows sidebar identified by |tab| and |content_id| (only sidebar's
|
| - // mini tab is visible).
|
| - void ShowSidebar(TabContents* tab, const std::string& content_id);
|
| -
|
| - // Expands sidebar identified by |tab| and |content_id|.
|
| - void ExpandSidebar(TabContents* tab, const std::string& content_id);
|
| -
|
| - // Collapses sidebar identified by |tab| and |content_id| (has no effect
|
| - // if sidebar is not expanded).
|
| - void CollapseSidebar(TabContents* tab, const std::string& content_id);
|
| -
|
| - // Hides sidebar identified by |tab| and |content_id| (removes sidebar's
|
| - // mini tab).
|
| - void HideSidebar(TabContents* tab, const std::string& content_id);
|
| -
|
| - // Navigates sidebar identified by |tab| and |content_id| to |url|.
|
| - void NavigateSidebar(TabContents* tab,
|
| - const std::string& content_id,
|
| - const GURL& url);
|
| -
|
| - // Changes sidebar's badge text (displayed on the mini tab).
|
| - void SetSidebarBadgeText(TabContents* tab,
|
| - const std::string& content_id,
|
| - const string16& badge_text);
|
| -
|
| - // Changes sidebar's icon (displayed on the mini tab).
|
| - void SetSidebarIcon(TabContents* tab,
|
| - const std::string& content_id,
|
| - const SkBitmap& bitmap);
|
| -
|
| - // Changes sidebar's title (mini tab's tooltip).
|
| - void SetSidebarTitle(TabContents* tab,
|
| - const std::string& content_id,
|
| - const string16& title);
|
| -
|
| private:
|
| friend class base::RefCounted<SidebarManager>;
|
|
|
| @@ -104,28 +90,32 @@
|
| const NotificationDetails& details);
|
|
|
| // Overridden from SidebarContainer::Delegate.
|
| - virtual void UpdateSidebar(SidebarContainer* host);
|
| + virtual void UpdateSidebar(SidebarChangedDetails* details);
|
|
|
| // Hides all sidebars registered for |tab|.
|
| - void HideAllSidebars(TabContents* tab);
|
| + void HideAllSidebars(TabContentsWrapper* tab);
|
|
|
| // Returns SidebarContainer corresponding to |sidebar_contents|.
|
| SidebarContainer* FindSidebarContainerFor(TabContents* sidebar_contents);
|
|
|
| + // Returns TabContentsWrapper corresponding to |tab_contents|.
|
| + TabContentsWrapper* FindTabContentsWrapperFor(TabContents* tab_contents);
|
| +
|
| // Registers new SidebarContainer for |tab|. There must be no
|
| // other SidebarContainers registered for the RenderViewHost at the moment.
|
| - void RegisterSidebarContainerFor(TabContents* tab,
|
| + void RegisterSidebarContainerFor(TabContentsWrapper* tab,
|
| SidebarContainer* container);
|
|
|
| // Unregisters SidebarContainer identified by |tab| and |content_id|.
|
| - void UnregisterSidebarContainerFor(TabContents* tab,
|
| + void UnregisterSidebarContainerFor(TabContentsWrapper* tab,
|
| const std::string& content_id);
|
|
|
| // Records the link between |tab| and |sidebar_host|.
|
| - void BindSidebarHost(TabContents* tab, SidebarContainer* sidebar_host);
|
| + void BindSidebarHost(TabContentsWrapper* tab, SidebarContainer* sidebar_host);
|
|
|
| // Forgets the link between |tab| and |sidebar_host|.
|
| - void UnbindSidebarHost(TabContents* tab, SidebarContainer* sidebar_host);
|
| + void UnbindSidebarHost(TabContentsWrapper* tab,
|
| + SidebarContainer* sidebar_host);
|
|
|
| NotificationRegistrar registrar_;
|
|
|
| @@ -139,10 +129,10 @@
|
| // SidebarManager start listening to SidebarContainers when they are put
|
| // into these maps and removes them when they are closing.
|
| struct SidebarStateForTab;
|
| - typedef std::map<TabContents*, SidebarStateForTab> TabToSidebarHostMap;
|
| + typedef std::map<TabContentsWrapper*, SidebarStateForTab> TabToSidebarHostMap;
|
| TabToSidebarHostMap tab_to_sidebar_host_;
|
|
|
| - typedef std::map<SidebarContainer*, TabContents*> SidebarHostToTabMap;
|
| + typedef std::map<SidebarContainer*, TabContentsWrapper*> SidebarHostToTabMap;
|
| SidebarHostToTabMap sidebar_host_to_tab_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(SidebarManager);
|
|
|