| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <set> | |
| 11 #include <string> | 10 #include <string> |
| 12 #include <vector> | 11 #include <vector> |
| 13 | 12 |
| 14 #include "ash/display/window_tree_host_manager.h" | 13 #include "ash/display/window_tree_host_manager.h" |
| 15 #include "ash/shelf/shelf_delegate.h" | 14 #include "ash/shelf/shelf_delegate.h" |
| 16 #include "ash/shelf/shelf_item_delegate.h" | 15 #include "ash/shelf/shelf_item_delegate.h" |
| 17 #include "ash/shelf/shelf_item_delegate_manager.h" | 16 #include "ash/shelf/shelf_item_delegate_manager.h" |
| 18 #include "ash/shelf/shelf_item_types.h" | 17 #include "ash/shelf/shelf_item_types.h" |
| 19 #include "ash/shelf/shelf_layout_manager_observer.h" | |
| 20 #include "ash/shelf/shelf_model_observer.h" | 18 #include "ash/shelf/shelf_model_observer.h" |
| 21 #include "ash/shelf/shelf_types.h" | 19 #include "ash/shelf/shelf_types.h" |
| 22 #include "ash/shell_observer.h" | |
| 23 #include "base/compiler_specific.h" | 20 #include "base/compiler_specific.h" |
| 24 #include "base/macros.h" | 21 #include "base/macros.h" |
| 25 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 26 #include "base/memory/scoped_vector.h" | 23 #include "base/memory/scoped_vector.h" |
| 27 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 28 #include "chrome/browser/ui/app_icon_loader.h" | 25 #include "chrome/browser/ui/app_icon_loader.h" |
| 29 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" | 26 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" |
| 30 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 27 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| 31 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" | 28 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" |
| 32 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h" | 29 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // windows. Launcher items have a type, an optional app id, and a controller. | 77 // windows. Launcher items have a type, an optional app id, and a controller. |
| 81 // This incarnation groups running tabs/windows in application specific lists. | 78 // This incarnation groups running tabs/windows in application specific lists. |
| 82 // * Browser app windows have BrowserLauncherItemController, owned by the | 79 // * Browser app windows have BrowserLauncherItemController, owned by the |
| 83 // BrowserView instance. | 80 // BrowserView instance. |
| 84 // * App windows have AppWindowLauncherItemController, owned by | 81 // * App windows have AppWindowLauncherItemController, owned by |
| 85 // AppWindowLauncherController. | 82 // AppWindowLauncherController. |
| 86 // * Shortcuts have no LauncherItemController. | 83 // * Shortcuts have no LauncherItemController. |
| 87 class ChromeLauncherController | 84 class ChromeLauncherController |
| 88 : public ash::ShelfDelegate, | 85 : public ash::ShelfDelegate, |
| 89 public ash::ShelfModelObserver, | 86 public ash::ShelfModelObserver, |
| 90 public ash::ShellObserver, | |
| 91 public ash::WindowTreeHostManager::Observer, | 87 public ash::WindowTreeHostManager::Observer, |
| 92 public AppIconLoaderDelegate, | 88 public AppIconLoaderDelegate, |
| 93 public syncable_prefs::PrefServiceSyncableObserver, | 89 public syncable_prefs::PrefServiceSyncableObserver, |
| 94 public AppSyncUIStateObserver, | 90 public AppSyncUIStateObserver, |
| 95 public ExtensionEnableFlowDelegate, | 91 public ExtensionEnableFlowDelegate, |
| 96 public LauncherAppUpdater::Delegate, | 92 public LauncherAppUpdater::Delegate, |
| 97 public ash::ShelfLayoutManagerObserver, | |
| 98 public ash::ShelfItemDelegateManagerObserver { | 93 public ash::ShelfItemDelegateManagerObserver { |
| 99 public: | 94 public: |
| 100 // Indicates if a shelf item is incognito or not. | 95 // Indicates if a shelf item is incognito or not. |
| 101 enum IncognitoState { | 96 enum IncognitoState { |
| 102 STATE_INCOGNITO, | 97 STATE_INCOGNITO, |
| 103 STATE_NOT_INCOGNITO, | 98 STATE_NOT_INCOGNITO, |
| 104 }; | 99 }; |
| 105 | 100 |
| 106 // Used to update the state of non plaform apps, as web contents change. | 101 // Used to update the state of non plaform apps, as web contents change. |
| 107 enum AppState { | 102 enum AppState { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // it, the the window will get minimized instead. | 263 // it, the the window will get minimized instead. |
| 269 // Returns the action performed. Should be one of kNoAction, | 264 // Returns the action performed. Should be one of kNoAction, |
| 270 // kExistingWindowActivated, or kExistingWindowMinimized. | 265 // kExistingWindowActivated, or kExistingWindowMinimized. |
| 271 ash::ShelfItemDelegate::PerformedAction ActivateWindowOrMinimizeIfActive( | 266 ash::ShelfItemDelegate::PerformedAction ActivateWindowOrMinimizeIfActive( |
| 272 ui::BaseWindow* window, | 267 ui::BaseWindow* window, |
| 273 bool allow_minimize); | 268 bool allow_minimize); |
| 274 | 269 |
| 275 // ash::ShelfDelegate: | 270 // ash::ShelfDelegate: |
| 276 void OnShelfCreated(ash::Shelf* shelf) override; | 271 void OnShelfCreated(ash::Shelf* shelf) override; |
| 277 void OnShelfDestroyed(ash::Shelf* shelf) override; | 272 void OnShelfDestroyed(ash::Shelf* shelf) override; |
| 273 void OnShelfAlignmentChanged(ash::Shelf* shelf) override; |
| 274 void OnShelfAutoHideBehaviorChanged(ash::Shelf* shelf) override; |
| 278 ash::ShelfID GetShelfIDForAppID(const std::string& app_id) override; | 275 ash::ShelfID GetShelfIDForAppID(const std::string& app_id) override; |
| 279 bool HasShelfIDToAppIDMapping(ash::ShelfID id) const override; | 276 bool HasShelfIDToAppIDMapping(ash::ShelfID id) const override; |
| 280 const std::string& GetAppIDForShelfID(ash::ShelfID id) override; | 277 const std::string& GetAppIDForShelfID(ash::ShelfID id) override; |
| 281 bool GetAppIDForShelfIDConst(ash::ShelfID id, std::string* app_id) const; | 278 bool GetAppIDForShelfIDConst(ash::ShelfID id, std::string* app_id) const; |
| 282 void PinAppWithID(const std::string& app_id) override; | 279 void PinAppWithID(const std::string& app_id) override; |
| 283 bool IsAppPinned(const std::string& app_id) override; | 280 bool IsAppPinned(const std::string& app_id) override; |
| 284 void UnpinAppWithID(const std::string& app_id) override; | 281 void UnpinAppWithID(const std::string& app_id) override; |
| 285 | 282 |
| 286 // ash::ShelfItemDelegateManagerObserver: | 283 // ash::ShelfItemDelegateManagerObserver: |
| 287 void OnSetShelfItemDelegate(ash::ShelfID id, | 284 void OnSetShelfItemDelegate(ash::ShelfID id, |
| 288 ash::ShelfItemDelegate* item_delegate) override; | 285 ash::ShelfItemDelegate* item_delegate) override; |
| 289 | 286 |
| 290 // ash::ShelfModelObserver: | 287 // ash::ShelfModelObserver: |
| 291 void ShelfItemAdded(int index) override; | 288 void ShelfItemAdded(int index) override; |
| 292 void ShelfItemRemoved(int index, ash::ShelfID id) override; | 289 void ShelfItemRemoved(int index, ash::ShelfID id) override; |
| 293 void ShelfItemMoved(int start_index, int target_index) override; | 290 void ShelfItemMoved(int start_index, int target_index) override; |
| 294 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override; | 291 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override; |
| 295 | 292 |
| 296 // ash::ShellObserver: | |
| 297 void OnShelfAlignmentChanged(aura::Window* root_window) override; | |
| 298 | |
| 299 // ash::WindowTreeHostManager::Observer: | 293 // ash::WindowTreeHostManager::Observer: |
| 300 void OnDisplayConfigurationChanged() override; | 294 void OnDisplayConfigurationChanged() override; |
| 301 | 295 |
| 302 // LauncherAppUpdater: | 296 // LauncherAppUpdater: |
| 303 void OnAppInstalled(content::BrowserContext* browser_context, | 297 void OnAppInstalled(content::BrowserContext* browser_context, |
| 304 const std::string& app_id) override; | 298 const std::string& app_id) override; |
| 305 void OnAppUpdated(content::BrowserContext* browser_context, | 299 void OnAppUpdated(content::BrowserContext* browser_context, |
| 306 const std::string& app_id) override; | 300 const std::string& app_id) override; |
| 307 void OnAppUninstalled(content::BrowserContext* browser_context, | 301 void OnAppUninstalled(content::BrowserContext* browser_context, |
| 308 const std::string& app_id) override; | 302 const std::string& app_id) override; |
| 309 | 303 |
| 310 // syncable_prefs::PrefServiceSyncableObserver: | 304 // syncable_prefs::PrefServiceSyncableObserver: |
| 311 void OnIsSyncingChanged() override; | 305 void OnIsSyncingChanged() override; |
| 312 | 306 |
| 313 // AppSyncUIStateObserver: | 307 // AppSyncUIStateObserver: |
| 314 void OnAppSyncUIStatusChanged() override; | 308 void OnAppSyncUIStatusChanged() override; |
| 315 | 309 |
| 316 // ExtensionEnableFlowDelegate: | 310 // ExtensionEnableFlowDelegate: |
| 317 void ExtensionEnableFlowFinished() override; | 311 void ExtensionEnableFlowFinished() override; |
| 318 void ExtensionEnableFlowAborted(bool user_initiated) override; | 312 void ExtensionEnableFlowAborted(bool user_initiated) override; |
| 319 | 313 |
| 320 // AppIconLoaderDelegate: | 314 // AppIconLoaderDelegate: |
| 321 void OnAppImageUpdated(const std::string& app_id, | 315 void OnAppImageUpdated(const std::string& app_id, |
| 322 const gfx::ImageSkia& image) override; | 316 const gfx::ImageSkia& image) override; |
| 323 | 317 |
| 324 // ash::ShelfLayoutManagerObserver: | |
| 325 void OnAutoHideBehaviorChanged( | |
| 326 aura::Window* root_window, | |
| 327 ash::ShelfAutoHideBehavior new_behavior) override; | |
| 328 | |
| 329 // Called when the active user has changed. | 318 // Called when the active user has changed. |
| 330 void ActiveUserChanged(const std::string& user_email); | 319 void ActiveUserChanged(const std::string& user_email); |
| 331 | 320 |
| 332 // Called when a user got added to the session. | 321 // Called when a user got added to the session. |
| 333 void AdditionalUserAddedToSession(Profile* profile); | 322 void AdditionalUserAddedToSession(Profile* profile); |
| 334 | 323 |
| 335 // Get the list of all running incarnations of this item. | 324 // Get the list of all running incarnations of this item. |
| 336 // |event_flags| specifies the flags which were set by the event which | 325 // |event_flags| specifies the flags which were set by the event which |
| 337 // triggered this menu generation. It can be used to generate different lists. | 326 // triggered this menu generation. It can be used to generate different lists. |
| 338 ChromeLauncherAppMenuItems GetApplicationList(const ash::ShelfItem& item, | 327 ChromeLauncherAppMenuItems GetApplicationList(const ash::ShelfItem& item, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 int PinRunningAppInternal(int index, ash::ShelfID shelf_id); | 435 int PinRunningAppInternal(int index, ash::ShelfID shelf_id); |
| 447 | 436 |
| 448 // Unpin a locked application. This is an internal call which converts the | 437 // Unpin a locked application. This is an internal call which converts the |
| 449 // model type of the given app index from a shortcut into an unpinned running | 438 // model type of the given app index from a shortcut into an unpinned running |
| 450 // app. | 439 // app. |
| 451 void UnpinRunningAppInternal(int index); | 440 void UnpinRunningAppInternal(int index); |
| 452 | 441 |
| 453 // Re-syncs shelf model with prefs::kPinnedLauncherApps. | 442 // Re-syncs shelf model with prefs::kPinnedLauncherApps. |
| 454 void UpdateAppLaunchersFromPref(); | 443 void UpdateAppLaunchersFromPref(); |
| 455 | 444 |
| 456 // Persists the shelf auto-hide behavior to prefs. | |
| 457 void SetShelfAutoHideBehaviorPrefs(ash::ShelfAutoHideBehavior behavior, | |
| 458 aura::Window* root_window); | |
| 459 | |
| 460 // Sets the shelf auto-hide behavior from prefs. | 445 // Sets the shelf auto-hide behavior from prefs. |
| 461 void SetShelfAutoHideBehaviorFromPrefs(); | 446 void SetShelfAutoHideBehaviorFromPrefs(); |
| 462 | 447 |
| 463 // Sets the shelf alignment from prefs. | 448 // Sets the shelf alignment from prefs. |
| 464 void SetShelfAlignmentFromPrefs(); | 449 void SetShelfAlignmentFromPrefs(); |
| 465 | 450 |
| 466 // Sets both of auto-hide behavior and alignment from prefs. | 451 // Sets both of auto-hide behavior and alignment from prefs. |
| 467 void SetShelfBehaviorsFromPrefs(); | 452 void SetShelfBehaviorsFromPrefs(); |
| 468 | 453 |
| 469 #if defined(OS_CHROMEOS) | 454 #if defined(OS_CHROMEOS) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 | 553 |
| 569 // Used to handle app load/unload events. | 554 // Used to handle app load/unload events. |
| 570 std::vector<scoped_ptr<LauncherAppUpdater>> app_updaters_; | 555 std::vector<scoped_ptr<LauncherAppUpdater>> app_updaters_; |
| 571 | 556 |
| 572 PrefChangeRegistrar pref_change_registrar_; | 557 PrefChangeRegistrar pref_change_registrar_; |
| 573 | 558 |
| 574 AppSyncUIState* app_sync_ui_state_; | 559 AppSyncUIState* app_sync_ui_state_; |
| 575 | 560 |
| 576 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; | 561 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; |
| 577 | 562 |
| 578 // Shelves that are currently being observed. | |
| 579 std::set<ash::Shelf*> shelves_; | |
| 580 | |
| 581 // The owned browser status monitor. | 563 // The owned browser status monitor. |
| 582 scoped_ptr<BrowserStatusMonitor> browser_status_monitor_; | 564 scoped_ptr<BrowserStatusMonitor> browser_status_monitor_; |
| 583 | 565 |
| 584 #if defined(OS_CHROMEOS) | 566 #if defined(OS_CHROMEOS) |
| 585 // A special observer class to detect user switches. | 567 // A special observer class to detect user switches. |
| 586 scoped_ptr<ChromeLauncherControllerUserSwitchObserver> user_switch_observer_; | 568 scoped_ptr<ChromeLauncherControllerUserSwitchObserver> user_switch_observer_; |
| 587 #endif | 569 #endif |
| 588 | 570 |
| 589 // If true, incoming pinned state changes should be ignored. | 571 // If true, incoming pinned state changes should be ignored. |
| 590 bool ignore_persist_pinned_state_change_; | 572 bool ignore_persist_pinned_state_change_; |
| 591 | 573 |
| 592 // The list of running & un-pinned applications for different users on hidden | 574 // The list of running & un-pinned applications for different users on hidden |
| 593 // desktops. | 575 // desktops. |
| 594 typedef std::vector<std::string> RunningAppListIds; | 576 typedef std::vector<std::string> RunningAppListIds; |
| 595 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap; | 577 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap; |
| 596 RunningAppListIdMap last_used_running_application_order_; | 578 RunningAppListIdMap last_used_running_application_order_; |
| 597 | 579 |
| 598 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); | 580 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); |
| 599 }; | 581 }; |
| 600 | 582 |
| 601 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ | 583 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ |
| OLD | NEW |