| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PER_APP_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "ash/launcher/launcher_model_observer.h" | 13 #include "ash/launcher/launcher_model_observer.h" |
| 14 #include "ash/launcher/launcher_types.h" | 14 #include "ash/launcher/launcher_types.h" |
| 15 #include "ash/shelf_types.h" | 15 #include "ash/shelf_types.h" |
| 16 #include "ash/shell_observer.h" | 16 #include "ash/shell_observer.h" |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/memory/scoped_vector.h" | 20 #include "base/memory/scoped_vector.h" |
| 21 #include "base/prefs/public/pref_change_registrar.h" | 21 #include "base/prefs/public/pref_change_registrar.h" |
| 22 #include "chrome/browser/extensions/extension_prefs.h" | 22 #include "chrome/browser/extensions/extension_prefs.h" |
| 23 #include "chrome/browser/prefs/pref_service_syncable_observer.h" | 23 #include "chrome/browser/prefs/pref_service_syncable_observer.h" |
| 24 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" | 24 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" |
| 25 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 25 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| 26 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 26 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 27 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h" | 27 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h" |
| 28 #include "chrome/browser/ui/browser_list_observer.h" |
| 28 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" | 29 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" |
| 29 #include "content/public/browser/notification_observer.h" | 30 #include "content/public/browser/notification_observer.h" |
| 30 #include "content/public/browser/notification_registrar.h" | 31 #include "content/public/browser/notification_registrar.h" |
| 31 #include "ui/aura/window_observer.h" | 32 #include "ui/aura/window_observer.h" |
| 32 | 33 |
| 33 class AppSyncUIState; | 34 class AppSyncUIState; |
| 34 class Browser; | 35 class Browser; |
| 35 class BrowserLauncherItemControllerTest; | 36 class BrowserLauncherItemControllerTest; |
| 36 class ExtensionEnableFlow; | 37 class ExtensionEnableFlow; |
| 37 class LauncherItemController; | 38 class LauncherItemController; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 58 // owned by the BrowserView instance. | 59 // owned by the BrowserView instance. |
| 59 // * App shell windows have ShellWindowLauncherItemController, owned by | 60 // * App shell windows have ShellWindowLauncherItemController, owned by |
| 60 // ShellWindowLauncherController. | 61 // ShellWindowLauncherController. |
| 61 // * Shortcuts have no LauncherItemController. | 62 // * Shortcuts have no LauncherItemController. |
| 62 class ChromeLauncherControllerPerApp : public ash::LauncherModelObserver, | 63 class ChromeLauncherControllerPerApp : public ash::LauncherModelObserver, |
| 63 public ash::ShellObserver, | 64 public ash::ShellObserver, |
| 64 public ChromeLauncherController, | 65 public ChromeLauncherController, |
| 65 public content::NotificationObserver, | 66 public content::NotificationObserver, |
| 66 public PrefServiceSyncableObserver, | 67 public PrefServiceSyncableObserver, |
| 67 public AppSyncUIStateObserver, | 68 public AppSyncUIStateObserver, |
| 68 public ExtensionEnableFlowDelegate { | 69 public ExtensionEnableFlowDelegate, |
| 70 public chrome::BrowserListObserver { |
| 69 public: | 71 public: |
| 70 ChromeLauncherControllerPerApp(Profile* profile, ash::LauncherModel* model); | 72 ChromeLauncherControllerPerApp(Profile* profile, ash::LauncherModel* model); |
| 71 virtual ~ChromeLauncherControllerPerApp(); | 73 virtual ~ChromeLauncherControllerPerApp(); |
| 72 | 74 |
| 73 // ChromeLauncherController overrides: | 75 // ChromeLauncherController overrides: |
| 74 | 76 |
| 75 // Initializes this ChromeLauncherControllerPerApp. | 77 // Initializes this ChromeLauncherControllerPerApp. |
| 76 virtual void Init() OVERRIDE; | 78 virtual void Init() OVERRIDE; |
| 77 | 79 |
| 78 // Returns the new per application interface of the given launcher. If it is | 80 // Returns the new per application interface of the given launcher. If it is |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 290 |
| 289 // Checks if a given |web_contents| is known to be associated with an | 291 // Checks if a given |web_contents| is known to be associated with an |
| 290 // application of type |app_id|. | 292 // application of type |app_id|. |
| 291 bool IsWebContentHandledByApplication(content::WebContents* web_contents, | 293 bool IsWebContentHandledByApplication(content::WebContents* web_contents, |
| 292 const std::string& app_id); | 294 const std::string& app_id); |
| 293 | 295 |
| 294 // Get the favicon for the application list by giving the |web_content|. | 296 // Get the favicon for the application list by giving the |web_content|. |
| 295 // Note that for incognito windows the incognito icon will be returned. | 297 // Note that for incognito windows the incognito icon will be returned. |
| 296 gfx::Image GetAppListIcon(content::WebContents* web_contents) const; | 298 gfx::Image GetAppListIcon(content::WebContents* web_contents) const; |
| 297 | 299 |
| 300 // Overridden from chrome::BrowserListObserver. |
| 301 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; |
| 302 |
| 298 protected: | 303 protected: |
| 299 // ChromeLauncherController overrides: | 304 // ChromeLauncherController overrides: |
| 300 | 305 |
| 301 // Creates a new app shortcut item and controller on the launcher at |index|. | 306 // Creates a new app shortcut item and controller on the launcher at |index|. |
| 302 // Use kInsertItemAtEnd to add a shortcut as the last item. | 307 // Use kInsertItemAtEnd to add a shortcut as the last item. |
| 303 virtual ash::LauncherID CreateAppShortcutLauncherItem( | 308 virtual ash::LauncherID CreateAppShortcutLauncherItem( |
| 304 const std::string& app_id, | 309 const std::string& app_id, |
| 305 int index) OVERRIDE; | 310 int index) OVERRIDE; |
| 306 | 311 |
| 307 // Sets the AppTabHelper/AppIconLoader, taking ownership of the helper class. | 312 // Sets the AppTabHelper/AppIconLoader, taking ownership of the helper class. |
| 308 // These are intended for testing. | 313 // These are intended for testing. |
| 309 virtual void SetAppTabHelperForTest(AppTabHelper* helper) OVERRIDE; | 314 virtual void SetAppTabHelperForTest(AppTabHelper* helper) OVERRIDE; |
| 310 virtual void SetAppIconLoaderForTest(AppIconLoader* loader) OVERRIDE; | 315 virtual void SetAppIconLoaderForTest(AppIconLoader* loader) OVERRIDE; |
| 311 virtual const std::string& GetAppIdFromLauncherIdForTest( | 316 virtual const std::string& GetAppIdFromLauncherIdForTest( |
| 312 ash::LauncherID id) OVERRIDE; | 317 ash::LauncherID id) OVERRIDE; |
| 313 | 318 |
| 314 private: | 319 private: |
| 315 friend class ChromeLauncherControllerPerAppTest; | 320 friend class ChromeLauncherControllerPerAppTest; |
| 316 | 321 |
| 322 // Updates the activation state of the Broswer item. |
| 323 void UpdateBrowserItemStatus(); |
| 324 |
| 317 typedef std::map<ash::LauncherID, LauncherItemController*> | 325 typedef std::map<ash::LauncherID, LauncherItemController*> |
| 318 IDToItemControllerMap; | 326 IDToItemControllerMap; |
| 319 typedef std::list<content::WebContents*> WebContentsList; | 327 typedef std::list<content::WebContents*> WebContentsList; |
| 320 typedef std::map<std::string, WebContentsList> AppIDToWebContentsListMap; | 328 typedef std::map<std::string, WebContentsList> AppIDToWebContentsListMap; |
| 321 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap; | 329 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap; |
| 322 | 330 |
| 323 // Returns the profile used for new windows. | 331 // Returns the profile used for new windows. |
| 324 Profile* GetProfileForNewWindows(); | 332 Profile* GetProfileForNewWindows(); |
| 325 | 333 |
| 326 // Invoked when the associated browser or app is closed. | 334 // Invoked when the associated browser or app is closed. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 PrefChangeRegistrar pref_change_registrar_; | 402 PrefChangeRegistrar pref_change_registrar_; |
| 395 | 403 |
| 396 AppSyncUIState* app_sync_ui_state_; | 404 AppSyncUIState* app_sync_ui_state_; |
| 397 | 405 |
| 398 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; | 406 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; |
| 399 | 407 |
| 400 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPerApp); | 408 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPerApp); |
| 401 }; | 409 }; |
| 402 | 410 |
| 403 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_ | 411 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_ |
| OLD | NEW |