Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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_EXTENSIONS_SIDEBAR_MANAGER_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_SIDEBAR_MANAGER_H_ | |
| 7 | |
| 8 #include "base/observer_list.h" | |
| 9 #include "chrome/browser/extensions/sidebar_container.h" | |
| 10 | |
| 11 class GURL; | |
| 12 class SidebarContainer; | |
| 13 class SidebarManagerObserver; | |
| 14 | |
| 15 namespace content { | |
| 16 class BrowserContext; | |
| 17 class WebContents; | |
| 18 } | |
| 19 | |
| 20 namespace extensions { | |
| 21 | |
| 22 // Singleton that manages SidebarContainer instances and | |
| 23 // maintains a connection between tabs and sidebars. | |
| 24 class SidebarManager { | |
| 25 public: | |
| 26 // Returns SidebarManager instance registered with BrowserContext. | |
| 27 static SidebarManager* GetFromContext(content::BrowserContext* context); | |
| 28 | |
| 29 SidebarManager(); | |
| 30 | |
| 31 ~SidebarManager(); | |
| 32 | |
| 33 // Returns SidebarContainer registered for |tab| or nullptr if there is no | |
| 34 // SidebarContainer registered for |tab|. | |
| 35 SidebarContainer* GetSidebarContainerFor(content::WebContents* tab); | |
| 36 | |
| 37 // Creates a new sidebar identified by |tab| (adds sidebar's mini tab). | |
| 38 void CreateSidebar(content::WebContents* tab, | |
| 39 const GURL& url, | |
| 40 Browser* browser); | |
| 41 | |
| 42 // Hides and destroys sidebar identified by |tab| (removes sidebar's mini | |
| 43 // tab). | |
|
Devlin
2015/07/07 21:39:29
What is a mini tab?
ltilve
2015/07/09 22:15:51
Done. Removed the wrong comment.
| |
| 44 void HideSidebar(content::WebContents* tab); | |
|
Devlin
2015/07/07 21:39:29
Let's rename this HideSidebarForTab().
ltilve
2015/07/09 22:15:51
Done.
| |
| 45 | |
| 46 void AddObserver(SidebarManagerObserver* observer); | |
| 47 void RemoveObserver(SidebarManagerObserver* observer); | |
| 48 | |
| 49 private: | |
| 50 // These two maps are for tracking dependencies between tabs and | |
| 51 // their SidebarContainers. | |
| 52 // | |
| 53 // SidebarManager start listening to SidebarContainers when they are put | |
| 54 // into these maps and removes them when they are closing. | |
| 55 using TabToSidebarContainerMap = | |
| 56 std::map<content::WebContents*, SidebarContainer*>; | |
| 57 | |
| 58 TabToSidebarContainerMap tab_to_sidebar_container_; | |
| 59 | |
| 60 base::ObserverList<SidebarManagerObserver> observer_list_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(SidebarManager); | |
| 63 }; | |
| 64 | |
| 65 } // namespace extensions | |
| 66 | |
| 67 #endif // CHROME_BROWSER_EXTENSIONS_SIDEBAR_MANAGER_H_ | |
| OLD | NEW |