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

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

Issue 23606016: Refactor LauncherItemController and LauncherItemDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for LauncherTest and observing LauncherModel in DelegateManager Created 7 years, 3 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 (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_LAUNCHER_ITEM_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_
7 7
8 #include "ash/launcher/launcher_item_delegate.h"
8 #include "ash/launcher/launcher_types.h" 9 #include "ash/launcher/launcher_types.h"
9 #include "base/basictypes.h" 10 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
12 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
13 14
14 class ChromeLauncherController; 15 class ChromeLauncherController;
15 class ChromeLauncherAppMenuItem; 16 class ChromeLauncherAppMenuItem;
16 17
17 typedef ScopedVector<ChromeLauncherAppMenuItem> ChromeLauncherAppMenuItems; 18 typedef ScopedVector<ChromeLauncherAppMenuItem> ChromeLauncherAppMenuItems;
18 19
19 namespace aura { 20 namespace aura {
20 class Window; 21 class Window;
21 } 22 }
22 23
23 namespace content { 24 namespace content {
24 class WebContents; 25 class WebContents;
25 } 26 }
26 27
27 // LauncherItemController is used by ChromeLauncherController to track one 28 // LauncherItemController is used by ChromeLauncherController to track one
28 // or more windows associated with a launcher item. 29 // or more windows associated with a launcher item.
29 class LauncherItemController { 30 class LauncherItemController : public ash::LauncherItemDelegate {
30 public: 31 public:
31 enum Type { 32 enum Type {
32 TYPE_APP, 33 TYPE_APP,
33 TYPE_APP_PANEL, 34 TYPE_APP_PANEL,
34 TYPE_SHORTCUT, 35 TYPE_SHORTCUT,
35 TYPE_WINDOWED_APP 36 TYPE_WINDOWED_APP
36 }; 37 };
37 38
38 LauncherItemController(Type type, 39 LauncherItemController(Type type,
39 const std::string& app_id, 40 const std::string& app_id,
(...skipping 14 matching lines...) Expand all
54 DCHECK(locked_); 55 DCHECK(locked_);
55 locked_--; 56 locked_--;
56 } 57 }
57 bool locked() { return locked_ > 0; } 58 bool locked() { return locked_ > 0; }
58 59
59 bool image_set_by_controller() const { return image_set_by_controller_; } 60 bool image_set_by_controller() const { return image_set_by_controller_; }
60 void set_image_set_by_controller(bool image_set_by_controller) { 61 void set_image_set_by_controller(bool image_set_by_controller) {
61 image_set_by_controller_ = image_set_by_controller; 62 image_set_by_controller_ = image_set_by_controller;
62 } 63 }
63 64
64 // Returns the title for this item.
65 virtual string16 GetTitle() = 0;
66
67 // Returns true if this item controls |window|. 65 // Returns true if this item controls |window|.
68 // When this |window| has multiple applications/tabs, it only returns true 66 // When this |window| has multiple applications/tabs, it only returns true
69 // it controls the currently visible app/tab. 67 // it controls the currently visible app/tab.
70 virtual bool IsCurrentlyShownInWindow(aura::Window* window) const = 0; 68 virtual bool IsCurrentlyShownInWindow(aura::Window* window) const = 0;
71 69
72 // Returns true if this item is open. 70 // Returns true if this item is open.
73 virtual bool IsOpen() const = 0; 71 virtual bool IsOpen() const = 0;
74 72
75 // Returns true if this item is visible (e.g. not minimized). 73 // Returns true if this item is visible (e.g. not minimized).
76 virtual bool IsVisible() const = 0; 74 virtual bool IsVisible() const = 0;
77 75
78 // Launches a new instance of the app associated with this item. 76 // Launches a new instance of the app associated with this item.
79 virtual void Launch(int event_flags) = 0; 77 virtual void Launch(int event_flags) = 0;
80 78
81 // Shows and activates the most-recently-active window associated with the 79 // Shows and activates the most-recently-active window associated with the
82 // item, or launches the item if it is not currently open. 80 // item, or launches the item if it is not currently open.
83 virtual void Activate() = 0; 81 virtual void Activate() = 0;
84 82
85 // Closes all windows associated with this item. 83 // Closes all windows associated with this item.
86 virtual void Close() = 0; 84 virtual void Close() = 0;
87 85
88 // Called when the item is clicked. The behavior varies by the number of
89 // windows associated with the item:
90 // * One window: toggles the minimize state.
91 // * Multiple windows: cycles the active window.
92 // The |event| is dispatched by a view, therefore the type of the
93 // event's target is |views::View|.
94 virtual void Clicked(const ui::Event& event) = 0;
95
96 // Called when the controlled item is removed from the launcher. 86 // Called when the controlled item is removed from the launcher.
97 virtual void OnRemoved() = 0; 87 virtual void OnRemoved() = 0;
98 88
99 // Called to retrieve the list of running applications.
100 virtual ChromeLauncherAppMenuItems GetApplicationList(int event_flags) = 0; 89 virtual ChromeLauncherAppMenuItems GetApplicationList(int event_flags) = 0;
101 90
102 // Helper function to get the ash::LauncherItemType for the item type. 91 // Helper function to get the ash::LauncherItemType for the item type.
103 ash::LauncherItemType GetLauncherItemType() const; 92 ash::LauncherItemType GetLauncherItemType() const;
104 93
105 protected: 94 protected:
106 // Helper function to return the title associated with |app_id_|. 95 // Helper function to return the title associated with |app_id_|.
107 // Returns an empty title if no matching extension can be found. 96 // Returns an empty title if no matching extension can be found.
108 string16 GetAppTitle() const; 97 string16 GetAppTitle() const;
109 98
110 private: 99 private:
111 const Type type_; 100 const Type type_;
112 // App id will be empty if there is no app associated with the window. 101 // App id will be empty if there is no app associated with the window.
113 const std::string app_id_; 102 const std::string app_id_;
114 ash::LauncherID launcher_id_; 103 ash::LauncherID launcher_id_;
115 ChromeLauncherController* launcher_controller_; 104 ChromeLauncherController* launcher_controller_;
116 105
117 // The lock counter which tells the launcher if the item can be removed from 106 // The lock counter which tells the launcher if the item can be removed from
118 // the launcher (0) or not (>0). It is being used for windowed V1 107 // the launcher (0) or not (>0). It is being used for windowed V1
119 // applications. 108 // applications.
120 int locked_; 109 int locked_;
121 110
122 // Set to true if the launcher item image has been set by the controller. 111 // Set to true if the launcher item image has been set by the controller.
123 bool image_set_by_controller_; 112 bool image_set_by_controller_;
124 113
125 DISALLOW_COPY_AND_ASSIGN(LauncherItemController); 114 DISALLOW_COPY_AND_ASSIGN(LauncherItemController);
126 }; 115 };
127 116
128 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ 117 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698