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

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

Issue 10829268: chromeos: Sync animation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unit_tests crash + 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/extensions/extension_prefs.h" 21 #include "chrome/browser/extensions/extension_prefs.h"
21 #include "chrome/browser/extensions/shell_window_registry.h" 22 #include "chrome/browser/extensions/shell_window_registry.h"
22 #include "chrome/browser/prefs/pref_change_registrar.h" 23 #include "chrome/browser/prefs/pref_change_registrar.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 BrowserLauncherItemController; 43 class BrowserLauncherItemController;
42 class BrowserLauncherItemControllerTest; 44 class BrowserLauncherItemControllerTest;
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 tabbed 50 // ChromeLauncherController manages the launcher items needed for tabbed
48 // browsers (BrowserLauncherItemController) and browser shortcuts. 51 // browsers (BrowserLauncherItemController) and browser shortcuts.
49 class ChromeLauncherController 52 class ChromeLauncherController
50 : public ash::LauncherDelegate, 53 : public ash::LauncherDelegate,
51 public ash::LauncherModelObserver, 54 public ash::LauncherModelObserver,
52 public ash::ShellObserver, 55 public ash::ShellObserver,
53 public content::NotificationObserver, 56 public content::NotificationObserver,
54 public extensions::ShellWindowRegistry::Observer, 57 public extensions::ShellWindowRegistry::Observer,
55 public aura::client::ActivationChangeObserver, 58 public aura::client::ActivationChangeObserver,
56 public aura::WindowObserver { 59 public aura::WindowObserver,
60 public ProfileSyncServiceObserver {
57 public: 61 public:
58 // Indicates if a launcher item is incognito or not. 62 // Indicates if a launcher item is incognito or not.
59 enum IncognitoState { 63 enum IncognitoState {
60 STATE_INCOGNITO, 64 STATE_INCOGNITO,
61 STATE_NOT_INCOGNITO, 65 STATE_NOT_INCOGNITO,
62 }; 66 };
63 67
64 // Used to update the state of non plaform apps, as tab contents change. 68 // Used to update the state of non plaform apps, as tab contents change.
65 enum AppState { 69 enum AppState {
66 APP_STATE_ACTIVE, 70 APP_STATE_ACTIVE,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 virtual ui::MenuModel* CreateContextMenuForLauncher() OVERRIDE; 223 virtual ui::MenuModel* CreateContextMenuForLauncher() OVERRIDE;
220 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE; 224 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE;
221 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE; 225 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE;
222 226
223 // ash::LauncherModelObserver overrides: 227 // ash::LauncherModelObserver overrides:
224 virtual void LauncherItemAdded(int index) OVERRIDE; 228 virtual void LauncherItemAdded(int index) OVERRIDE;
225 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE; 229 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE;
226 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; 230 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE;
227 virtual void LauncherItemChanged(int index, 231 virtual void LauncherItemChanged(int index,
228 const ash::LauncherItem& old_item) OVERRIDE; 232 const ash::LauncherItem& old_item) OVERRIDE;
233 virtual void LauncherStatusChanged() OVERRIDE;
229 234
230 // Overridden from content::NotificationObserver: 235 // Overridden from content::NotificationObserver:
231 virtual void Observe(int type, 236 virtual void Observe(int type,
232 const content::NotificationSource& source, 237 const content::NotificationSource& source,
233 const content::NotificationDetails& details) OVERRIDE; 238 const content::NotificationDetails& details) OVERRIDE;
234 239
235 // Overridden from ShellWindowRegistry::Observer: 240 // Overridden from ShellWindowRegistry::Observer:
236 virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE; 241 virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE;
237 virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE; 242 virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE;
238 243
239 // Overriden from client::ActivationChangeObserver: 244 // Overridden from client::ActivationChangeObserver:
240 virtual void OnWindowActivated( 245 virtual void OnWindowActivated(
241 aura::Window* active, 246 aura::Window* active,
242 aura::Window* old_active) OVERRIDE; 247 aura::Window* old_active) OVERRIDE;
243 248
244 // Overriden from aura::WindowObserver: 249 // Overridden from aura::WindowObserver:
245 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE; 250 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE;
246 251
247 // Overriden from ash::ShellObserver: 252 // Overridden from ash::ShellObserver:
248 virtual void OnShelfAlignmentChanged() OVERRIDE; 253 virtual void OnShelfAlignmentChanged() OVERRIDE;
249 254
255 // Overridden from ProfileSyncServiceObserver:
256 virtual void OnStateChanged() OVERRIDE;
257
250 private: 258 private:
251 friend class BrowserLauncherItemControllerTest; 259 friend class BrowserLauncherItemControllerTest;
252 friend class ChromeLauncherControllerTest; 260 friend class ChromeLauncherControllerTest;
253 261
254 enum ItemType { 262 enum ItemType {
255 TYPE_APP, 263 TYPE_APP,
256 TYPE_TABBED_BROWSER 264 TYPE_TABBED_BROWSER
257 }; 265 };
258 266
259 // Used to identity an item on the launcher. 267 // Used to identity an item on the launcher.
(...skipping 23 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 BrowserLauncherItemController* controller, 321 BrowserLauncherItemController* 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 sync is completed and no pending synced extension install
327 // and calls StopLoadingAnimation when both conditions are met.
328 void CheckAppSync();
329
330 void StartLoadingAnimation();
331 void StopLoadingAnimation();
332
322 static ChromeLauncherController* instance_; 333 static ChromeLauncherController* instance_;
323 334
324 ash::LauncherModel* model_; 335 ash::LauncherModel* model_;
325 336
326 // Profile used for prefs and loading extensions. This is NOT necessarily the 337 // Profile used for prefs and loading extensions. This is NOT necessarily the
327 // profile new windows are created with. 338 // profile new windows are created with.
328 Profile* profile_; 339 Profile* profile_;
329 340
330 IDToItemMap id_to_item_map_; 341 IDToItemMap id_to_item_map_;
331 342
(...skipping 15 matching lines...) Expand all
347 scoped_ptr<AppTabHelper> app_tab_helper_; 358 scoped_ptr<AppTabHelper> app_tab_helper_;
348 359
349 // Used to load the image for an app item. 360 // Used to load the image for an app item.
350 scoped_ptr<AppIconLoader> app_icon_loader_; 361 scoped_ptr<AppIconLoader> app_icon_loader_;
351 362
352 content::NotificationRegistrar notification_registrar_; 363 content::NotificationRegistrar notification_registrar_;
353 364
354 PrefChangeRegistrar pref_change_registrar_; 365 PrefChangeRegistrar pref_change_registrar_;
355 aura::client::ActivationClient* activation_client_; 366 aura::client::ActivationClient* activation_client_;
356 367
368 ProfileSyncService* observed_sync_service_;
369 base::OneShotTimer<ChromeLauncherController> loading_timer_;
370
357 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); 371 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController);
358 }; 372 };
359 373
360 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 374 #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