| 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_SHELL_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_SHELL_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 { |
| 17 class ShellWindow; |
| 18 } |
| 19 |
| 16 namespace aura { | 20 namespace aura { |
| 17 class Window; | 21 class Window; |
| 18 } | 22 } |
| 19 | 23 |
| 20 namespace gfx { | 24 namespace gfx { |
| 21 class Image; | 25 class Image; |
| 22 } | 26 } |
| 23 | 27 |
| 24 class ChromeLauncherController; | 28 class ChromeLauncherController; |
| 25 class ShellWindow; | |
| 26 | 29 |
| 27 // This is a ShellWindowItemLauncherController for shell windows. There is one | 30 // This is a ShellWindowItemLauncherController for shell windows. There is one |
| 28 // instance per app, per launcher id. | 31 // instance per app, per launcher id. |
| 29 // For apps with multiple windows, each item controller keeps track of all | 32 // For apps with multiple windows, each item controller keeps track of all |
| 30 // windows associated with the app and their activation order. | 33 // windows associated with the app and their activation order. |
| 31 // Instances are owned by ShellWindowLauncherController. | 34 // Instances are owned by ShellWindowLauncherController. |
| 32 // | 35 // |
| 33 // Tests are in chrome_launcher_controller_browsertest.cc | 36 // Tests are in chrome_launcher_controller_browsertest.cc |
| 34 | 37 |
| 35 class ShellWindowLauncherItemController : public LauncherItemController, | 38 class ShellWindowLauncherItemController : public LauncherItemController, |
| 36 public aura::WindowObserver { | 39 public aura::WindowObserver { |
| 37 public: | 40 public: |
| 38 ShellWindowLauncherItemController(Type type, | 41 ShellWindowLauncherItemController(Type type, |
| 39 const std::string& app_launcher_id, | 42 const std::string& app_launcher_id, |
| 40 const std::string& app_id, | 43 const std::string& app_id, |
| 41 ChromeLauncherController* controller); | 44 ChromeLauncherController* controller); |
| 42 | 45 |
| 43 virtual ~ShellWindowLauncherItemController(); | 46 virtual ~ShellWindowLauncherItemController(); |
| 44 | 47 |
| 45 void AddShellWindow(ShellWindow* shell_window, | 48 void AddShellWindow(apps::ShellWindow* shell_window, |
| 46 ash::LauncherItemStatus status); | 49 ash::LauncherItemStatus status); |
| 47 | 50 |
| 48 void RemoveShellWindowForWindow(aura::Window* window); | 51 void RemoveShellWindowForWindow(aura::Window* window); |
| 49 | 52 |
| 50 void SetActiveWindow(aura::Window* window); | 53 void SetActiveWindow(aura::Window* window); |
| 51 | 54 |
| 52 const std::string& app_launcher_id() const { return app_launcher_id_; } | 55 const std::string& app_launcher_id() const { return app_launcher_id_; } |
| 53 | 56 |
| 54 // LauncherItemController | 57 // LauncherItemController |
| 55 virtual string16 GetTitle() OVERRIDE; | 58 virtual string16 GetTitle() OVERRIDE; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 72 const void* key, | 75 const void* key, |
| 73 intptr_t old) OVERRIDE; | 76 intptr_t old) OVERRIDE; |
| 74 | 77 |
| 75 // Get the number of running applications/incarnations of this. | 78 // Get the number of running applications/incarnations of this. |
| 76 size_t shell_window_count() const { return shell_windows_.size(); } | 79 size_t shell_window_count() const { return shell_windows_.size(); } |
| 77 | 80 |
| 78 // Activates the window at position |index|. | 81 // Activates the window at position |index|. |
| 79 void ActivateIndexedApp(size_t index); | 82 void ActivateIndexedApp(size_t index); |
| 80 | 83 |
| 81 private: | 84 private: |
| 82 typedef std::list<ShellWindow*> ShellWindowList; | 85 typedef std::list<apps::ShellWindow*> ShellWindowList; |
| 83 | 86 |
| 84 void ShowAndActivateOrMinimize(ShellWindow* shell_window); | 87 void ShowAndActivateOrMinimize(apps::ShellWindow* shell_window); |
| 85 | 88 |
| 86 // Activate the given |window_to_show|, or - if already selected - advance to | 89 // Activate the given |window_to_show|, or - if already selected - advance to |
| 87 // the next window of similar type. | 90 // the next window of similar type. |
| 88 void ActivateOrAdvanceToNextShellWindow(ShellWindow* window_to_show); | 91 void ActivateOrAdvanceToNextShellWindow(apps::ShellWindow* window_to_show); |
| 89 | 92 |
| 90 // List of associated shell windows | 93 // List of associated shell windows |
| 91 ShellWindowList shell_windows_; | 94 ShellWindowList shell_windows_; |
| 92 | 95 |
| 93 // Pointer to the most recently active shell window | 96 // Pointer to the most recently active shell window |
| 94 ShellWindow* last_active_shell_window_; | 97 apps::ShellWindow* last_active_shell_window_; |
| 95 | 98 |
| 96 // The launcher id associated with this set of windows. There is one | 99 // The launcher id associated with this set of windows. There is one |
| 97 // AppLauncherItemController for each |app_launcher_id_|. | 100 // AppLauncherItemController for each |app_launcher_id_|. |
| 98 const std::string app_launcher_id_; | 101 const std::string app_launcher_id_; |
| 99 | 102 |
| 100 // Scoped list of observed windows (for removal on destruction) | 103 // Scoped list of observed windows (for removal on destruction) |
| 101 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; | 104 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; |
| 102 | 105 |
| 103 DISALLOW_COPY_AND_ASSIGN(ShellWindowLauncherItemController); | 106 DISALLOW_COPY_AND_ASSIGN(ShellWindowLauncherItemController); |
| 104 }; | 107 }; |
| 105 | 108 |
| 106 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_SHELL_WINDOW_LAUNCHER_ITEM_CONTROLLER_
H_ | 109 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_SHELL_WINDOW_LAUNCHER_ITEM_CONTROLLER_
H_ |
| OLD | NEW |