| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_APP_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_APP_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 "ash/public/cpp/shelf_item_delegate.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/scoped_observer.h" | 13 #include "base/scoped_observer.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 aura { | 16 namespace aura { |
| 17 class Window; | 17 class Window; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace ui { | 20 namespace ui { |
| 21 class BaseWindow; | 21 class BaseWindow; |
| 22 } | 22 } |
| 23 | 23 |
| 24 class ChromeLauncherController; | 24 // This is a ShelfItemDelegate for abstract app windows (extension or ARC). |
| 25 | |
| 26 // This is a LauncherItemController for abstract app windows (extension or ARC). | |
| 27 // There is one instance per app, per launcher id. For apps with multiple | 25 // There is one instance per app, per launcher id. For apps with multiple |
| 28 // windows, each item controller keeps track of all windows associated with the | 26 // windows, each item controller keeps track of all windows associated with the |
| 29 // app and their activation order. Instances are owned by ash::ShelfModel. | 27 // app and their activation order. Instances are owned by ash::ShelfModel. |
| 30 // | 28 // |
| 31 // Tests are in chrome_launcher_controller_impl_browsertest.cc | 29 // Tests are in chrome_launcher_controller_impl_browsertest.cc |
| 32 class AppWindowLauncherItemController : public LauncherItemController, | 30 class AppWindowLauncherItemController : public ash::ShelfItemDelegate, |
| 33 public aura::WindowObserver { | 31 public aura::WindowObserver { |
| 34 public: | 32 public: |
| 35 using WindowList = std::list<ui::BaseWindow*>; | 33 using WindowList = std::list<ui::BaseWindow*>; |
| 36 | 34 |
| 37 ~AppWindowLauncherItemController() override; | 35 ~AppWindowLauncherItemController() override; |
| 38 | 36 |
| 39 void AddWindow(ui::BaseWindow* window); | 37 void AddWindow(ui::BaseWindow* window); |
| 40 void RemoveWindow(ui::BaseWindow* window); | 38 void RemoveWindow(ui::BaseWindow* window); |
| 41 | 39 |
| 42 void SetActiveWindow(aura::Window* window); | 40 void SetActiveWindow(aura::Window* window); |
| 43 ui::BaseWindow* GetAppWindow(aura::Window* window); | 41 ui::BaseWindow* GetAppWindow(aura::Window* window); |
| 44 | 42 |
| 45 // LauncherItemController overrides: | 43 // ash::ShelfItemDelegate overrides: |
| 46 AppWindowLauncherItemController* AsAppWindowLauncherItemController() override; | 44 AppWindowLauncherItemController* AsAppWindowLauncherItemController() override; |
| 47 void ItemSelected(std::unique_ptr<ui::Event> event, | 45 void ItemSelected(std::unique_ptr<ui::Event> event, |
| 48 int64_t display_id, | 46 int64_t display_id, |
| 49 ash::ShelfLaunchSource source, | 47 ash::ShelfLaunchSource source, |
| 50 const ItemSelectedCallback& callback) override; | 48 const ItemSelectedCallback& callback) override; |
| 51 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override; | 49 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override; |
| 52 void Close() override; | 50 void Close() override; |
| 53 | 51 |
| 54 // aura::WindowObserver overrides: | 52 // aura::WindowObserver overrides: |
| 55 void OnWindowPropertyChanged(aura::Window* window, | 53 void OnWindowPropertyChanged(aura::Window* window, |
| 56 const void* key, | 54 const void* key, |
| 57 intptr_t old) override; | 55 intptr_t old) override; |
| 58 | 56 |
| 59 // Get the number of running applications/incarnations of this. | 57 // Get the number of running applications/incarnations of this. |
| 60 size_t window_count() const { return windows_.size(); } | 58 size_t window_count() const { return windows_.size(); } |
| 61 | 59 |
| 62 // Activates the window at position |index|. | 60 // Activates the window at position |index|. |
| 63 void ActivateIndexedApp(size_t index); | 61 void ActivateIndexedApp(size_t index); |
| 64 | 62 |
| 65 const WindowList& windows() const { return windows_; } | 63 const WindowList& windows() const { return windows_; } |
| 66 | 64 |
| 67 protected: | 65 protected: |
| 68 AppWindowLauncherItemController(const ash::AppLaunchId& app_launch_id, | 66 explicit AppWindowLauncherItemController( |
| 69 ChromeLauncherController* controller); | 67 const ash::AppLaunchId& app_launch_id); |
| 70 | 68 |
| 71 // Called when app window is removed from controller. | 69 // Called when app window is removed from controller. |
| 72 virtual void OnWindowRemoved(ui::BaseWindow* window) {} | 70 virtual void OnWindowRemoved(ui::BaseWindow* window) {} |
| 73 | 71 |
| 74 // Returns the action performed. Should be one of SHELF_ACTION_NONE, | 72 // Returns the action performed. Should be one of SHELF_ACTION_NONE, |
| 75 // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_WINDOW_MINIMIZED. | 73 // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_WINDOW_MINIMIZED. |
| 76 ash::ShelfAction ShowAndActivateOrMinimize(ui::BaseWindow* window); | 74 ash::ShelfAction ShowAndActivateOrMinimize(ui::BaseWindow* window); |
| 77 | 75 |
| 78 // Activate the given |window_to_show|, or - if already selected - advance to | 76 // Activate the given |window_to_show|, or - if already selected - advance to |
| 79 // the next window of similar type. | 77 // the next window of similar type. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 91 // Pointer to the most recently active app window | 89 // Pointer to the most recently active app window |
| 92 ui::BaseWindow* last_active_window_ = nullptr; | 90 ui::BaseWindow* last_active_window_ = nullptr; |
| 93 | 91 |
| 94 // Scoped list of observed windows (for removal on destruction) | 92 // Scoped list of observed windows (for removal on destruction) |
| 95 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; | 93 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; |
| 96 | 94 |
| 97 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherItemController); | 95 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherItemController); |
| 98 }; | 96 }; |
| 99 | 97 |
| 100 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ | 98 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ |
| OLD | NEW |