| 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_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 private ash::ShelfModelObserver, | 54 private ash::ShelfModelObserver, |
| 55 private ash::WindowTreeHostManager::Observer, | 55 private ash::WindowTreeHostManager::Observer, |
| 56 private AppSyncUIStateObserver, | 56 private AppSyncUIStateObserver, |
| 57 private app_list::AppListSyncableService::Observer, | 57 private app_list::AppListSyncableService::Observer, |
| 58 private sync_preferences::PrefServiceSyncableObserver { | 58 private sync_preferences::PrefServiceSyncableObserver { |
| 59 public: | 59 public: |
| 60 ChromeLauncherControllerImpl(Profile* profile, ash::ShelfModel* model); | 60 ChromeLauncherControllerImpl(Profile* profile, ash::ShelfModel* model); |
| 61 ~ChromeLauncherControllerImpl() override; | 61 ~ChromeLauncherControllerImpl() override; |
| 62 | 62 |
| 63 // ChromeLauncherController: | 63 // ChromeLauncherController: |
| 64 ash::ShelfID CreateAppLauncherItem(LauncherItemController* controller, | 64 ash::ShelfID CreateAppLauncherItem( |
| 65 ash::ShelfItemStatus status) override; | 65 std::unique_ptr<ash::ShelfItemDelegate> item_delegate, |
| 66 ash::ShelfItemStatus status) override; |
| 66 const ash::ShelfItem* GetItem(ash::ShelfID id) const override; | 67 const ash::ShelfItem* GetItem(ash::ShelfID id) const override; |
| 67 void SetItemType(ash::ShelfID id, ash::ShelfItemType type) override; | 68 void SetItemType(ash::ShelfID id, ash::ShelfItemType type) override; |
| 68 void SetItemStatus(ash::ShelfID id, ash::ShelfItemStatus status) override; | 69 void SetItemStatus(ash::ShelfID id, ash::ShelfItemStatus status) override; |
| 69 void SetItemController(ash::ShelfID id, | 70 void SetShelfItemDelegate( |
| 70 LauncherItemController* controller) override; | 71 ash::ShelfID id, |
| 72 std::unique_ptr<ash::ShelfItemDelegate> item_delegate) override; |
| 71 void CloseLauncherItem(ash::ShelfID id) override; | 73 void CloseLauncherItem(ash::ShelfID id) override; |
| 72 bool IsPinned(ash::ShelfID id) override; | 74 bool IsPinned(ash::ShelfID id) override; |
| 73 void SetV1AppStatus(const std::string& app_id, | 75 void SetV1AppStatus(const std::string& app_id, |
| 74 ash::ShelfItemStatus status) override; | 76 ash::ShelfItemStatus status) override; |
| 75 void Launch(ash::ShelfID id, int event_flags) override; | 77 void Launch(ash::ShelfID id, int event_flags) override; |
| 76 void Close(ash::ShelfID id) override; | 78 void Close(ash::ShelfID id) override; |
| 77 bool IsOpen(ash::ShelfID id) override; | 79 bool IsOpen(ash::ShelfID id) override; |
| 78 bool IsPlatformApp(ash::ShelfID id) override; | 80 bool IsPlatformApp(ash::ShelfID id) override; |
| 79 void ActivateApp(const std::string& app_id, | 81 void ActivateApp(const std::string& app_id, |
| 80 ash::ShelfLaunchSource source, | 82 ash::ShelfLaunchSource source, |
| 81 int event_flags) override; | 83 int event_flags) override; |
| 82 void SetLauncherItemImage(ash::ShelfID shelf_id, | 84 void SetLauncherItemImage(ash::ShelfID shelf_id, |
| 83 const gfx::ImageSkia& image) override; | 85 const gfx::ImageSkia& image) override; |
| 84 void UpdateAppState(content::WebContents* contents, | 86 void UpdateAppState(content::WebContents* contents, |
| 85 AppState app_state) override; | 87 AppState app_state) override; |
| 86 ash::ShelfID GetShelfIDForWebContents( | 88 ash::ShelfID GetShelfIDForWebContents( |
| 87 content::WebContents* contents) override; | 89 content::WebContents* contents) override; |
| 88 void SetRefocusURLPatternForTest(ash::ShelfID id, const GURL& url) override; | 90 void SetRefocusURLPatternForTest(ash::ShelfID id, const GURL& url) override; |
| 89 ash::ShelfAction ActivateWindowOrMinimizeIfActive( | 91 ash::ShelfAction ActivateWindowOrMinimizeIfActive( |
| 90 ui::BaseWindow* window, | 92 ui::BaseWindow* window, |
| 91 bool allow_minimize) override; | 93 bool allow_minimize) override; |
| 92 void ActiveUserChanged(const std::string& user_email) override; | 94 void ActiveUserChanged(const std::string& user_email) override; |
| 93 void AdditionalUserAddedToSession(Profile* profile) override; | 95 void AdditionalUserAddedToSession(Profile* profile) override; |
| 94 MenuItemList GetAppMenuItemsForTesting(const ash::ShelfItem& item) override; | 96 ash::MenuItemList GetAppMenuItemsForTesting( |
| 97 const ash::ShelfItem& item) override; |
| 95 std::vector<content::WebContents*> GetV1ApplicationsFromAppId( | 98 std::vector<content::WebContents*> GetV1ApplicationsFromAppId( |
| 96 const std::string& app_id) override; | 99 const std::string& app_id) override; |
| 97 void ActivateShellApp(const std::string& app_id, int window_index) override; | 100 void ActivateShellApp(const std::string& app_id, int window_index) override; |
| 98 bool IsWebContentHandledByApplication(content::WebContents* web_contents, | 101 bool IsWebContentHandledByApplication(content::WebContents* web_contents, |
| 99 const std::string& app_id) override; | 102 const std::string& app_id) override; |
| 100 bool ContentCanBeHandledByGmailApp( | 103 bool ContentCanBeHandledByGmailApp( |
| 101 content::WebContents* web_contents) override; | 104 content::WebContents* web_contents) override; |
| 102 gfx::Image GetAppListIcon(content::WebContents* web_contents) const override; | 105 gfx::Image GetAppListIcon(content::WebContents* web_contents) const override; |
| 103 base::string16 GetAppListTitle( | 106 base::string16 GetAppListTitle( |
| 104 content::WebContents* web_contents) const override; | 107 content::WebContents* web_contents) const override; |
| 105 BrowserShortcutLauncherItemController* | 108 BrowserShortcutLauncherItemController* |
| 106 GetBrowserShortcutLauncherItemController() override; | 109 GetBrowserShortcutLauncherItemController() override; |
| 107 LauncherItemController* GetLauncherItemController( | 110 ash::ShelfItemDelegate* GetShelfItemDelegate(const ash::ShelfID id) override; |
| 108 const ash::ShelfID id) override; | |
| 109 bool ShelfBoundsChangesProbablyWithUser( | 111 bool ShelfBoundsChangesProbablyWithUser( |
| 110 ash::WmShelf* shelf, | 112 ash::WmShelf* shelf, |
| 111 const AccountId& account_id) const override; | 113 const AccountId& account_id) const override; |
| 112 void OnUserProfileReadyToSwitch(Profile* profile) override; | 114 void OnUserProfileReadyToSwitch(Profile* profile) override; |
| 113 ArcAppDeferredLauncherController* GetArcDeferredLauncher() override; | 115 ArcAppDeferredLauncherController* GetArcDeferredLauncher() override; |
| 114 const std::string& GetLaunchIDForShelfID(ash::ShelfID id) override; | 116 const std::string& GetLaunchIDForShelfID(ash::ShelfID id) override; |
| 115 void AttachProfile(Profile* profile_to_attach) override; | 117 void AttachProfile(Profile* profile_to_attach) override; |
| 116 | 118 |
| 117 // Access to the BrowserStatusMonitor for tests. | 119 // Access to the BrowserStatusMonitor for tests. |
| 118 BrowserStatusMonitor* browser_status_monitor_for_test() { | 120 BrowserStatusMonitor* browser_status_monitor_for_test() { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 const ash::AppLaunchId& app_launch_id, | 154 const ash::AppLaunchId& app_launch_id, |
| 153 int index); | 155 int index); |
| 154 | 156 |
| 155 private: | 157 private: |
| 156 friend class ChromeLauncherControllerImplTest; | 158 friend class ChromeLauncherControllerImplTest; |
| 157 friend class ShelfAppBrowserTest; | 159 friend class ShelfAppBrowserTest; |
| 158 friend class LauncherPlatformAppBrowserTest; | 160 friend class LauncherPlatformAppBrowserTest; |
| 159 friend class TestChromeLauncherControllerImpl; | 161 friend class TestChromeLauncherControllerImpl; |
| 160 FRIEND_TEST_ALL_PREFIXES(ChromeLauncherControllerImplTest, AppPanels); | 162 FRIEND_TEST_ALL_PREFIXES(ChromeLauncherControllerImplTest, AppPanels); |
| 161 | 163 |
| 162 typedef std::map<ash::ShelfID, LauncherItemController*> IDToItemControllerMap; | 164 typedef std::map<ash::ShelfID, ash::ShelfItemDelegate*> IDToItemControllerMap; |
| 163 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap; | 165 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap; |
| 164 | 166 |
| 165 // Remembers / restores list of running applications. | 167 // Remembers / restores list of running applications. |
| 166 // Note that this order will neither be stored in the preference nor will it | 168 // Note that this order will neither be stored in the preference nor will it |
| 167 // remember the order of closed applications since it is only temporary. | 169 // remember the order of closed applications since it is only temporary. |
| 168 void RememberUnpinnedRunningApplicationOrder(); | 170 void RememberUnpinnedRunningApplicationOrder(); |
| 169 void RestoreUnpinnedRunningApplicationOrder(const std::string& user_id); | 171 void RestoreUnpinnedRunningApplicationOrder(const std::string& user_id); |
| 170 | 172 |
| 171 // Invoked when the associated browser or app is closed. | 173 // Invoked when the associated browser or app is closed. |
| 172 void LauncherItemClosed(ash::ShelfID id); | 174 void LauncherItemClosed(ash::ShelfID id); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 200 void SetVirtualKeyboardBehaviorFromPrefs(); | 202 void SetVirtualKeyboardBehaviorFromPrefs(); |
| 201 | 203 |
| 202 // Returns the shelf item status for the given |app_id|, which can be either | 204 // Returns the shelf item status for the given |app_id|, which can be either |
| 203 // STATUS_ACTIVE (if the app is active), STATUS_RUNNING (if there is such an | 205 // STATUS_ACTIVE (if the app is active), STATUS_RUNNING (if there is such an |
| 204 // app) or STATUS_CLOSED. | 206 // app) or STATUS_CLOSED. |
| 205 ash::ShelfItemStatus GetAppState(const std::string& app_id); | 207 ash::ShelfItemStatus GetAppState(const std::string& app_id); |
| 206 | 208 |
| 207 // Creates an app launcher to insert at |index|. Note that |index| may be | 209 // Creates an app launcher to insert at |index|. Note that |index| may be |
| 208 // adjusted by the model to meet ordering constraints. | 210 // adjusted by the model to meet ordering constraints. |
| 209 // The |shelf_item_type| will be set into the ShelfModel. | 211 // The |shelf_item_type| will be set into the ShelfModel. |
| 210 ash::ShelfID InsertAppLauncherItem(LauncherItemController* controller, | 212 ash::ShelfID InsertAppLauncherItem( |
| 211 ash::ShelfItemStatus status, | 213 std::unique_ptr<ash::ShelfItemDelegate> item_delegate, |
| 212 int index, | 214 ash::ShelfItemStatus status, |
| 213 ash::ShelfItemType shelf_item_type); | 215 int index, |
| 216 ash::ShelfItemType shelf_item_type); |
| 214 | 217 |
| 215 // Create ShelfItem for Browser Shortcut. | 218 // Create ShelfItem for Browser Shortcut. |
| 216 void CreateBrowserShortcutLauncherItem(); | 219 void CreateBrowserShortcutLauncherItem(); |
| 217 | 220 |
| 218 // Check if the given |web_contents| is in incognito mode. | 221 // Check if the given |web_contents| is in incognito mode. |
| 219 bool IsIncognito(const content::WebContents* web_contents) const; | 222 bool IsIncognito(const content::WebContents* web_contents) const; |
| 220 | 223 |
| 221 // Finds the index of where to insert the next item. | 224 // Finds the index of where to insert the next item. |
| 222 int FindInsertionPoint(); | 225 int FindInsertionPoint(); |
| 223 | 226 |
| 224 // Close all windowed V1 applications of a certain extension which was already | 227 // Close all windowed V1 applications of a certain extension which was already |
| 225 // deleted. | 228 // deleted. |
| 226 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id, | 229 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id, |
| 227 const Profile* profile); | 230 const Profile* profile); |
| 228 | 231 |
| 229 // Set ShelfItemDelegate |item_delegate| for |id| and take an ownership. | |
| 230 // TODO(simon.hong81): Make this take a scoped_ptr of |item_delegate|. | |
| 231 void SetShelfItemDelegate(ash::ShelfID id, | |
| 232 ash::mojom::ShelfItemDelegate* item_delegate); | |
| 233 | |
| 234 // Forget the current profile to allow attaching to a new one. | 232 // Forget the current profile to allow attaching to a new one. |
| 235 void ReleaseProfile(); | 233 void ReleaseProfile(); |
| 236 | 234 |
| 237 // ash::ShelfModelObserver: | 235 // ash::ShelfModelObserver: |
| 238 void ShelfItemAdded(int index) override; | 236 void ShelfItemAdded(int index) override; |
| 239 void ShelfItemRemoved(int index, const ash::ShelfItem& old_item) override; | 237 void ShelfItemRemoved(int index, const ash::ShelfItem& old_item) override; |
| 240 void ShelfItemMoved(int start_index, int target_index) override; | 238 void ShelfItemMoved(int start_index, int target_index) override; |
| 241 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override; | 239 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override; |
| 242 void OnSetShelfItemDelegate( | 240 void OnSetShelfItemDelegate(ash::ShelfID id, |
| 243 ash::ShelfID id, | 241 ash::ShelfItemDelegate* item_delegate) override; |
| 244 ash::mojom::ShelfItemDelegate* item_delegate) override; | |
| 245 | 242 |
| 246 // ash::WindowTreeHostManager::Observer: | 243 // ash::WindowTreeHostManager::Observer: |
| 247 void OnDisplayConfigurationChanged() override; | 244 void OnDisplayConfigurationChanged() override; |
| 248 | 245 |
| 249 // AppSyncUIStateObserver: | 246 // AppSyncUIStateObserver: |
| 250 void OnAppSyncUIStatusChanged() override; | 247 void OnAppSyncUIStatusChanged() override; |
| 251 | 248 |
| 252 // AppIconLoaderDelegate: | 249 // AppIconLoaderDelegate: |
| 253 void OnAppImageUpdated(const std::string& app_id, | 250 void OnAppImageUpdated(const std::string& app_id, |
| 254 const gfx::ImageSkia& image) override; | 251 const gfx::ImageSkia& image) override; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 typedef std::vector<std::string> RunningAppListIds; | 294 typedef std::vector<std::string> RunningAppListIds; |
| 298 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap; | 295 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap; |
| 299 RunningAppListIdMap last_used_running_application_order_; | 296 RunningAppListIdMap last_used_running_application_order_; |
| 300 | 297 |
| 301 base::WeakPtrFactory<ChromeLauncherControllerImpl> weak_ptr_factory_; | 298 base::WeakPtrFactory<ChromeLauncherControllerImpl> weak_ptr_factory_; |
| 302 | 299 |
| 303 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImpl); | 300 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImpl); |
| 304 }; | 301 }; |
| 305 | 302 |
| 306 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_ | 303 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_ |
| OLD | NEW |