OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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 <map> | |
9 #include <string> | |
Devlin
2015/06/19 19:56:10
Do we need this?
ltilve
2015/06/28 22:44:20
Done.
| |
10 | |
11 #include "base/observer_list.h" | |
12 #include "base/strings/string16.h" | |
Devlin
2015/06/19 19:56:10
Or this?
ltilve
2015/06/28 22:44:20
Done.
| |
13 #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.
| |
14 | |
15 class GURL; | |
16 class SidebarContainer; | |
17 class SidebarManagerObserver; | |
18 | |
19 namespace content { | |
20 class BrowserContext; | |
21 class WebContents; | |
22 } | |
23 | |
24 namespace extensions { | |
25 /////////////////////////////////////////////////////////////////////////////// | |
26 // SidebarManager | |
27 // | |
28 // This class is a singleton that manages SidebarContainer instances and | |
29 // maintains a connection between tabs and sidebars. | |
30 // | |
31 class SidebarManager { | |
32 public: | |
33 // Returns SidebarManager instance registered with BrowserContext. | |
34 static SidebarManager* GetFromContext(content::BrowserContext* context); | |
35 | |
36 SidebarManager(); | |
37 | |
38 // 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.
| |
39 // SidebarContainer registered for |tab|. | |
40 SidebarContainer* GetSidebarContainerFor(content::WebContents* tab); | |
41 | |
42 // Creates a new sidebar identified by |tab| (adds sidebar's mini tab). | |
43 void CreateSidebar(content::WebContents* tab, | |
44 const GURL& url, | |
45 Browser* browser); | |
46 | |
47 // Hides and destroys sidebar identified by |tab| (removes sidebar's mini | |
48 // tab). | |
49 void HideSidebar(content::WebContents* tab); | |
50 | |
51 // Check if |tab| has a sidebar assigned. | |
52 bool HasSidebar(content::WebContents* tab); | |
53 | |
54 void AddObserver(SidebarManagerObserver* observer); | |
55 void RemoveObserver(SidebarManagerObserver* observer); | |
56 | |
57 ~SidebarManager(); | |
Devlin
2015/06/19 19:56:10
put this up near the constructor
ltilve
2015/06/28 22:44:20
Done.
| |
58 | |
59 private: | |
60 // Returns SidebarContainer corresponding to |sidebar_contents|. | |
61 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
| |
62 content::WebContents* sidebar_contents); | |
63 | |
64 // This map stores sidebars linked to a particular tab. Sidebars are | |
65 // identified by their unique content id (string). | |
66 typedef std::map<std::string, SidebarContainer*> | |
67 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.
| |
68 | |
69 // These two maps are for tracking dependencies between tabs and | |
70 // their SidebarContainers. | |
71 // | |
72 // SidebarManager start listening to SidebarContainers when they are put | |
73 // into these maps and removes them when they are closing. | |
74 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.
| |
75 TabToSidebarContainerMap; | |
76 TabToSidebarContainerMap tab_to_sidebar_container_; | |
77 | |
78 base::ObserverList<SidebarManagerObserver> observer_list_; | |
79 | |
80 DISALLOW_COPY_AND_ASSIGN(SidebarManager); | |
81 }; | |
82 | |
83 } // namespace extensions | |
84 | |
85 #endif // CHROME_BROWSER_EXTENSIONS_SIDEBAR_MANAGER_H_ | |
OLD | NEW |