Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h

Issue 10534079: Add support for managing active state of platform apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed redundant GetNativeWindow() decl in BrowserWindow Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_CHROME_LAUNCHER_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "ash/launcher/launcher_delegate.h" 12 #include "ash/launcher/launcher_delegate.h"
13 #include "ash/launcher/launcher_model_observer.h" 13 #include "ash/launcher/launcher_model_observer.h"
14 #include "ash/launcher/launcher_types.h" 14 #include "ash/launcher/launcher_types.h"
15 #include "ash/wm/shelf_auto_hide_behavior.h" 15 #include "ash/wm/shelf_auto_hide_behavior.h"
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "chrome/browser/extensions/extension_prefs.h" 19 #include "chrome/browser/extensions/extension_prefs.h"
20 #include "chrome/browser/extensions/shell_window_registry.h" 20 #include "chrome/browser/extensions/shell_window_registry.h"
21 #include "chrome/browser/prefs/pref_change_registrar.h" 21 #include "chrome/browser/prefs/pref_change_registrar.h"
22 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
24 #include "ui/aura/client/activation_change_observer.h"
25 #include "ui/aura/window_observer.h"
24 26
25 namespace ash { 27 namespace ash {
26 class LauncherModel; 28 class LauncherModel;
27 } 29 }
28 30
31 namespace aura {
32 class Window;
33
34 namespace client {
35 class ActivationClient;
36 }
37
38 }
39
29 class BrowserLauncherItemController; 40 class BrowserLauncherItemController;
30 class BrowserLauncherItemControllerTest; 41 class BrowserLauncherItemControllerTest;
31 class PrefService; 42 class PrefService;
32 class Profile; 43 class Profile;
33 class TabContents; 44 class TabContents;
34 typedef TabContents TabContentsWrapper; 45 typedef TabContents TabContentsWrapper;
35 46
36 // ChromeLauncherController manages the launcher items needed for tabbed 47 // ChromeLauncherController manages the launcher items needed for tabbed
37 // browsers (BrowserLauncherItemController) and browser shortcuts. 48 // browsers (BrowserLauncherItemController) and browser shortcuts.
38 class ChromeLauncherController : public ash::LauncherDelegate, 49 class ChromeLauncherController : public ash::LauncherDelegate,
39 public ash::LauncherModelObserver, 50 public ash::LauncherModelObserver,
40 public content::NotificationObserver, 51 public content::NotificationObserver,
41 public ShellWindowRegistry::Observer { 52 public ShellWindowRegistry::Observer,
53 public aura::client::ActivationChangeObserver,
54 public aura::WindowObserver {
42 public: 55 public:
43 // Indicates if a launcher item is incognito or not. 56 // Indicates if a launcher item is incognito or not.
44 enum IncognitoState { 57 enum IncognitoState {
45 STATE_INCOGNITO, 58 STATE_INCOGNITO,
46 STATE_NOT_INCOGNITO, 59 STATE_NOT_INCOGNITO,
47 }; 60 };
48 61
49 // Interface used to load app icons. This is in it's own class so that it can 62 // Interface used to load app icons. This is in it's own class so that it can
50 // be mocked. 63 // be mocked.
51 class AppIconLoader { 64 class AppIconLoader {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 192
180 // Overridden from content::NotificationObserver: 193 // Overridden from content::NotificationObserver:
181 virtual void Observe(int type, 194 virtual void Observe(int type,
182 const content::NotificationSource& source, 195 const content::NotificationSource& source,
183 const content::NotificationDetails& details) OVERRIDE; 196 const content::NotificationDetails& details) OVERRIDE;
184 197
185 // Overridden from ShellWindowRegistry::Observer: 198 // Overridden from ShellWindowRegistry::Observer:
186 virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE; 199 virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE;
187 virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE; 200 virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE;
188 201
202 // Overriden from client::ActivationChangeObserver:
203 virtual void OnWindowActivated(
204 aura::Window* active,
205 aura::Window* old_active) OVERRIDE;
206
207 // Overriden from aura::WindowObserver:
208 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE;
209
189 private: 210 private:
190 friend class BrowserLauncherItemControllerTest; 211 friend class BrowserLauncherItemControllerTest;
191 friend class ChromeLauncherControllerTest; 212 friend class ChromeLauncherControllerTest;
192 213
193 enum ItemType { 214 enum ItemType {
194 TYPE_APP, 215 TYPE_APP,
195 TYPE_TABBED_BROWSER 216 TYPE_TABBED_BROWSER
196 }; 217 };
197 218
198 // Used to identity an item on the launcher. 219 // Used to identity an item on the launcher.
199 struct Item { 220 struct Item {
200 Item(); 221 Item();
201 ~Item(); 222 ~Item();
202 223
203 bool is_pinned() const { return controller == NULL; } 224 bool is_pinned() const { return controller == NULL; }
204 225
205 // Type of item. 226 // Type of item.
206 ItemType item_type; 227 ItemType item_type;
207 228
208 // ID of the app. 229 // ID of the app.
209 std::string app_id; 230 std::string app_id;
210 231
211 // The BrowserLauncherItemController this item came from. NULL if a 232 // The BrowserLauncherItemController this item came from. NULL if a
212 // shortcut. 233 // shortcut.
213 BrowserLauncherItemController* controller; 234 BrowserLauncherItemController* controller;
214 }; 235 };
215 236
216 typedef std::map<ash::LauncherID, Item> IDToItemMap; 237 typedef std::map<ash::LauncherID, Item> IDToItemMap;
238 typedef std::map<aura::Window*, ash::LauncherID> WindowToIDMap;
217 239
218 // Updates the pinned pref state. The pinned state consists of a list pref. 240 // Updates the pinned pref state. The pinned state consists of a list pref.
219 // Each item of the list is a dictionary. The key |kAppIDPath| gives the 241 // Each item of the list is a dictionary. The key |kAppIDPath| gives the
220 // id of the app. 242 // id of the app.
221 void PersistPinnedState(); 243 void PersistPinnedState();
222 244
223 // Sets the AppIconLoader, taking ownership of |loader|. This is intended for 245 // Sets the AppIconLoader, taking ownership of |loader|. This is intended for
224 // testing. 246 // testing.
225 void SetAppIconLoaderForTest(AppIconLoader* loader); 247 void SetAppIconLoaderForTest(AppIconLoader* loader);
226 248
(...skipping 26 matching lines...) Expand all
253 static ChromeLauncherController* instance_; 275 static ChromeLauncherController* instance_;
254 276
255 ash::LauncherModel* model_; 277 ash::LauncherModel* model_;
256 278
257 // Profile used for prefs and loading extensions. This is NOT necessarily the 279 // Profile used for prefs and loading extensions. This is NOT necessarily the
258 // profile new windows are created with. 280 // profile new windows are created with.
259 Profile* profile_; 281 Profile* profile_;
260 282
261 IDToItemMap id_to_item_map_; 283 IDToItemMap id_to_item_map_;
262 284
285 // Allows us to get from an aura::Window to the id of a launcher item.
286 // Currently only used for platform app windows.
287 WindowToIDMap window_to_id_map_;
288
263 // Used to load the image for an app tab. 289 // Used to load the image for an app tab.
264 scoped_ptr<AppIconLoader> app_icon_loader_; 290 scoped_ptr<AppIconLoader> app_icon_loader_;
265 291
266 content::NotificationRegistrar notification_registrar_; 292 content::NotificationRegistrar notification_registrar_;
267 293
268 PrefChangeRegistrar pref_change_registrar_; 294 PrefChangeRegistrar pref_change_registrar_;
295 aura::client::ActivationClient* activation_client_;
269 296
270 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); 297 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController);
271 }; 298 };
272 299
273 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 300 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698