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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 namespace aura { | 29 namespace aura { |
30 class Window; | 30 class Window; |
31 } | 31 } |
32 | 32 |
33 // LauncherUpdater is responsible for keeping the launcher representation of a | 33 // LauncherUpdater is responsible for keeping the launcher representation of a |
34 // window up to date as the tab strip changes. | 34 // window up to date as the tab strip changes. |
35 class LauncherUpdater : public TabStripModelObserver, | 35 class LauncherUpdater : public TabStripModelObserver, |
36 public LauncherFaviconLoader::Delegate { | 36 public LauncherFaviconLoader::Delegate { |
37 public: | 37 public: |
| 38 // This API is to be used as part of testing only. |
| 39 class TestApi { |
| 40 public: |
| 41 explicit TestApi(LauncherUpdater* launcher_updater) |
| 42 : launcher_updater_(launcher_updater) {} |
| 43 virtual ~TestApi() {} |
| 44 |
| 45 // Returns the launcher id for |tab| if it's an app otherwise returns the |
| 46 // id for the browser itself. |
| 47 ash::LauncherID GetLauncherID(TabContentsWrapper* tab) { |
| 48 return launcher_updater_->GetLauncherID(tab); |
| 49 } |
| 50 |
| 51 // Returns the launcher id for the browser window. |
| 52 ash::LauncherID item_id() const { return launcher_updater_->item_id_; } |
| 53 |
| 54 private: |
| 55 LauncherUpdater* launcher_updater_; |
| 56 }; |
| 57 |
38 enum Type { | 58 enum Type { |
39 TYPE_APP, | 59 TYPE_APP, |
40 TYPE_PANEL, | 60 TYPE_PANEL, |
41 TYPE_TABBED | 61 TYPE_TABBED |
42 }; | 62 }; |
43 | 63 |
44 LauncherUpdater(aura::Window* window, | 64 LauncherUpdater(aura::Window* window, |
45 TabStripModel* tab_model, | 65 TabStripModel* tab_model, |
46 ChromeLauncherDelegate* launcher_delegate, | 66 ChromeLauncherDelegate* launcher_delegate, |
47 Type type, | 67 Type type, |
(...skipping 13 matching lines...) Expand all Loading... |
61 | 81 |
62 Type type() const { return type_; } | 82 Type type() const { return type_; } |
63 | 83 |
64 TabContentsWrapper* GetTab(ash::LauncherID id); | 84 TabContentsWrapper* GetTab(ash::LauncherID id); |
65 | 85 |
66 LauncherFaviconLoader* favicon_loader() const { | 86 LauncherFaviconLoader* favicon_loader() const { |
67 return favicon_loader_.get(); | 87 return favicon_loader_.get(); |
68 } | 88 } |
69 | 89 |
70 // TabStripModelObserver overrides: | 90 // TabStripModelObserver overrides: |
| 91 void ActivationChanged(TabContentsWrapper* tab, bool active); |
| 92 // Call to indicate that the window the tabcontents are in has changed its |
| 93 // activation state. |
| 94 void BrowserActivationStateChanged(); |
| 95 |
| 96 // TabStripModel overrides: |
71 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, | 97 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, |
72 TabContentsWrapper* new_contents, | 98 TabContentsWrapper* new_contents, |
73 int index, | 99 int index, |
74 bool user_gesture) OVERRIDE; | 100 bool user_gesture) OVERRIDE; |
75 virtual void TabChangedAt( | 101 virtual void TabChangedAt( |
76 TabContentsWrapper* tab, | 102 TabContentsWrapper* tab, |
77 int index, | 103 int index, |
78 TabStripModelObserver::TabChangeType change_type) OVERRIDE; | 104 TabStripModelObserver::TabChangeType change_type) OVERRIDE; |
79 virtual void TabInsertedAt(TabContentsWrapper* contents, | 105 virtual void TabInsertedAt(TabContentsWrapper* contents, |
80 int index, | 106 int index, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 void RegisterAppItem(ash::LauncherID id, TabContentsWrapper* tab); | 149 void RegisterAppItem(ash::LauncherID id, TabContentsWrapper* tab); |
124 | 150 |
125 // Creates a tabbed launcher item. | 151 // Creates a tabbed launcher item. |
126 void CreateTabbedItem(); | 152 void CreateTabbedItem(); |
127 | 153 |
128 // Returns true if this LauncherUpdater created the launcher item with the | 154 // Returns true if this LauncherUpdater created the launcher item with the |
129 // specified id. Returns true if it did. If the id corresponds to an app tab, | 155 // specified id. Returns true if it did. If the id corresponds to an app tab, |
130 // |tab| is set to the TabContentsWrapper for the app tab. | 156 // |tab| is set to the TabContentsWrapper for the app tab. |
131 bool ContainsID(ash::LauncherID id, TabContentsWrapper** tab); | 157 bool ContainsID(ash::LauncherID id, TabContentsWrapper** tab); |
132 | 158 |
| 159 // Returns the launcher id for |tab| if it's an app otherwise returns the |
| 160 // id for the browser itself. |
| 161 ash::LauncherID GetLauncherID(TabContentsWrapper* tab); |
| 162 |
| 163 // Retrieves the running status of |tab|. |
| 164 ash::LauncherItemStatus GetStatusForTab(TabContentsWrapper* tab); |
| 165 |
133 ash::LauncherModel* launcher_model(); | 166 ash::LauncherModel* launcher_model(); |
134 | 167 |
135 // Browser window we're in. | 168 // Browser window we're in. |
136 aura::Window* window_; | 169 aura::Window* window_; |
137 | 170 |
138 TabStripModel* tab_model_; | 171 TabStripModel* tab_model_; |
139 | 172 |
140 ChromeLauncherDelegate* launcher_delegate_; | 173 ChromeLauncherDelegate* launcher_delegate_; |
141 | 174 |
142 // Whether this corresponds to an app or tabbed browser. | 175 // Whether this corresponds to an app or tabbed browser. |
(...skipping 13 matching lines...) Expand all Loading... |
156 // Used for any app tabs. | 189 // Used for any app tabs. |
157 AppTabMap app_map_; | 190 AppTabMap app_map_; |
158 | 191 |
159 // Loads launcher sized favicons for panels. | 192 // Loads launcher sized favicons for panels. |
160 scoped_ptr<LauncherFaviconLoader> favicon_loader_; | 193 scoped_ptr<LauncherFaviconLoader> favicon_loader_; |
161 | 194 |
162 DISALLOW_COPY_AND_ASSIGN(LauncherUpdater); | 195 DISALLOW_COPY_AND_ASSIGN(LauncherUpdater); |
163 }; | 196 }; |
164 | 197 |
165 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_ | 198 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_ |
OLD | NEW |