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

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: Use new launch_2 test platform app 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, aura::Window* old_active) OVERRIDE;
sky 2012/06/11 17:47:39 nit: each arg on its own line.
DaveMoore 2012/06/11 18:13:40 Done.
205
206 // Overriden from aura::WindowObserver:
207 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE;
208
189 private: 209 private:
190 friend class BrowserLauncherItemControllerTest; 210 friend class BrowserLauncherItemControllerTest;
191 friend class ChromeLauncherControllerTest; 211 friend class ChromeLauncherControllerTest;
192 212
193 enum ItemType { 213 enum ItemType {
194 TYPE_APP, 214 TYPE_APP,
195 TYPE_TABBED_BROWSER 215 TYPE_TABBED_BROWSER
196 }; 216 };
197 217
198 // Used to identity an item on the launcher. 218 // Used to identity an item on the launcher.
199 struct Item { 219 struct Item {
200 Item(); 220 Item();
201 ~Item(); 221 ~Item();
202 222
203 bool is_pinned() const { return controller == NULL; } 223 bool is_pinned() const { return controller == NULL; }
204 224
205 // Type of item. 225 // Type of item.
206 ItemType item_type; 226 ItemType item_type;
207 227
208 // ID of the app. 228 // ID of the app.
209 std::string app_id; 229 std::string app_id;
210 230
211 // The BrowserLauncherItemController this item came from. NULL if a 231 // The BrowserLauncherItemController this item came from. NULL if a
212 // shortcut. 232 // shortcut.
213 BrowserLauncherItemController* controller; 233 BrowserLauncherItemController* controller;
214 }; 234 };
215 235
216 typedef std::map<ash::LauncherID, Item> IDToItemMap; 236 typedef std::map<ash::LauncherID, Item> IDToItemMap;
237 typedef std::map<aura::Window*, ash::LauncherID> WindowToIDMap;
217 238
218 // Updates the pinned pref state. The pinned state consists of a list pref. 239 // 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 240 // Each item of the list is a dictionary. The key |kAppIDPath| gives the
220 // id of the app. 241 // id of the app.
221 void PersistPinnedState(); 242 void PersistPinnedState();
222 243
223 // Sets the AppIconLoader, taking ownership of |loader|. This is intended for 244 // Sets the AppIconLoader, taking ownership of |loader|. This is intended for
224 // testing. 245 // testing.
225 void SetAppIconLoaderForTest(AppIconLoader* loader); 246 void SetAppIconLoaderForTest(AppIconLoader* loader);
226 247
(...skipping 25 matching lines...) Expand all
252 273
253 static ChromeLauncherController* instance_; 274 static ChromeLauncherController* instance_;
254 275
255 ash::LauncherModel* model_; 276 ash::LauncherModel* model_;
256 277
257 // Profile used for prefs and loading extensions. This is NOT necessarily the 278 // Profile used for prefs and loading extensions. This is NOT necessarily the
258 // profile new windows are created with. 279 // profile new windows are created with.
259 Profile* profile_; 280 Profile* profile_;
260 281
261 IDToItemMap id_to_item_map_; 282 IDToItemMap id_to_item_map_;
283 WindowToIDMap window_to_id_map_;
sky 2012/06/11 17:47:39 Add a description for this. Especially mention its
DaveMoore 2012/06/11 18:13:40 Done.
262 284
263 // Used to load the image for an app tab. 285 // Used to load the image for an app tab.
264 scoped_ptr<AppIconLoader> app_icon_loader_; 286 scoped_ptr<AppIconLoader> app_icon_loader_;
265 287
266 content::NotificationRegistrar notification_registrar_; 288 content::NotificationRegistrar notification_registrar_;
267 289
268 PrefChangeRegistrar pref_change_registrar_; 290 PrefChangeRegistrar pref_change_registrar_;
291 aura::client::ActivationClient* activation_client_;
269 292
270 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); 293 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController);
271 }; 294 };
272 295
273 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 296 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698