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

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

Issue 10860053: Reland 152221 - chromeos: Sync animation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 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_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
7 7
8 #include <list> 8 #include <list>
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/shell_observer.h" 15 #include "ash/shell_observer.h"
16 #include "ash/wm/shelf_types.h" 16 #include "ash/wm/shelf_types.h"
17 #include "base/basictypes.h" 17 #include "base/basictypes.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
20 #include "base/timer.h"
20 #include "chrome/browser/api/prefs/pref_change_registrar.h" 21 #include "chrome/browser/api/prefs/pref_change_registrar.h"
21 #include "chrome/browser/extensions/extension_prefs.h" 22 #include "chrome/browser/extensions/extension_prefs.h"
22 #include "chrome/browser/extensions/shell_window_registry.h" 23 #include "chrome/browser/extensions/shell_window_registry.h"
24 #include "chrome/browser/sync/profile_sync_service_observer.h"
23 #include "content/public/browser/notification_observer.h" 25 #include "content/public/browser/notification_observer.h"
24 #include "content/public/browser/notification_registrar.h" 26 #include "content/public/browser/notification_registrar.h"
25 #include "ui/aura/client/activation_change_observer.h" 27 #include "ui/aura/client/activation_change_observer.h"
26 #include "ui/aura/window_observer.h" 28 #include "ui/aura/window_observer.h"
27 29
28 namespace ash { 30 namespace ash {
29 class LauncherModel; 31 class LauncherModel;
30 } 32 }
31 33
32 namespace aura { 34 namespace aura {
33 class Window; 35 class Window;
34 36
35 namespace client { 37 namespace client {
36 class ActivationClient; 38 class ActivationClient;
37 } 39 }
38 40
39 } 41 }
40 42
41 class BrowserLauncherItemControllerTest; 43 class BrowserLauncherItemControllerTest;
42 class LauncherItemController; 44 class LauncherItemController;
43 class PrefService; 45 class PrefService;
44 class Profile; 46 class Profile;
47 class ProfileSyncService;
45 class TabContents; 48 class TabContents;
46 49
47 // ChromeLauncherController manages the launcher items needed for content 50 // ChromeLauncherController manages the launcher items needed for content
48 // windows: tabbed browsers (BrowserLauncherItemController), browser shortcuts, 51 // windows: tabbed browsers (BrowserLauncherItemController), browser shortcuts,
49 // and App windows. 52 // and App windows.
50 class ChromeLauncherController 53 class ChromeLauncherController
51 : public ash::LauncherDelegate, 54 : public ash::LauncherDelegate,
52 public ash::LauncherModelObserver, 55 public ash::LauncherModelObserver,
53 public ash::ShellObserver, 56 public ash::ShellObserver,
54 public content::NotificationObserver, 57 public content::NotificationObserver,
55 public extensions::ShellWindowRegistry::Observer, 58 public extensions::ShellWindowRegistry::Observer,
56 public aura::client::ActivationChangeObserver, 59 public aura::client::ActivationChangeObserver,
57 public aura::WindowObserver { 60 public aura::WindowObserver,
61 public ProfileSyncServiceObserver {
58 public: 62 public:
59 // Indicates if a launcher item is incognito or not. 63 // Indicates if a launcher item is incognito or not.
60 enum IncognitoState { 64 enum IncognitoState {
61 STATE_INCOGNITO, 65 STATE_INCOGNITO,
62 STATE_NOT_INCOGNITO, 66 STATE_NOT_INCOGNITO,
63 }; 67 };
64 68
65 // Used to update the state of non plaform apps, as tab contents change. 69 // Used to update the state of non plaform apps, as tab contents change.
66 enum AppState { 70 enum AppState {
67 APP_STATE_ACTIVE, 71 APP_STATE_ACTIVE,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 virtual ui::MenuModel* CreateContextMenuForLauncher() OVERRIDE; 224 virtual ui::MenuModel* CreateContextMenuForLauncher() OVERRIDE;
221 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE; 225 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE;
222 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE; 226 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE;
223 227
224 // ash::LauncherModelObserver overrides: 228 // ash::LauncherModelObserver overrides:
225 virtual void LauncherItemAdded(int index) OVERRIDE; 229 virtual void LauncherItemAdded(int index) OVERRIDE;
226 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE; 230 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE;
227 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; 231 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE;
228 virtual void LauncherItemChanged(int index, 232 virtual void LauncherItemChanged(int index,
229 const ash::LauncherItem& old_item) OVERRIDE; 233 const ash::LauncherItem& old_item) OVERRIDE;
234 virtual void LauncherStatusChanged() OVERRIDE;
230 235
231 // Overridden from content::NotificationObserver: 236 // Overridden from content::NotificationObserver:
232 virtual void Observe(int type, 237 virtual void Observe(int type,
233 const content::NotificationSource& source, 238 const content::NotificationSource& source,
234 const content::NotificationDetails& details) OVERRIDE; 239 const content::NotificationDetails& details) OVERRIDE;
235 240
236 // Overridden from ShellWindowRegistry::Observer: 241 // Overridden from ShellWindowRegistry::Observer:
237 virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE; 242 virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE;
238 virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE; 243 virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE;
239 244
240 // Overriden from client::ActivationChangeObserver: 245 // Overridden from client::ActivationChangeObserver:
241 virtual void OnWindowActivated( 246 virtual void OnWindowActivated(
242 aura::Window* active, 247 aura::Window* active,
243 aura::Window* old_active) OVERRIDE; 248 aura::Window* old_active) OVERRIDE;
244 249
245 // Overriden from aura::WindowObserver: 250 // Overridden from aura::WindowObserver:
246 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE; 251 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE;
247 252
248 // Overriden from ash::ShellObserver: 253 // Overridden from ash::ShellObserver:
249 virtual void OnShelfAlignmentChanged() OVERRIDE; 254 virtual void OnShelfAlignmentChanged() OVERRIDE;
250 255
256 // Overridden from ProfileSyncServiceObserver:
257 virtual void OnStateChanged() OVERRIDE;
258
251 private: 259 private:
252 friend class BrowserLauncherItemControllerTest; 260 friend class BrowserLauncherItemControllerTest;
253 friend class ChromeLauncherControllerTest; 261 friend class ChromeLauncherControllerTest;
254 262
255 enum ItemType { 263 enum ItemType {
256 TYPE_APP, 264 TYPE_APP,
257 TYPE_TABBED_BROWSER 265 TYPE_TABBED_BROWSER
258 }; 266 };
259 267
260 // Used to identity an item on the launcher. 268 // Used to identity an item on the launcher.
(...skipping 22 matching lines...) Expand all
283 // These are intended for testing. 291 // These are intended for testing.
284 void SetAppTabHelperForTest(AppTabHelper* helper); 292 void SetAppTabHelperForTest(AppTabHelper* helper);
285 void SetAppIconLoaderForTest(AppIconLoader* loader); 293 void SetAppIconLoaderForTest(AppIconLoader* loader);
286 294
287 // Returns the profile used for new windows. 295 // Returns the profile used for new windows.
288 Profile* GetProfileForNewWindows(); 296 Profile* GetProfileForNewWindows();
289 297
290 // Returns item status for given |id|. 298 // Returns item status for given |id|.
291 ash::LauncherItemStatus GetItemStatus(ash::LauncherID id) const; 299 ash::LauncherItemStatus GetItemStatus(ash::LauncherID id) const;
292 300
293 // Finds the launcher item that represents given |app_id| and updates the
294 // pending state.
295 void MarkAppPending(const std::string& app_id);
296
297 // Internal helpers for pinning and unpinning that handle both 301 // Internal helpers for pinning and unpinning that handle both
298 // client-triggered and internal pinning operations. 302 // client-triggered and internal pinning operations.
299 void DoPinAppWithID(const std::string& app_id); 303 void DoPinAppWithID(const std::string& app_id);
300 void DoUnpinAppsWithID(const std::string& app_id); 304 void DoUnpinAppsWithID(const std::string& app_id);
301 305
302 // Re-syncs launcher model with prefs::kPinnedLauncherApps. 306 // Re-syncs launcher model with prefs::kPinnedLauncherApps.
303 void UpdateAppLaunchersFromPref(); 307 void UpdateAppLaunchersFromPref();
304 308
305 // Sets the shelf auto-hide behavior from prefs. 309 // Sets the shelf auto-hide behavior from prefs.
306 void SetShelfAutoHideBehaviorFromPrefs(); 310 void SetShelfAutoHideBehaviorFromPrefs();
307 311
308 // Sets the shelf alignment from prefs. 312 // Sets the shelf alignment from prefs.
309 void SetShelfAlignmentFromPrefs(); 313 void SetShelfAlignmentFromPrefs();
310 314
311 // Returns the most recently active tab contents for an app. 315 // Returns the most recently active tab contents for an app.
312 TabContents* GetLastActiveTabContents(const std::string& app_id); 316 TabContents* GetLastActiveTabContents(const std::string& app_id);
313 317
314 // Creates an app launcher to insert at |index|. Note that |index| may be 318 // Creates an app launcher to insert at |index|. Note that |index| may be
315 // adjusted by the model to meet ordering constraints. 319 // adjusted by the model to meet ordering constraints.
316 ash::LauncherID InsertAppLauncherItem( 320 ash::LauncherID InsertAppLauncherItem(
317 LauncherItemController* controller, 321 LauncherItemController* controller,
318 const std::string& app_id, 322 const std::string& app_id,
319 ash::LauncherItemStatus status, 323 ash::LauncherItemStatus status,
320 int index); 324 int index);
321 325
326 // Checks whether app sync status and starts/stops loading animation
327 // accordingly. If sync has not setup, do nothing. If sync is completed and
328 // there is no pending synced extension install, call StopLoadingAnimation.
329 // Otherwise, call StartLoadingAnimation.
330 void CheckAppSync();
331
332 void StartLoadingAnimation();
333 void StopLoadingAnimation();
334
322 static ChromeLauncherController* instance_; 335 static ChromeLauncherController* instance_;
323 336
324 ash::LauncherModel* model_; 337 ash::LauncherModel* model_;
325 338
326 // Profile used for prefs and loading extensions. This is NOT necessarily the 339 // Profile used for prefs and loading extensions. This is NOT necessarily the
327 // profile new windows are created with. 340 // profile new windows are created with.
328 Profile* profile_; 341 Profile* profile_;
329 342
330 IDToItemMap id_to_item_map_; 343 IDToItemMap id_to_item_map_;
331 344
(...skipping 15 matching lines...) Expand all
347 scoped_ptr<AppTabHelper> app_tab_helper_; 360 scoped_ptr<AppTabHelper> app_tab_helper_;
348 361
349 // Used to load the image for an app item. 362 // Used to load the image for an app item.
350 scoped_ptr<AppIconLoader> app_icon_loader_; 363 scoped_ptr<AppIconLoader> app_icon_loader_;
351 364
352 content::NotificationRegistrar notification_registrar_; 365 content::NotificationRegistrar notification_registrar_;
353 366
354 PrefChangeRegistrar pref_change_registrar_; 367 PrefChangeRegistrar pref_change_registrar_;
355 aura::client::ActivationClient* activation_client_; 368 aura::client::ActivationClient* activation_client_;
356 369
370 ProfileSyncService* observed_sync_service_;
371 base::OneShotTimer<ChromeLauncherController> loading_timer_;
372
357 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); 373 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController);
358 }; 374 };
359 375
360 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 376 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/pending_extension_manager.cc ('k') | chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698