Index: chrome/browser/extensions/sidebar_manager.h |
diff --git a/chrome/browser/extensions/sidebar_manager.h b/chrome/browser/extensions/sidebar_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..28353e4da2466333fd943ba83ee3c9cbd01e1e32 |
--- /dev/null |
+++ b/chrome/browser/extensions/sidebar_manager.h |
@@ -0,0 +1,85 @@ |
+// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_EXTENSIONS_SIDEBAR_MANAGER_H_ |
+#define CHROME_BROWSER_EXTENSIONS_SIDEBAR_MANAGER_H_ |
+ |
+#include <map> |
+#include <string> |
Devlin
2015/06/19 19:56:10
Do we need this?
ltilve
2015/06/28 22:44:20
Done.
|
+ |
+#include "base/observer_list.h" |
+#include "base/strings/string16.h" |
Devlin
2015/06/19 19:56:10
Or this?
ltilve
2015/06/28 22:44:20
Done.
|
+#include "chrome/browser/extensions/sidebar_container.h" |
Devlin
2015/06/19 19:56:10
Or this? (Please comb through these regularly and
ltilve
2015/06/28 22:44:20
Done.
|
+ |
+class GURL; |
+class SidebarContainer; |
+class SidebarManagerObserver; |
+ |
+namespace content { |
+class BrowserContext; |
+class WebContents; |
+} |
+ |
+namespace extensions { |
+/////////////////////////////////////////////////////////////////////////////// |
+// SidebarManager |
+// |
+// This class is a singleton that manages SidebarContainer instances and |
+// maintains a connection between tabs and sidebars. |
+// |
+class SidebarManager { |
+ public: |
+ // Returns SidebarManager instance registered with BrowserContext. |
+ static SidebarManager* GetFromContext(content::BrowserContext* context); |
+ |
+ SidebarManager(); |
+ |
+ // Returns SidebarContainer registered for |tab| or nullptr if there is no |
Devlin
2015/06/19 19:56:10
It seems like this and HasSidebar can be combined
ltilve
2015/06/28 22:44:20
By combining them I understand that you mean just
ltilve
2015/06/29 10:46:51
Done. I have applied that modification.
|
+ // SidebarContainer registered for |tab|. |
+ SidebarContainer* GetSidebarContainerFor(content::WebContents* tab); |
+ |
+ // Creates a new sidebar identified by |tab| (adds sidebar's mini tab). |
+ void CreateSidebar(content::WebContents* tab, |
+ const GURL& url, |
+ Browser* browser); |
+ |
+ // Hides and destroys sidebar identified by |tab| (removes sidebar's mini |
+ // tab). |
+ void HideSidebar(content::WebContents* tab); |
+ |
+ // Check if |tab| has a sidebar assigned. |
+ bool HasSidebar(content::WebContents* tab); |
+ |
+ void AddObserver(SidebarManagerObserver* observer); |
+ void RemoveObserver(SidebarManagerObserver* observer); |
+ |
+ ~SidebarManager(); |
Devlin
2015/06/19 19:56:10
put this up near the constructor
ltilve
2015/06/28 22:44:20
Done.
|
+ |
+ private: |
+ // Returns SidebarContainer corresponding to |sidebar_contents|. |
+ SidebarContainer* FindSidebarContainerFor( |
Devlin
2015/06/19 19:56:10
Is this used?
ltilve
2015/06/28 22:44:20
Done. This function has been moved to the UI patch
|
+ content::WebContents* sidebar_contents); |
+ |
+ // This map stores sidebars linked to a particular tab. Sidebars are |
+ // identified by their unique content id (string). |
+ typedef std::map<std::string, SidebarContainer*> |
+ ContentIdToSidebarContainerMap; |
Devlin
2015/06/19 19:56:10
Do we need this?
ltilve
2015/06/28 22:44:20
Done. It was not being longer used.
|
+ |
+ // These two maps are for tracking dependencies between tabs and |
+ // their SidebarContainers. |
+ // |
+ // SidebarManager start listening to SidebarContainers when they are put |
+ // into these maps and removes them when they are closing. |
+ typedef std::map<content::WebContents*, SidebarContainer*> |
Devlin
2015/06/19 19:56:10
nit: prefer 'using' syntax.
ltilve
2015/06/28 22:44:20
Done.
|
+ TabToSidebarContainerMap; |
+ TabToSidebarContainerMap tab_to_sidebar_container_; |
+ |
+ base::ObserverList<SidebarManagerObserver> observer_list_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SidebarManager); |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_SIDEBAR_MANAGER_H_ |