| 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_SHELL_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_SHELL_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
| 13 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 13 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 14 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
| 15 | 15 |
| 16 namespace apps { | 16 namespace apps { |
| 17 class AppWindow; | 17 class AppWindow; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace aura { | 20 namespace aura { |
| 21 class Window; | 21 class Window; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace gfx { | 24 namespace gfx { |
| 25 class Image; | 25 class Image; |
| 26 } | 26 } |
| 27 | 27 |
| 28 class ChromeLauncherController; | 28 class ChromeLauncherController; |
| 29 | 29 |
| 30 // This is a ShellWindowItemLauncherController for app windows. There is one | 30 // This is a LauncherItemController for app windows. There is one instance per |
| 31 // instance per app, per launcher id. | 31 // app, per launcher id. For apps with multiple windows, each item controller |
| 32 // For apps with multiple windows, each item controller keeps track of all | 32 // keeps track of all windows associated with the app and their activation |
| 33 // windows associated with the app and their activation order. | 33 // order. Instances are owned by ash::ShelfItemDelegateManager. |
| 34 // Instances are owned by ash::ShelfItemDelegateManager. | |
| 35 // | 34 // |
| 36 // Tests are in chrome_launcher_controller_browsertest.cc | 35 // Tests are in chrome_launcher_controller_browsertest.cc |
| 37 // | 36 class AppWindowLauncherItemController : public LauncherItemController, |
| 38 // TODO(jamescook): Rename to AppWindowLauncherItemController. | 37 public aura::WindowObserver { |
| 39 // http://crbug.com/344079 | |
| 40 class ShellWindowLauncherItemController : public LauncherItemController, | |
| 41 public aura::WindowObserver { | |
| 42 public: | 38 public: |
| 43 ShellWindowLauncherItemController(Type type, | 39 AppWindowLauncherItemController(Type type, |
| 44 const std::string& app_shelf_id, | 40 const std::string& app_shelf_id, |
| 45 const std::string& app_id, | 41 const std::string& app_id, |
| 46 ChromeLauncherController* controller); | 42 ChromeLauncherController* controller); |
| 47 | 43 |
| 48 virtual ~ShellWindowLauncherItemController(); | 44 virtual ~AppWindowLauncherItemController(); |
| 49 | 45 |
| 50 void AddAppWindow(apps::AppWindow* app_window, ash::ShelfItemStatus status); | 46 void AddAppWindow(apps::AppWindow* app_window, ash::ShelfItemStatus status); |
| 51 | 47 |
| 52 void RemoveShellWindowForWindow(aura::Window* window); | 48 void RemoveAppWindowForWindow(aura::Window* window); |
| 53 | 49 |
| 54 void SetActiveWindow(aura::Window* window); | 50 void SetActiveWindow(aura::Window* window); |
| 55 | 51 |
| 56 const std::string& app_shelf_id() const { return app_shelf_id_; } | 52 const std::string& app_shelf_id() const { return app_shelf_id_; } |
| 57 | 53 |
| 58 // LauncherItemController overrides: | 54 // LauncherItemController overrides: |
| 59 virtual bool IsOpen() const OVERRIDE; | 55 virtual bool IsOpen() const OVERRIDE; |
| 60 virtual bool IsVisible() const OVERRIDE; | 56 virtual bool IsVisible() const OVERRIDE; |
| 61 virtual void Launch(ash::LaunchSource source, int event_flags) OVERRIDE; | 57 virtual void Launch(ash::LaunchSource source, int event_flags) OVERRIDE; |
| 62 virtual bool Activate(ash::LaunchSource source) OVERRIDE; | 58 virtual bool Activate(ash::LaunchSource source) OVERRIDE; |
| 63 virtual ChromeLauncherAppMenuItems GetApplicationList( | 59 virtual ChromeLauncherAppMenuItems GetApplicationList(int event_flags) |
| 64 int event_flags) OVERRIDE; | 60 OVERRIDE; |
| 65 virtual bool ItemSelected(const ui::Event& eent) OVERRIDE; | 61 virtual bool ItemSelected(const ui::Event& eent) OVERRIDE; |
| 66 virtual base::string16 GetTitle() OVERRIDE; | 62 virtual base::string16 GetTitle() OVERRIDE; |
| 67 virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) OVERRIDE; | 63 virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) OVERRIDE; |
| 68 virtual ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE; | 64 virtual ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE; |
| 69 virtual bool IsDraggable() OVERRIDE; | 65 virtual bool IsDraggable() OVERRIDE; |
| 70 virtual bool ShouldShowTooltip() OVERRIDE; | 66 virtual bool ShouldShowTooltip() OVERRIDE; |
| 71 virtual void Close() OVERRIDE; | 67 virtual void Close() OVERRIDE; |
| 72 | 68 |
| 73 // aura::WindowObserver overrides: | 69 // aura::WindowObserver overrides: |
| 74 virtual void OnWindowPropertyChanged(aura::Window* window, | 70 virtual void OnWindowPropertyChanged(aura::Window* window, |
| 75 const void* key, | 71 const void* key, |
| 76 intptr_t old) OVERRIDE; | 72 intptr_t old) OVERRIDE; |
| 77 | 73 |
| 78 // Get the number of running applications/incarnations of this. | 74 // Get the number of running applications/incarnations of this. |
| 79 size_t app_window_count() const { return app_windows_.size(); } | 75 size_t app_window_count() const { return app_windows_.size(); } |
| 80 | 76 |
| 81 // Activates the window at position |index|. | 77 // Activates the window at position |index|. |
| 82 void ActivateIndexedApp(size_t index); | 78 void ActivateIndexedApp(size_t index); |
| 83 | 79 |
| 84 private: | 80 private: |
| 85 typedef std::list<apps::AppWindow*> AppWindowList; | 81 typedef std::list<apps::AppWindow*> AppWindowList; |
| 86 | 82 |
| 87 void ShowAndActivateOrMinimize(apps::AppWindow* app_window); | 83 void ShowAndActivateOrMinimize(apps::AppWindow* app_window); |
| 88 | 84 |
| 89 // Activate the given |window_to_show|, or - if already selected - advance to | 85 // Activate the given |window_to_show|, or - if already selected - advance to |
| 90 // the next window of similar type. | 86 // the next window of similar type. |
| 91 void ActivateOrAdvanceToNextShellWindow(apps::AppWindow* window_to_show); | 87 void ActivateOrAdvanceToNextAppWindow(apps::AppWindow* window_to_show); |
| 92 | 88 |
| 93 // List of associated app windows | 89 // List of associated app windows |
| 94 AppWindowList app_windows_; | 90 AppWindowList app_windows_; |
| 95 | 91 |
| 96 // Pointer to the most recently active app window | 92 // Pointer to the most recently active app window |
| 97 apps::AppWindow* last_active_app_window_; | 93 apps::AppWindow* last_active_app_window_; |
| 98 | 94 |
| 99 // The launcher id associated with this set of windows. There is one | 95 // The launcher id associated with this set of windows. There is one |
| 100 // AppLauncherItemController for each |app_shelf_id_|. | 96 // AppLauncherItemController for each |app_shelf_id_|. |
| 101 const std::string app_shelf_id_; | 97 const std::string app_shelf_id_; |
| 102 | 98 |
| 103 // Scoped list of observed windows (for removal on destruction) | 99 // Scoped list of observed windows (for removal on destruction) |
| 104 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; | 100 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; |
| 105 | 101 |
| 106 DISALLOW_COPY_AND_ASSIGN(ShellWindowLauncherItemController); | 102 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherItemController); |
| 107 }; | 103 }; |
| 108 | 104 |
| 109 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_SHELL_WINDOW_LAUNCHER_ITEM_CONTROLLER_
H_ | 105 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ |
| OLD | NEW |