OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 14 matching lines...) Expand all Loading... | |
25 } | 25 } |
26 | 26 |
27 namespace aura { | 27 namespace aura { |
28 class Window; | 28 class Window; |
29 } | 29 } |
30 | 30 |
31 // LauncherUpdater is responsible for keeping the launcher representation of a | 31 // LauncherUpdater is responsible for keeping the launcher representation of a |
32 // window up to date as the tab strip changes. | 32 // window up to date as the tab strip changes. |
33 class LauncherUpdater : public TabStripModelObserver { | 33 class LauncherUpdater : public TabStripModelObserver { |
34 public: | 34 public: |
35 // This API is to be used as part of testing only. | |
36 class TestApi { | |
sky
2012/03/13 17:14:42
I hate seeing the first public thing in a class a
DaveMoore
2012/03/13 23:33:56
I understand the issue about it being the first th
| |
37 public: | |
38 TestApi(LauncherUpdater* launcher_updater) | |
39 : launcher_updater_(launcher_updater) {} | |
40 virtual ~TestApi() {} | |
41 | |
42 // Returns the launcher id for |tab| if it's an app otherwise returns the | |
43 // id for the browser itself. | |
44 ash::LauncherID GetLauncherID(TabContentsWrapper* tab) { | |
45 return launcher_updater_->GetLauncherID(tab); | |
46 } | |
47 | |
48 // Returns the launcher id for the browser window. | |
49 ash::LauncherID item_id() const { return launcher_updater_->item_id_; } | |
50 | |
51 private: | |
52 LauncherUpdater* launcher_updater_; | |
53 }; | |
54 | |
35 enum Type { | 55 enum Type { |
36 TYPE_APP, | 56 TYPE_APP, |
37 TYPE_PANEL, | 57 TYPE_PANEL, |
38 TYPE_TABBED | 58 TYPE_TABBED |
39 }; | 59 }; |
40 | 60 |
41 LauncherUpdater(aura::Window* window, | 61 LauncherUpdater(aura::Window* window, |
42 TabStripModel* tab_model, | 62 TabStripModel* tab_model, |
43 ChromeLauncherDelegate* launcher_delegate, | 63 ChromeLauncherDelegate* launcher_delegate, |
44 Type type, | 64 Type type, |
45 const std::string& app_id); | 65 const std::string& app_id); |
46 virtual ~LauncherUpdater(); | 66 virtual ~LauncherUpdater(); |
47 | 67 |
48 // Sets up this LauncherUpdater. | 68 // Sets up this LauncherUpdater. |
49 void Init(); | 69 void Init(); |
50 | 70 |
51 // Creates and returns a new LauncherUpdater for |browser|. This returns | 71 // Creates and returns a new LauncherUpdater for |browser|. This returns |
52 // NULL if a LauncherUpdater is not needed for the specified browser. | 72 // NULL if a LauncherUpdater is not needed for the specified browser. |
53 static LauncherUpdater* Create(Browser* browser); | 73 static LauncherUpdater* Create(Browser* browser); |
54 | 74 |
55 aura::Window* window() { return window_; } | 75 aura::Window* window() { return window_; } |
56 | 76 |
57 TabStripModel* tab_model() { return tab_model_; } | 77 TabStripModel* tab_model() { return tab_model_; } |
58 | 78 |
59 Type type() const { return type_; } | 79 Type type() const { return type_; } |
60 | 80 |
61 TabContentsWrapper* GetTab(ash::LauncherID id); | 81 TabContentsWrapper* GetTab(ash::LauncherID id); |
62 | 82 |
63 // TabStripModel overrides: | 83 // TabStripModel overrides: |
84 void ActivationChanged(TabContentsWrapper* tab, bool active); | |
sky
2012/03/13 17:14:42
Don't group this with TabStripModel overrides.
Al
DaveMoore
2012/03/13 23:33:56
Done.
| |
64 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, | 85 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, |
65 TabContentsWrapper* new_contents, | 86 TabContentsWrapper* new_contents, |
66 int index, | 87 int index, |
67 bool user_gesture) OVERRIDE; | 88 bool user_gesture) OVERRIDE; |
68 virtual void TabChangedAt( | 89 virtual void TabChangedAt( |
69 TabContentsWrapper* tab, | 90 TabContentsWrapper* tab, |
70 int index, | 91 int index, |
71 TabStripModelObserver::TabChangeType change_type) OVERRIDE; | 92 TabStripModelObserver::TabChangeType change_type) OVERRIDE; |
72 virtual void TabInsertedAt(TabContentsWrapper* contents, | 93 virtual void TabInsertedAt(TabContentsWrapper* contents, |
73 int index, | 94 int index, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 void RegisterAppItem(ash::LauncherID id, TabContentsWrapper* tab); | 134 void RegisterAppItem(ash::LauncherID id, TabContentsWrapper* tab); |
114 | 135 |
115 // Creates a tabbed launcher item. | 136 // Creates a tabbed launcher item. |
116 void CreateTabbedItem(); | 137 void CreateTabbedItem(); |
117 | 138 |
118 // Returns true if this LauncherUpdater created the launcher item with the | 139 // Returns true if this LauncherUpdater created the launcher item with the |
119 // specified id. Returns true if it did. If the id corresponds to an app tab, | 140 // specified id. Returns true if it did. If the id corresponds to an app tab, |
120 // |tab| is set to the TabContentsWrapper for the app tab. | 141 // |tab| is set to the TabContentsWrapper for the app tab. |
121 bool ContainsID(ash::LauncherID id, TabContentsWrapper** tab); | 142 bool ContainsID(ash::LauncherID id, TabContentsWrapper** tab); |
122 | 143 |
144 // Returns the launcher id for |tab| if it's an app otherwise returns the | |
145 // id for the browser itself. | |
146 ash::LauncherID GetLauncherID(TabContentsWrapper* tab); | |
147 | |
123 ash::LauncherModel* launcher_model(); | 148 ash::LauncherModel* launcher_model(); |
124 | 149 |
125 // Browser window we're in. | 150 // Browser window we're in. |
126 aura::Window* window_; | 151 aura::Window* window_; |
127 | 152 |
128 TabStripModel* tab_model_; | 153 TabStripModel* tab_model_; |
129 | 154 |
130 ChromeLauncherDelegate* launcher_delegate_; | 155 ChromeLauncherDelegate* launcher_delegate_; |
131 | 156 |
132 // Whether this corresponds to an app or tabbed browser. | 157 // Whether this corresponds to an app or tabbed browser. |
133 const Type type_; | 158 const Type type_; |
134 | 159 |
135 const std::string app_id_; | 160 const std::string app_id_; |
136 | 161 |
137 // This is one of three possible values: | 162 // This is one of three possible values: |
138 // . If type_ == TYPE_APP, this is the ID of the app item. | 163 // . If type_ == TYPE_APP, this is the ID of the app item. |
139 // . If type_ == TYPE_TABBED and all the tabs are app tabs this is -1. | 164 // . If type_ == TYPE_TABBED and all the tabs are app tabs this is -1. |
140 // . Otherwise this is the id of the TYPE_TABBED item. | 165 // . Otherwise this is the id of the TYPE_TABBED item. |
141 ash::LauncherID item_id_; | 166 ash::LauncherID item_id_; |
142 | 167 |
143 // Used for any app tabs. | 168 // Used for any app tabs. |
144 AppTabMap app_map_; | 169 AppTabMap app_map_; |
145 | 170 |
146 DISALLOW_COPY_AND_ASSIGN(LauncherUpdater); | 171 DISALLOW_COPY_AND_ASSIGN(LauncherUpdater); |
147 }; | 172 }; |
148 | 173 |
149 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_ | 174 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_ |
OLD | NEW |