Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h

Issue 1823923002: arc: Support running Arc app in shelf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, tests, cleanup Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h>
9
10 #include <list> 8 #include <list>
11 #include <string> 9 #include <string>
12 10
13 #include "base/macros.h" 11 #include "base/macros.h"
14 #include "base/scoped_observer.h" 12 #include "base/scoped_observer.h"
15 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 13 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
16 #include "ui/aura/window_observer.h" 14 #include "ui/aura/window_observer.h"
17 15
18 namespace aura { 16 namespace aura {
19 class Window; 17 class Window;
20 } 18 }
21 19
22 namespace extensions { 20 namespace ui {
23 class AppWindow; 21 class BaseWindow;
24 } 22 }
25 23
26 class ChromeLauncherController; 24 class ChromeLauncherController;
27 25
28 // This is a LauncherItemController for app windows. There is one instance per 26 // This is a LauncherItemController for abstract app windows. There is one
29 // app, per launcher id. For apps with multiple windows, each item controller 27 // instance per app, per launcher id. For apps with multiple windows, each item
30 // keeps track of all windows associated with the app and their activation 28 // controller keeps track of all windows associated with the app and their
31 // order. Instances are owned by ash::ShelfItemDelegateManager. 29 // activation order. Instances are owned by ash::ShelfItemDelegateManager.
32 // 30 //
33 // Tests are in chrome_launcher_controller_browsertest.cc 31 // Tests are in chrome_launcher_controller_browsertest.cc
34 class AppWindowLauncherItemController : public LauncherItemController, 32 class AppWindowLauncherItemController : public LauncherItemController,
35 public aura::WindowObserver { 33 public aura::WindowObserver {
36 public: 34 public:
37 AppWindowLauncherItemController(Type type,
38 const std::string& app_shelf_id,
39 const std::string& app_id,
40 ChromeLauncherController* controller);
41
42 ~AppWindowLauncherItemController() override; 35 ~AppWindowLauncherItemController() override;
43 36
44 void AddAppWindow(extensions::AppWindow* app_window, 37 void AddWindow(ui::BaseWindow* window);
45 ash::ShelfItemStatus status);
46 38
47 void RemoveAppWindowForWindow(aura::Window* window); 39 void RemoveWindowForNativeWindow(aura::Window* window);
48 40
49 void SetActiveWindow(aura::Window* window); 41 void SetActiveWindow(aura::Window* window);
50 42
51 const std::string& app_shelf_id() const { return app_shelf_id_; } 43 const std::string& app_shelf_id() const { return app_shelf_id_; }
52 44
53 // LauncherItemController overrides: 45 // LauncherItemController overrides:
54 bool IsOpen() const override; 46 bool IsOpen() const override;
55 bool IsVisible() const override; 47 bool IsVisible() const override;
56 void Launch(ash::LaunchSource source, int event_flags) override; 48 void Launch(ash::LaunchSource source, int event_flags) override;
57 ash::ShelfItemDelegate::PerformedAction Activate( 49 ash::ShelfItemDelegate::PerformedAction Activate(
58 ash::LaunchSource source) override; 50 ash::LaunchSource source) override;
59 ChromeLauncherAppMenuItems GetApplicationList(int event_flags) override; 51 ChromeLauncherAppMenuItems GetApplicationList(int event_flags) override;
60 ash::ShelfItemDelegate::PerformedAction ItemSelected( 52 ash::ShelfItemDelegate::PerformedAction ItemSelected(
61 const ui::Event& eent) override; 53 const ui::Event& eent) override;
62 base::string16 GetTitle() override; 54 base::string16 GetTitle() override;
63 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override; 55 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override;
64 bool IsDraggable() override; 56 bool IsDraggable() override;
65 bool CanPin() const override; 57 bool CanPin() const override;
66 bool ShouldShowTooltip() override; 58 bool ShouldShowTooltip() override;
67 void Close() override; 59 void Close() override;
68 60
69 // aura::WindowObserver overrides: 61 // aura::WindowObserver overrides:
70 void OnWindowPropertyChanged(aura::Window* window, 62 void OnWindowPropertyChanged(aura::Window* window,
71 const void* key, 63 const void* key,
72 intptr_t old) override; 64 intptr_t old) override;
73 65
74 // Get the number of running applications/incarnations of this. 66 // Get the number of running applications/incarnations of this.
75 size_t app_window_count() const { return app_windows_.size(); } 67 size_t window_count() const { return windows_.size(); }
76 68
77 // Activates the window at position |index|. 69 // Activates the window at position |index|.
78 void ActivateIndexedApp(size_t index); 70 void ActivateIndexedApp(size_t index);
79 71
80 private: 72 protected:
81 typedef std::list<extensions::AppWindow*> AppWindowList; 73 typedef std::list<ui::BaseWindow*> WindowList;
xiyuan 2016/03/23 23:22:53 nit: using WindowList = std::list<ui::BaseWindow*>
khmel 2016/03/24 16:30:37 Done.
74
75 AppWindowLauncherItemController(Type type,
76 const std::string& app_shelf_id,
77 const std::string& app_id,
78 ChromeLauncherController* controller);
79
80 // Called when app window is removed from controller.
81 virtual void OnWindowRemoved(ui::BaseWindow* window) {}
82 82
83 // Returns the action performed. Should be one of kNoAction, 83 // Returns the action performed. Should be one of kNoAction,
84 // kExistingWindowActivated, or kExistingWindowMinimized. 84 // kExistingWindowActivated, or kExistingWindowMinimized.
85 ash::ShelfItemDelegate::PerformedAction ShowAndActivateOrMinimize( 85 ash::ShelfItemDelegate::PerformedAction ShowAndActivateOrMinimize(
86 extensions::AppWindow* app_window); 86 ui::BaseWindow* window);
87 87
88 // Activate the given |window_to_show|, or - if already selected - advance to 88 // Activate the given |window_to_show|, or - if already selected - advance to
89 // the next window of similar type. 89 // the next window of similar type.
90 // Returns the action performed. Should be one of kNoAction, 90 // Returns the action performed. Should be one of kNoAction,
91 // kExistingWindowActivated, or kExistingWindowMinimized. 91 // kExistingWindowActivated, or kExistingWindowMinimized.
92 ash::ShelfItemDelegate::PerformedAction ActivateOrAdvanceToNextAppWindow( 92 ash::ShelfItemDelegate::PerformedAction ActivateOrAdvanceToNextAppWindow(
93 extensions::AppWindow* window_to_show); 93 ui::BaseWindow* window_to_show);
94 94
95 const WindowList& windows() { return windows_; }
96
97 private:
95 // List of associated app windows 98 // List of associated app windows
96 AppWindowList app_windows_; 99 WindowList windows_;
97 100
98 // Pointer to the most recently active app window 101 // Pointer to the most recently active app window
99 extensions::AppWindow* last_active_app_window_; 102 ui::BaseWindow* last_active_window_ = nullptr;
100 103
101 // The launcher id associated with this set of windows. There is one 104 // The launcher id associated with this set of windows. There is one
102 // AppLauncherItemController for each |app_shelf_id_|. 105 // AppLauncherItemController for each |app_shelf_id_|.
103 const std::string app_shelf_id_; 106 const std::string app_shelf_id_;
104 107
105 // Scoped list of observed windows (for removal on destruction) 108 // Scoped list of observed windows (for removal on destruction)
106 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; 109 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_;
107 110
108 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherItemController); 111 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherItemController);
109 }; 112 };
110 113
111 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ 114 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698