| 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 <memory> | 10 #include <memory> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "components/syncable_prefs/pref_service_syncable_observer.h" | 33 #include "components/syncable_prefs/pref_service_syncable_observer.h" |
| 34 #include "extensions/common/constants.h" | 34 #include "extensions/common/constants.h" |
| 35 #include "ui/aura/window_observer.h" | 35 #include "ui/aura/window_observer.h" |
| 36 | 36 |
| 37 class AppSyncUIState; | 37 class AppSyncUIState; |
| 38 class Browser; | 38 class Browser; |
| 39 class BrowserShortcutLauncherItemController; | 39 class BrowserShortcutLauncherItemController; |
| 40 class BrowserStatusMonitor; | 40 class BrowserStatusMonitor; |
| 41 class ExtensionEnableFlow; | 41 class ExtensionEnableFlow; |
| 42 class GURL; | 42 class GURL; |
| 43 class LauncherControllerHelper; |
| 43 class LauncherItemController; | 44 class LauncherItemController; |
| 44 class Profile; | 45 class Profile; |
| 45 class AppWindowLauncherController; | 46 class AppWindowLauncherController; |
| 46 class TabContents; | 47 class TabContents; |
| 47 | 48 |
| 48 namespace ash { | 49 namespace ash { |
| 49 class ShelfItemDelegateManager; | 50 class ShelfItemDelegateManager; |
| 50 class ShelfModel; | 51 class ShelfModel; |
| 51 } | 52 } |
| 52 | 53 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 // Used to update the state of non plaform apps, as web contents change. | 103 // Used to update the state of non plaform apps, as web contents change. |
| 103 enum AppState { | 104 enum AppState { |
| 104 APP_STATE_ACTIVE, | 105 APP_STATE_ACTIVE, |
| 105 APP_STATE_WINDOW_ACTIVE, | 106 APP_STATE_WINDOW_ACTIVE, |
| 106 APP_STATE_INACTIVE, | 107 APP_STATE_INACTIVE, |
| 107 APP_STATE_REMOVED | 108 APP_STATE_REMOVED |
| 108 }; | 109 }; |
| 109 | 110 |
| 110 // Mockable interface to get app ids from tabs. | |
| 111 class AppTabHelper { | |
| 112 public: | |
| 113 virtual ~AppTabHelper() {} | |
| 114 | |
| 115 // Returns the app id of the specified tab, or an empty string if there is | |
| 116 // no app. All known profiles will be queried for this. | |
| 117 virtual std::string GetAppID(content::WebContents* tab) = 0; | |
| 118 | |
| 119 // Returns true if |id| is valid for the currently active profile. | |
| 120 // Used during restore to ignore no longer valid extensions. | |
| 121 // Note that already running applications are ignored by the restore | |
| 122 // process. | |
| 123 virtual bool IsValidIDForCurrentUser(const std::string& id) = 0; | |
| 124 | |
| 125 // Sets the currently active profile for the usage of |GetAppID|. | |
| 126 virtual void SetCurrentUser(Profile* profile) = 0; | |
| 127 }; | |
| 128 | |
| 129 ChromeLauncherController(Profile* profile, ash::ShelfModel* model); | 111 ChromeLauncherController(Profile* profile, ash::ShelfModel* model); |
| 130 ~ChromeLauncherController() override; | 112 ~ChromeLauncherController() override; |
| 131 | 113 |
| 132 // Initializes this ChromeLauncherController. | 114 // Initializes this ChromeLauncherController. |
| 133 void Init(); | 115 void Init(); |
| 134 | 116 |
| 135 // Creates an instance. | 117 // Creates an instance. |
| 136 static ChromeLauncherController* CreateInstance(Profile* profile, | 118 static ChromeLauncherController* CreateInstance(Profile* profile, |
| 137 ash::ShelfModel* model); | 119 ash::ShelfModel* model); |
| 138 | 120 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 366 |
| 385 // TODO(khmel): Find better home for Pinnable enum. | 367 // TODO(khmel): Find better home for Pinnable enum. |
| 386 AppListControllerDelegate::Pinnable GetPinnable(const std::string& app_id); | 368 AppListControllerDelegate::Pinnable GetPinnable(const std::string& app_id); |
| 387 | 369 |
| 388 protected: | 370 protected: |
| 389 // Creates a new app shortcut item and controller on the shelf at |index|. | 371 // Creates a new app shortcut item and controller on the shelf at |index|. |
| 390 // Use kInsertItemAtEnd to add a shortcut as the last item. | 372 // Use kInsertItemAtEnd to add a shortcut as the last item. |
| 391 ash::ShelfID CreateAppShortcutLauncherItem(const std::string& app_id, | 373 ash::ShelfID CreateAppShortcutLauncherItem(const std::string& app_id, |
| 392 int index); | 374 int index); |
| 393 | 375 |
| 394 // Sets the AppTabHelper/AppIconLoader, taking ownership of the helper class. | 376 // Sets LauncherControllerHelper/AppIconLoader for test, taking ownership. |
| 395 // These are intended for testing. | 377 void SetLauncherControllerHelperForTest(LauncherControllerHelper* helper); |
| 396 void SetAppTabHelperForTest(AppTabHelper* helper); | |
| 397 void SetAppIconLoadersForTest( | 378 void SetAppIconLoadersForTest( |
| 398 std::vector<std::unique_ptr<AppIconLoader>>& loaders); | 379 std::vector<std::unique_ptr<AppIconLoader>>& loaders); |
| 399 const std::string& GetAppIdFromShelfIdForTest(ash::ShelfID id); | 380 const std::string& GetAppIdFromShelfIdForTest(ash::ShelfID id); |
| 400 | 381 |
| 401 // Sets the ash::ShelfItemDelegateManager only for unittests and doesn't | 382 // Sets the ash::ShelfItemDelegateManager only for unittests and doesn't |
| 402 // take an ownership of it. | 383 // take an ownership of it. |
| 403 void SetShelfItemDelegateManagerForTest( | 384 void SetShelfItemDelegateManagerForTest( |
| 404 ash::ShelfItemDelegateManager* manager); | 385 ash::ShelfItemDelegateManager* manager); |
| 405 | 386 |
| 406 private: | 387 private: |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 459 |
| 479 // Create ShelfItem for Browser Shortcut. | 460 // Create ShelfItem for Browser Shortcut. |
| 480 ash::ShelfID CreateBrowserShortcutLauncherItem(); | 461 ash::ShelfID CreateBrowserShortcutLauncherItem(); |
| 481 | 462 |
| 482 // Check if the given |web_contents| is in incognito mode. | 463 // Check if the given |web_contents| is in incognito mode. |
| 483 bool IsIncognito(const content::WebContents* web_contents) const; | 464 bool IsIncognito(const content::WebContents* web_contents) const; |
| 484 | 465 |
| 485 // Update browser shortcut's index. | 466 // Update browser shortcut's index. |
| 486 void PersistChromeItemIndex(int index); | 467 void PersistChromeItemIndex(int index); |
| 487 | 468 |
| 488 // Get browser shortcut's index from pref. | |
| 489 int GetChromeIconIndexFromPref() const; | |
| 490 | |
| 491 // Depending on the provided flags, move either the chrome icon, the app icon | 469 // Depending on the provided flags, move either the chrome icon, the app icon |
| 492 // or none to the given |target_index|. The provided |chrome_index| and | 470 // or none to the given |target_index|. The provided |chrome_index| and |
| 493 // |app_list_index| locations will get adjusted within this call to finalize | 471 // |app_list_index| locations will get adjusted within this call to finalize |
| 494 // the action and to make sure that the other item can still be moved | 472 // the action and to make sure that the other item can still be moved |
| 495 // afterwards (index adjustments). | 473 // afterwards (index adjustments). |
| 496 void MoveChromeOrApplistToFinalPosition( | 474 void MoveChromeOrApplistToFinalPosition( |
| 497 bool is_chrome, | 475 bool is_chrome, |
| 498 bool is_app_list, | 476 bool is_app_list, |
| 499 int target_index, | 477 int target_index, |
| 500 int* chrome_index, | 478 int* chrome_index, |
| 501 int* app_list_index); | 479 int* app_list_index); |
| 502 | 480 |
| 503 // Finds the index of where to insert the next item. | 481 // Finds the index of where to insert the next item. |
| 504 int FindInsertionPoint(bool is_app_list); | 482 int FindInsertionPoint(bool is_app_list); |
| 505 | 483 |
| 506 // Get the browser shortcut's index in the shelf using the current's systems | 484 // Get the browser shortcut's index in the shelf using the current's systems |
| 507 // configuration of pinned and known (but not running) apps. | 485 // configuration of pinned and known (but not running) apps. |
| 508 int GetChromeIconIndexForCreation(); | 486 int GetChromeIconIndexForCreation(); |
| 509 | 487 |
| 510 // Get the list of pinned programs from the preferences. | |
| 511 std::vector<std::string> GetListOfPinnedAppsAndBrowser(); | |
| 512 | |
| 513 // Close all windowed V1 applications of a certain extension which was already | 488 // Close all windowed V1 applications of a certain extension which was already |
| 514 // deleted. | 489 // deleted. |
| 515 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id, | 490 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id, |
| 516 const Profile* profile); | 491 const Profile* profile); |
| 517 | 492 |
| 518 // Set ShelfItemDelegate |item_delegate| for |id| and take an ownership. | 493 // Set ShelfItemDelegate |item_delegate| for |id| and take an ownership. |
| 519 // TODO(simon.hong81): Make this take a scoped_ptr of |item_delegate|. | 494 // TODO(simon.hong81): Make this take a scoped_ptr of |item_delegate|. |
| 520 void SetShelfItemDelegate(ash::ShelfID id, | 495 void SetShelfItemDelegate(ash::ShelfID id, |
| 521 ash::ShelfItemDelegate* item_delegate); | 496 ash::ShelfItemDelegate* item_delegate); |
| 522 | 497 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 542 IDToItemControllerMap id_to_item_controller_map_; | 517 IDToItemControllerMap id_to_item_controller_map_; |
| 543 | 518 |
| 544 // Direct access to app_id for a web contents. | 519 // Direct access to app_id for a web contents. |
| 545 WebContentsToAppIDMap web_contents_to_app_id_; | 520 WebContentsToAppIDMap web_contents_to_app_id_; |
| 546 | 521 |
| 547 // Used to track app windows. | 522 // Used to track app windows. |
| 548 std::vector<std::unique_ptr<AppWindowLauncherController>> | 523 std::vector<std::unique_ptr<AppWindowLauncherController>> |
| 549 app_window_controllers_; | 524 app_window_controllers_; |
| 550 | 525 |
| 551 // Used to get app info for tabs. | 526 // Used to get app info for tabs. |
| 552 std::unique_ptr<AppTabHelper> app_tab_helper_; | 527 std::unique_ptr<LauncherControllerHelper> launcher_controller_helper_; |
| 553 | 528 |
| 554 // Used to load the image for an extension app item. | 529 // Used to load the images for app items. |
| 555 std::vector<std::unique_ptr<AppIconLoader>> app_icon_loaders_; | 530 std::vector<std::unique_ptr<AppIconLoader>> app_icon_loaders_; |
| 556 | 531 |
| 557 // Used to handle app load/unload events. | 532 // Used to handle app load/unload events. |
| 558 std::vector<std::unique_ptr<LauncherAppUpdater>> app_updaters_; | 533 std::vector<std::unique_ptr<LauncherAppUpdater>> app_updaters_; |
| 559 | 534 |
| 560 PrefChangeRegistrar pref_change_registrar_; | 535 PrefChangeRegistrar pref_change_registrar_; |
| 561 | 536 |
| 562 AppSyncUIState* app_sync_ui_state_; | 537 AppSyncUIState* app_sync_ui_state_; |
| 563 | 538 |
| 564 std::unique_ptr<ExtensionEnableFlow> extension_enable_flow_; | 539 std::unique_ptr<ExtensionEnableFlow> extension_enable_flow_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 578 // The list of running & un-pinned applications for different users on hidden | 553 // The list of running & un-pinned applications for different users on hidden |
| 579 // desktops. | 554 // desktops. |
| 580 typedef std::vector<std::string> RunningAppListIds; | 555 typedef std::vector<std::string> RunningAppListIds; |
| 581 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap; | 556 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap; |
| 582 RunningAppListIdMap last_used_running_application_order_; | 557 RunningAppListIdMap last_used_running_application_order_; |
| 583 | 558 |
| 584 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); | 559 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); |
| 585 }; | 560 }; |
| 586 | 561 |
| 587 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ | 562 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ |
| OLD | NEW |