| 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> | 10 #include <set> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 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 LauncherItemController; | 43 class LauncherItemController; |
| 44 class Profile; | 44 class Profile; |
| 45 class ShellWindowLauncherController; | 45 class ShellWindowLauncherController; |
| 46 class TabContents; | 46 class TabContents; |
| 47 | 47 |
| 48 namespace ash { | 48 namespace ash { |
| 49 class LauncherItemDelegateManager; |
| 49 class LauncherModel; | 50 class LauncherModel; |
| 50 } | 51 } |
| 51 | 52 |
| 52 namespace aura { | 53 namespace aura { |
| 53 class Window; | 54 class Window; |
| 54 } | 55 } |
| 55 | 56 |
| 56 namespace content { | 57 namespace content { |
| 57 class NotificationRegistrar; | 58 class NotificationRegistrar; |
| 58 class WebContents; | 59 class WebContents; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 // ChromeLauncherController manages the launcher items needed for content | 81 // ChromeLauncherController manages the launcher items needed for content |
| 81 // windows. Launcher items have a type, an optional app id, and a controller. | 82 // windows. Launcher items have a type, an optional app id, and a controller. |
| 82 // This incarnation groups running tabs/windows in application specific lists. | 83 // This incarnation groups running tabs/windows in application specific lists. |
| 83 // * Browser app windows have BrowserLauncherItemController, owned by the | 84 // * Browser app windows have BrowserLauncherItemController, owned by the |
| 84 // BrowserView instance. | 85 // BrowserView instance. |
| 85 // * App shell windows have ShellWindowLauncherItemController, owned by | 86 // * App shell windows have ShellWindowLauncherItemController, owned by |
| 86 // ShellWindowLauncherController. | 87 // ShellWindowLauncherController. |
| 87 // * Shortcuts have no LauncherItemController. | 88 // * Shortcuts have no LauncherItemController. |
| 88 // TODO(simon.hong81): Move LauncherItemDelegate out from | |
| 89 // ChromeLauncherController and makes separate subclass with it. | |
| 90 class ChromeLauncherController : public ash::LauncherDelegate, | 89 class ChromeLauncherController : public ash::LauncherDelegate, |
| 91 public ash::LauncherItemDelegate, | |
| 92 public ash::LauncherModelObserver, | 90 public ash::LauncherModelObserver, |
| 93 public ash::ShellObserver, | 91 public ash::ShellObserver, |
| 94 public ash::DisplayController::Observer, | 92 public ash::DisplayController::Observer, |
| 95 public content::NotificationObserver, | 93 public content::NotificationObserver, |
| 96 public extensions::AppIconLoader::Delegate, | 94 public extensions::AppIconLoader::Delegate, |
| 97 public PrefServiceSyncableObserver, | 95 public PrefServiceSyncableObserver, |
| 98 public AppSyncUIStateObserver, | 96 public AppSyncUIStateObserver, |
| 99 public ExtensionEnableFlowDelegate, | 97 public ExtensionEnableFlowDelegate, |
| 100 public ash::ShelfLayoutManagerObserver { | 98 public ash::ShelfLayoutManagerObserver { |
| 101 public: | 99 public: |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 virtual void OnLauncherCreated(ash::Launcher* launcher) OVERRIDE; | 287 virtual void OnLauncherCreated(ash::Launcher* launcher) OVERRIDE; |
| 290 virtual void OnLauncherDestroyed(ash::Launcher* launcher) OVERRIDE; | 288 virtual void OnLauncherDestroyed(ash::Launcher* launcher) OVERRIDE; |
| 291 virtual ash::LauncherID GetLauncherIDForAppID( | 289 virtual ash::LauncherID GetLauncherIDForAppID( |
| 292 const std::string& app_id) OVERRIDE; | 290 const std::string& app_id) OVERRIDE; |
| 293 virtual const std::string& GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE; | 291 virtual const std::string& GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE; |
| 294 virtual void PinAppWithID(const std::string& app_id) OVERRIDE; | 292 virtual void PinAppWithID(const std::string& app_id) OVERRIDE; |
| 295 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE; | 293 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE; |
| 296 virtual bool CanPin() const OVERRIDE; | 294 virtual bool CanPin() const OVERRIDE; |
| 297 virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE; | 295 virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE; |
| 298 | 296 |
| 299 // ash::LauncherItemDelegate overrides: | |
| 300 virtual void ItemSelected(const ash::LauncherItem& item, | |
| 301 const ui::Event& event) OVERRIDE; | |
| 302 virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE; | |
| 303 virtual ui::MenuModel* CreateContextMenu( | |
| 304 const ash::LauncherItem& item, aura::RootWindow* root) OVERRIDE; | |
| 305 virtual ash::LauncherMenuModel* CreateApplicationMenu( | |
| 306 const ash::LauncherItem& item, | |
| 307 int event_flags) OVERRIDE; | |
| 308 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE; | |
| 309 virtual bool ShouldShowTooltip(const ash::LauncherItem& item) OVERRIDE; | |
| 310 | |
| 311 // ash::LauncherModelObserver overrides: | 297 // ash::LauncherModelObserver overrides: |
| 312 virtual void LauncherItemAdded(int index) OVERRIDE; | 298 virtual void LauncherItemAdded(int index) OVERRIDE; |
| 313 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE; | 299 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE; |
| 314 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; | 300 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; |
| 315 virtual void LauncherItemChanged(int index, | 301 virtual void LauncherItemChanged(int index, |
| 316 const ash::LauncherItem& old_item) OVERRIDE; | 302 const ash::LauncherItem& old_item) OVERRIDE; |
| 317 virtual void LauncherStatusChanged() OVERRIDE; | 303 virtual void LauncherStatusChanged() OVERRIDE; |
| 318 | 304 |
| 319 // content::NotificationObserver overrides: | 305 // content::NotificationObserver overrides: |
| 320 virtual void Observe(int type, | 306 virtual void Observe(int type, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 gfx::Image GetAppListIcon(content::WebContents* web_contents) const; | 364 gfx::Image GetAppListIcon(content::WebContents* web_contents) const; |
| 379 | 365 |
| 380 // Get the title for the applicatoin list entry for |web_contents|. | 366 // Get the title for the applicatoin list entry for |web_contents|. |
| 381 // If |web_contents| has not loaded, returns "Net Tab". | 367 // If |web_contents| has not loaded, returns "Net Tab". |
| 382 string16 GetAppListTitle(content::WebContents* web_contents) const; | 368 string16 GetAppListTitle(content::WebContents* web_contents) const; |
| 383 | 369 |
| 384 // Returns the LauncherItemController of BrowserShortcut. | 370 // Returns the LauncherItemController of BrowserShortcut. |
| 385 BrowserShortcutLauncherItemController* | 371 BrowserShortcutLauncherItemController* |
| 386 GetBrowserShortcutLauncherItemController(); | 372 GetBrowserShortcutLauncherItemController(); |
| 387 | 373 |
| 374 LauncherItemController* GetLauncherItemController(const ash::LauncherID id); |
| 375 |
| 388 protected: | 376 protected: |
| 389 // Creates a new app shortcut item and controller on the launcher at |index|. | 377 // Creates a new app shortcut item and controller on the launcher at |index|. |
| 390 // Use kInsertItemAtEnd to add a shortcut as the last item. | 378 // Use kInsertItemAtEnd to add a shortcut as the last item. |
| 391 ash::LauncherID CreateAppShortcutLauncherItem(const std::string& app_id, | 379 ash::LauncherID CreateAppShortcutLauncherItem(const std::string& app_id, |
| 392 int index); | 380 int index); |
| 393 | 381 |
| 394 // Sets the AppTabHelper/AppIconLoader, taking ownership of the helper class. | 382 // Sets the AppTabHelper/AppIconLoader, taking ownership of the helper class. |
| 395 // These are intended for testing. | 383 // These are intended for testing. |
| 396 void SetAppTabHelperForTest(AppTabHelper* helper); | 384 void SetAppTabHelperForTest(AppTabHelper* helper); |
| 397 void SetAppIconLoaderForTest(extensions::AppIconLoader* loader); | 385 void SetAppIconLoaderForTest(extensions::AppIconLoader* loader); |
| 398 const std::string& GetAppIdFromLauncherIdForTest(ash::LauncherID id); | 386 const std::string& GetAppIdFromLauncherIdForTest(ash::LauncherID id); |
| 399 | 387 |
| 388 // Sets the ash::LauncherItemDelegateManager only for unittests and doesn't |
| 389 // take an ownership of it. |
| 390 void SetLauncherItemDelegateManagerForTest( |
| 391 ash::LauncherItemDelegateManager* manager); |
| 392 |
| 400 private: | 393 private: |
| 401 friend class ChromeLauncherControllerTest; | 394 friend class ChromeLauncherControllerTest; |
| 402 friend class LauncherAppBrowserTest; | 395 friend class LauncherAppBrowserTest; |
| 403 friend class LauncherPlatformAppBrowserTest; | 396 friend class LauncherPlatformAppBrowserTest; |
| 404 | 397 |
| 405 typedef std::map<ash::LauncherID, LauncherItemController*> | 398 typedef std::map<ash::LauncherID, LauncherItemController*> |
| 406 IDToItemControllerMap; | 399 IDToItemControllerMap; |
| 407 typedef std::list<content::WebContents*> WebContentsList; | 400 typedef std::list<content::WebContents*> WebContentsList; |
| 408 typedef std::map<std::string, WebContentsList> AppIDToWebContentsListMap; | 401 typedef std::map<std::string, WebContentsList> AppIDToWebContentsListMap; |
| 409 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap; | 402 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // configuration of pinned and known (but not running) apps. | 494 // configuration of pinned and known (but not running) apps. |
| 502 int GetChromeIconIndexForCreation(); | 495 int GetChromeIconIndexForCreation(); |
| 503 | 496 |
| 504 // Get the list of pinned programs from the preferences. | 497 // Get the list of pinned programs from the preferences. |
| 505 std::vector<std::string> GetListOfPinnedAppsAndBrowser(); | 498 std::vector<std::string> GetListOfPinnedAppsAndBrowser(); |
| 506 | 499 |
| 507 // Close all windowed V1 applications of a certain extension which was already | 500 // Close all windowed V1 applications of a certain extension which was already |
| 508 // deleted. | 501 // deleted. |
| 509 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id); | 502 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id); |
| 510 | 503 |
| 511 // Register LauncherItemDelegate. | 504 // Set LauncherItemDelegate |item_delegate| for |id| and take an ownership. |
| 512 void RegisterLauncherItemDelegate(); | 505 // TODO(simon.hong81): Make this take a scoped_ptr of |item_delegate|. |
| 506 void SetLauncherItemDelegate(ash::LauncherID id, |
| 507 ash::LauncherItemDelegate* item_delegate); |
| 513 | 508 |
| 514 // Attach to a specific profile. | 509 // Attach to a specific profile. |
| 515 void AttachProfile(Profile* proifile); | 510 void AttachProfile(Profile* proifile); |
| 516 | 511 |
| 517 // Forget the current profile to allow attaching to a new one. | 512 // Forget the current profile to allow attaching to a new one. |
| 518 void ReleaseProfile(); | 513 void ReleaseProfile(); |
| 519 | 514 |
| 520 static ChromeLauncherController* instance_; | 515 static ChromeLauncherController* instance_; |
| 521 | 516 |
| 522 ash::LauncherModel* model_; | 517 ash::LauncherModel* model_; |
| 523 | 518 |
| 519 ash::LauncherItemDelegateManager* item_delegate_manager_; |
| 520 |
| 524 // Profile used for prefs and loading extensions. This is NOT necessarily the | 521 // Profile used for prefs and loading extensions. This is NOT necessarily the |
| 525 // profile new windows are created with. | 522 // profile new windows are created with. |
| 526 Profile* profile_; | 523 Profile* profile_; |
| 527 | 524 |
| 528 IDToItemControllerMap id_to_item_controller_map_; | 525 IDToItemControllerMap id_to_item_controller_map_; |
| 529 | 526 |
| 530 // Maintains activation order of web contents for each app. | 527 // Maintains activation order of web contents for each app. |
| 531 AppIDToWebContentsListMap app_id_to_web_contents_list_; | 528 AppIDToWebContentsListMap app_id_to_web_contents_list_; |
| 532 | 529 |
| 533 // Direct access to app_id for a web contents. | 530 // Direct access to app_id for a web contents. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 546 | 543 |
| 547 PrefChangeRegistrar pref_change_registrar_; | 544 PrefChangeRegistrar pref_change_registrar_; |
| 548 | 545 |
| 549 AppSyncUIState* app_sync_ui_state_; | 546 AppSyncUIState* app_sync_ui_state_; |
| 550 | 547 |
| 551 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; | 548 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; |
| 552 | 549 |
| 553 // Launchers that are currently being observed. | 550 // Launchers that are currently being observed. |
| 554 std::set<ash::Launcher*> launchers_; | 551 std::set<ash::Launcher*> launchers_; |
| 555 | 552 |
| 556 // The owned browser shortcut item. | |
| 557 scoped_ptr<BrowserShortcutLauncherItemController> browser_item_controller_; | |
| 558 | |
| 559 // The owned browser status monitor. | 553 // The owned browser status monitor. |
| 560 scoped_ptr<BrowserStatusMonitor> browser_status_monitor_; | 554 scoped_ptr<BrowserStatusMonitor> browser_status_monitor_; |
| 561 | 555 |
| 562 // A special observer class to detect user switches. | 556 // A special observer class to detect user switches. |
| 563 scoped_ptr<ChromeLauncherControllerUserSwitchObserver> user_switch_observer_; | 557 scoped_ptr<ChromeLauncherControllerUserSwitchObserver> user_switch_observer_; |
| 564 | 558 |
| 565 // If true, incoming pinned state changes should be ignored. | 559 // If true, incoming pinned state changes should be ignored. |
| 566 bool ignore_persist_pinned_state_change_; | 560 bool ignore_persist_pinned_state_change_; |
| 567 | 561 |
| 568 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); | 562 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); |
| 569 }; | 563 }; |
| 570 | 564 |
| 571 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ | 565 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ |
| OLD | NEW |