| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/display/window_tree_host_manager.h" | 12 #include "ash/display/window_tree_host_manager.h" |
| 13 #include "ash/public/cpp/shelf_item_delegate.h" | 13 #include "ash/public/cpp/shelf_item_delegate.h" |
| 14 #include "ash/public/cpp/shelf_types.h" | 14 #include "ash/public/cpp/shelf_types.h" |
| 15 #include "ash/public/interfaces/shelf.mojom.h" | 15 #include "ash/public/interfaces/shelf.mojom.h" |
| 16 #include "ash/shelf/shelf_model_observer.h" | 16 #include "ash/shelf/shelf_model_observer.h" |
| 17 #include "base/auto_reset.h" | 17 #include "base/auto_reset.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "chrome/browser/ui/app_icon_loader_delegate.h" | 20 #include "chrome/browser/ui/app_icon_loader_delegate.h" |
| 21 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 21 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| 22 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" | 22 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" |
| 23 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 23 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| 24 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h" | 24 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h" |
| 25 #include "chrome/browser/ui/ash/launcher/settings_window_observer.h" | 25 #include "chrome/browser/ui/ash/launcher/settings_window_observer.h" |
| 26 #include "components/prefs/pref_change_registrar.h" | 26 #include "components/prefs/pref_change_registrar.h" |
| 27 #include "components/sync_preferences/pref_service_syncable_observer.h" | 27 #include "components/sync_preferences/pref_service_syncable_observer.h" |
| 28 #include "mojo/public/cpp/bindings/associated_binding.h" | 28 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 29 #include "mojo/public/cpp/bindings/binding.h" |
| 30 #include "mojo/public/cpp/bindings/interface_ptr_set.h" |
| 29 | 31 |
| 30 class AccountId; | 32 class AccountId; |
| 31 class AppIconLoader; | 33 class AppIconLoader; |
| 32 class AppSyncUIState; | 34 class AppSyncUIState; |
| 33 class AppWindowLauncherController; | 35 class AppWindowLauncherController; |
| 34 class ArcAppDeferredLauncherController; | 36 class ArcAppDeferredLauncherController; |
| 35 class BrowserShortcutLauncherItemController; | 37 class BrowserShortcutLauncherItemController; |
| 36 class BrowserStatusMonitor; | 38 class BrowserStatusMonitor; |
| 37 class ChromeLauncherControllerUserSwitchObserver; | 39 class ChromeLauncherControllerUserSwitchObserver; |
| 38 class ChromeLauncherPrefsObserver; | 40 class ChromeLauncherPrefsObserver; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 58 class BaseWindow; | 60 class BaseWindow; |
| 59 } | 61 } |
| 60 | 62 |
| 61 // ChromeLauncherController helps manage Ash's shelf for Chrome prefs and apps. | 63 // ChromeLauncherController helps manage Ash's shelf for Chrome prefs and apps. |
| 62 // It helps synchronize shelf state with profile preferences and app content. | 64 // It helps synchronize shelf state with profile preferences and app content. |
| 63 // NOTE: Launcher is an old name for the shelf, this class should be renamed. | 65 // NOTE: Launcher is an old name for the shelf, this class should be renamed. |
| 64 class ChromeLauncherController | 66 class ChromeLauncherController |
| 65 : public LauncherAppUpdater::Delegate, | 67 : public LauncherAppUpdater::Delegate, |
| 66 public AppIconLoaderDelegate, | 68 public AppIconLoaderDelegate, |
| 67 private ash::mojom::ShelfObserver, | 69 private ash::mojom::ShelfObserver, |
| 70 private ash::mojom::ShelfModelObserver, |
| 68 private ash::ShelfModelObserver, | 71 private ash::ShelfModelObserver, |
| 69 private ash::WindowTreeHostManager::Observer, | 72 private ash::WindowTreeHostManager::Observer, |
| 70 private AppSyncUIStateObserver, | 73 private AppSyncUIStateObserver, |
| 71 private app_list::AppListSyncableService::Observer, | 74 private app_list::AppListSyncableService::Observer, |
| 72 private sync_preferences::PrefServiceSyncableObserver { | 75 private sync_preferences::PrefServiceSyncableObserver { |
| 73 public: | 76 public: |
| 74 // Used to update the state of non plaform apps, as web contents change. | 77 // Used to update the state of non plaform apps, as web contents change. |
| 75 enum AppState { | 78 enum AppState { |
| 76 APP_STATE_ACTIVE, | 79 APP_STATE_ACTIVE, |
| 77 APP_STATE_WINDOW_ACTIVE, | 80 APP_STATE_WINDOW_ACTIVE, |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 // deleted. | 349 // deleted. |
| 347 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id, | 350 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id, |
| 348 const Profile* profile); | 351 const Profile* profile); |
| 349 | 352 |
| 350 // Attach to a specific profile. | 353 // Attach to a specific profile. |
| 351 void AttachProfile(Profile* profile_to_attach); | 354 void AttachProfile(Profile* profile_to_attach); |
| 352 | 355 |
| 353 // Forget the current profile to allow attaching to a new one. | 356 // Forget the current profile to allow attaching to a new one. |
| 354 void ReleaseProfile(); | 357 void ReleaseProfile(); |
| 355 | 358 |
| 359 // Add an observer for the local ShelfModel. Called by ash::ShelfController as |
| 360 // a callback to establish two-way synchronization of ShelfModel state. |
| 361 void LinkShelfModels(ash::mojom::ShelfModelObserverPtr observer, |
| 362 const std::vector<ash::ShelfItem>& items); |
| 363 |
| 356 // ash::mojom::ShelfObserver: | 364 // ash::mojom::ShelfObserver: |
| 357 void OnShelfInitialized(int64_t display_id) override; | 365 void OnShelfInitialized(int64_t display_id) override; |
| 358 void OnAlignmentChanged(ash::ShelfAlignment alignment, | 366 void OnAlignmentChanged(ash::ShelfAlignment alignment, |
| 359 int64_t display_id) override; | 367 int64_t display_id) override; |
| 360 void OnAutoHideBehaviorChanged(ash::ShelfAutoHideBehavior auto_hide, | 368 void OnAutoHideBehaviorChanged(ash::ShelfAutoHideBehavior auto_hide, |
| 361 int64_t display_id) override; | 369 int64_t display_id) override; |
| 362 | 370 |
| 371 // ash::mojom::ShelfModelObserver: |
| 372 void OnShelfItemAdded(int32_t index, const ash::ShelfItem& item) override; |
| 373 void OnShelfItemRemoved(int32_t index, const ash::ShelfItem& item) override; |
| 374 void OnShelfItemMoved(int32_t start_index, int32_t target_index) override; |
| 375 void OnShelfItemChanged(int32_t index, const ash::ShelfItem& item) override; |
| 376 void OnShelfItemDelegateChanged( |
| 377 const ash::ShelfID& id, |
| 378 ash::mojom::ShelfItemDelegatePtr delegate) override; |
| 379 |
| 363 // ash::ShelfModelObserver: | 380 // ash::ShelfModelObserver: |
| 364 void ShelfItemAdded(int index) override; | 381 void ShelfItemAdded(int index) override; |
| 365 void ShelfItemRemoved(int index, const ash::ShelfItem& old_item) override; | 382 void ShelfItemRemoved(int index, const ash::ShelfItem& old_item) override; |
| 366 void ShelfItemMoved(int start_index, int target_index) override; | 383 void ShelfItemMoved(int start_index, int target_index) override; |
| 367 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override; | 384 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override; |
| 385 void ShelfItemDelegateChanged(const ash::ShelfID& id, |
| 386 ash::ShelfItemDelegate* delegate) override; |
| 368 | 387 |
| 369 // ash::WindowTreeHostManager::Observer: | 388 // ash::WindowTreeHostManager::Observer: |
| 370 void OnDisplayConfigurationChanged() override; | 389 void OnDisplayConfigurationChanged() override; |
| 371 | 390 |
| 372 // AppSyncUIStateObserver: | 391 // AppSyncUIStateObserver: |
| 373 void OnAppSyncUIStatusChanged() override; | 392 void OnAppSyncUIStatusChanged() override; |
| 374 | 393 |
| 375 // app_list::AppListSyncableService::Observer: | 394 // app_list::AppListSyncableService::Observer: |
| 376 void OnSyncModelUpdated() override; | 395 void OnSyncModelUpdated() override; |
| 377 | 396 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 392 | 411 |
| 393 // Ash's mojom::ShelfController used to change shelf state. | 412 // Ash's mojom::ShelfController used to change shelf state. |
| 394 ash::mojom::ShelfControllerPtr shelf_controller_; | 413 ash::mojom::ShelfControllerPtr shelf_controller_; |
| 395 | 414 |
| 396 // The binding this instance uses to implment mojom::ShelfObserver | 415 // The binding this instance uses to implment mojom::ShelfObserver |
| 397 mojo::AssociatedBinding<ash::mojom::ShelfObserver> observer_binding_; | 416 mojo::AssociatedBinding<ash::mojom::ShelfObserver> observer_binding_; |
| 398 | 417 |
| 399 // True when setting a shelf pref in response to an observer notification. | 418 // True when setting a shelf pref in response to an observer notification. |
| 400 bool updating_shelf_pref_from_observer_ = false; | 419 bool updating_shelf_pref_from_observer_ = false; |
| 401 | 420 |
| 421 // Binding for observation of the remote ShelfModel owned by Ash. |
| 422 ash::mojom::ShelfModelObserverRequest shelf_model_observer_request_; |
| 423 mojo::Binding<ash::mojom::ShelfModelObserver> shelf_model_observer_binding_; |
| 424 |
| 425 // True when applying changes from the remote ShelfModel owned by Ash. |
| 426 // Changes to the local ShelfModel should not be reported during this time. |
| 427 bool applying_remote_shelf_model_changes_ = false; |
| 428 |
| 429 // The set of shelf model observers notified about shelf model changes. |
| 430 mojo::InterfacePtrSet<ash::mojom::ShelfModelObserver> shelf_model_observers_; |
| 431 |
| 402 // When true, changes to pinned shelf items should update the sync model. | 432 // When true, changes to pinned shelf items should update the sync model. |
| 403 bool should_sync_pin_changes_ = true; | 433 bool should_sync_pin_changes_ = true; |
| 404 | 434 |
| 405 // Used to get app info for tabs. | 435 // Used to get app info for tabs. |
| 406 std::unique_ptr<LauncherControllerHelper> launcher_controller_helper_; | 436 std::unique_ptr<LauncherControllerHelper> launcher_controller_helper_; |
| 407 | 437 |
| 408 // An observer that manages the shelf title and icon for settings windows. | 438 // An observer that manages the shelf title and icon for settings windows. |
| 409 SettingsWindowObserver settings_window_observer_; | 439 SettingsWindowObserver settings_window_observer_; |
| 410 | 440 |
| 411 // Used to load the images for app items. | 441 // Used to load the images for app items. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 441 using RunningAppListIds = std::vector<std::string>; | 471 using RunningAppListIds = std::vector<std::string>; |
| 442 using RunningAppListIdMap = std::map<std::string, RunningAppListIds>; | 472 using RunningAppListIdMap = std::map<std::string, RunningAppListIds>; |
| 443 RunningAppListIdMap last_used_running_application_order_; | 473 RunningAppListIdMap last_used_running_application_order_; |
| 444 | 474 |
| 445 base::WeakPtrFactory<ChromeLauncherController> weak_ptr_factory_; | 475 base::WeakPtrFactory<ChromeLauncherController> weak_ptr_factory_; |
| 446 | 476 |
| 447 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); | 477 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); |
| 448 }; | 478 }; |
| 449 | 479 |
| 450 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ | 480 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ |
| OLD | NEW |