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

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

Issue 22429004: Refactor LauncherDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bugs Created 7 years, 4 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_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "ash/display/display_controller.h" 14 #include "ash/display/display_controller.h"
15 #include "ash/launcher/launcher_item_delegate.h"
15 #include "ash/launcher/launcher_model_observer.h" 16 #include "ash/launcher/launcher_model_observer.h"
16 #include "ash/launcher/launcher_types.h" 17 #include "ash/launcher/launcher_types.h"
17 #include "ash/shelf/shelf_layout_manager_observer.h" 18 #include "ash/shelf/shelf_layout_manager_observer.h"
18 #include "ash/shelf/shelf_types.h" 19 #include "ash/shelf/shelf_types.h"
19 #include "ash/shell_observer.h" 20 #include "ash/shell_observer.h"
20 #include "base/basictypes.h" 21 #include "base/basictypes.h"
21 #include "base/compiler_specific.h" 22 #include "base/compiler_specific.h"
22 #include "base/memory/scoped_ptr.h" 23 #include "base/memory/scoped_ptr.h"
23 #include "base/memory/scoped_vector.h" 24 #include "base/memory/scoped_vector.h"
24 #include "base/prefs/pref_change_registrar.h" 25 #include "base/prefs/pref_change_registrar.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // ChromeLauncherControllerPerApp manages the launcher items needed for content 63 // ChromeLauncherControllerPerApp manages the launcher items needed for content
63 // content windows. Launcher items have a type, an optional app id, and a 64 // content windows. Launcher items have a type, an optional app id, and a
64 // controller. This incarnation groups running tabs/windows in application 65 // controller. This incarnation groups running tabs/windows in application
65 // specific lists. 66 // specific lists.
66 // * Tabbed browsers and browser app windows have BrowserLauncherItemController, 67 // * Tabbed browsers and browser app windows have BrowserLauncherItemController,
67 // owned by the BrowserView instance. 68 // owned by the BrowserView instance.
68 // * App shell windows have ShellWindowLauncherItemController, owned by 69 // * App shell windows have ShellWindowLauncherItemController, owned by
69 // ShellWindowLauncherController. 70 // ShellWindowLauncherController.
70 // * Shortcuts have no LauncherItemController. 71 // * Shortcuts have no LauncherItemController.
71 class ChromeLauncherControllerPerApp 72 class ChromeLauncherControllerPerApp
72 : public ash::LauncherModelObserver, 73 : public ash::LauncherItemDelegate,
74 public ash::LauncherModelObserver,
73 public ash::ShellObserver, 75 public ash::ShellObserver,
74 public ash::DisplayController::Observer, 76 public ash::DisplayController::Observer,
75 public ChromeLauncherController, 77 public ChromeLauncherController,
76 public content::NotificationObserver, 78 public content::NotificationObserver,
77 public PrefServiceSyncableObserver, 79 public PrefServiceSyncableObserver,
78 public AppSyncUIStateObserver, 80 public AppSyncUIStateObserver,
79 public ExtensionEnableFlowDelegate, 81 public ExtensionEnableFlowDelegate,
80 public chrome::BrowserListObserver, 82 public chrome::BrowserListObserver,
81 public ash::ShelfLayoutManagerObserver { 83 public ash::ShelfLayoutManagerObserver {
82 public: 84 public:
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Used by the app-list, and by pinned-app launcher items. 168 // Used by the app-list, and by pinned-app launcher items.
167 virtual void ActivateApp(const std::string& app_id, int event_flags) OVERRIDE; 169 virtual void ActivateApp(const std::string& app_id, int event_flags) OVERRIDE;
168 170
169 // Returns the launch type of app for the specified id. 171 // Returns the launch type of app for the specified id.
170 virtual extensions::ExtensionPrefs::LaunchType GetLaunchType( 172 virtual extensions::ExtensionPrefs::LaunchType GetLaunchType(
171 ash::LauncherID id) OVERRIDE; 173 ash::LauncherID id) OVERRIDE;
172 174
173 // Returns the id of the app for the specified tab. 175 // Returns the id of the app for the specified tab.
174 virtual std::string GetAppID(content::WebContents* tab) OVERRIDE; 176 virtual std::string GetAppID(content::WebContents* tab) OVERRIDE;
175 177
176 // Returns the |LauncherModel|'s ID or 0 if the AppId was not found.
177 virtual ash::LauncherID GetLauncherIDForAppID(
178 const std::string& app_id) OVERRIDE;
179 virtual std::string GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE; 178 virtual std::string GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE;
180 179
181 // Set the image for a specific launcher item (e.g. when set by the app). 180 // Set the image for a specific launcher item (e.g. when set by the app).
182 virtual void SetLauncherItemImage(ash::LauncherID launcher_id, 181 virtual void SetLauncherItemImage(ash::LauncherID launcher_id,
183 const gfx::ImageSkia& image) OVERRIDE; 182 const gfx::ImageSkia& image) OVERRIDE;
184 183
185 // Returns true if a pinned launcher item with given |app_id| could be found.
186 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE;
187 184
188 // Find out if the given application |id| is a windowed app item and not a 185 // Find out if the given application |id| is a windowed app item and not a
189 // pinned item in the launcher. 186 // pinned item in the launcher.
190 bool IsWindowedAppInLauncher(const std::string& app_id); 187 bool IsWindowedAppInLauncher(const std::string& app_id);
191 188
192 // Pins an app with |app_id| to launcher. If there is a running instance in
193 // launcher, the running instance is pinned. If there is no running instance,
194 // a new launcher item is created and pinned.
195 virtual void PinAppWithID(const std::string& app_id) OVERRIDE;
196 189
197 // Updates the launche type of the app for the specified id to |launch_type|. 190 // Updates the launche type of the app for the specified id to |launch_type|.
198 virtual void SetLaunchType( 191 virtual void SetLaunchType(
199 ash::LauncherID id, 192 ash::LauncherID id,
200 extensions::ExtensionPrefs::LaunchType launch_type) OVERRIDE; 193 extensions::ExtensionPrefs::LaunchType launch_type) OVERRIDE;
201 194
202 // Unpins any app items whose id is |app_id|.
203 virtual void UnpinAppsWithID(const std::string& app_id) OVERRIDE;
204
205 // Returns true if the user is currently logged in as a guest. 195 // Returns true if the user is currently logged in as a guest.
206 virtual bool IsLoggedInAsGuest() OVERRIDE; 196 virtual bool IsLoggedInAsGuest() OVERRIDE;
207 197
208 // Invoked when user clicks on button in the launcher and there is no last 198 // Invoked when user clicks on button in the launcher and there is no last
209 // used window (or CTRL is held with the click). 199 // used window (or CTRL is held with the click).
210 virtual void CreateNewWindow() OVERRIDE; 200 virtual void CreateNewWindow() OVERRIDE;
211 201
212 // Invoked when the user clicks on button in the launcher to create a new 202 // Invoked when the user clicks on button in the launcher to create a new
213 // incognito window. 203 // incognito window.
214 virtual void CreateNewIncognitoWindow() OVERRIDE; 204 virtual void CreateNewIncognitoWindow() OVERRIDE;
215 205
216 // Checks whether the user is allowed to pin apps. Pinning may be disallowed
217 // by policy in case there is a pre-defined set of pinned apps.
218 virtual bool CanPin() const OVERRIDE;
219
220 // Updates the pinned pref state. The pinned state consists of a list pref. 206 // Updates the pinned pref state. The pinned state consists of a list pref.
221 // Each item of the list is a dictionary. The key |kAppIDPath| gives the 207 // Each item of the list is a dictionary. The key |kAppIDPath| gives the
222 // id of the app. 208 // id of the app.
223 virtual void PersistPinnedState() OVERRIDE; 209 virtual void PersistPinnedState() OVERRIDE;
224 210
225 virtual ash::LauncherModel* model() OVERRIDE; 211 virtual ash::LauncherModel* model() OVERRIDE;
226 212
227 virtual Profile* profile() OVERRIDE; 213 virtual Profile* profile() OVERRIDE;
228 214
229 // Gets the shelf auto-hide behavior on |root_window|. 215 // Gets the shelf auto-hide behavior on |root_window|.
(...skipping 25 matching lines...) Expand all
255 241
256 // Returns the extension identified by |app_id|. 242 // Returns the extension identified by |app_id|.
257 virtual const extensions::Extension* GetExtensionForAppID( 243 virtual const extensions::Extension* GetExtensionForAppID(
258 const std::string& app_id) const OVERRIDE; 244 const std::string& app_id) const OVERRIDE;
259 245
260 // Activates a |window|. If |allow_minimize| is true and the system allows 246 // Activates a |window|. If |allow_minimize| is true and the system allows
261 // it, the the window will get minimized instead. 247 // it, the the window will get minimized instead.
262 virtual void ActivateWindowOrMinimizeIfActive(ui::BaseWindow* window, 248 virtual void ActivateWindowOrMinimizeIfActive(ui::BaseWindow* window,
263 bool allow_minimize) OVERRIDE; 249 bool allow_minimize) OVERRIDE;
264 250
265 // ash::LauncherDelegate overrides: 251 // Checks whether the user is allowed to pin apps. Pinning may be disallowed
252 // by policy in case there is a pre-defined set of pinned apps.
253 virtual bool CanPin() const OVERRIDE;
254
255 // ash::LauncherItemDelegate overrides:
266 virtual void ItemSelected(const ash::LauncherItem& item, 256 virtual void ItemSelected(const ash::LauncherItem& item,
267 const ui::Event& event) OVERRIDE; 257 const ui::Event& event) OVERRIDE;
268 virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE; 258 virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE;
269 virtual ui::MenuModel* CreateContextMenu( 259 virtual ui::MenuModel* CreateContextMenu(
270 const ash::LauncherItem& item, aura::RootWindow* root) OVERRIDE; 260 const ash::LauncherItem& item, aura::RootWindow* root) OVERRIDE;
271 virtual ash::LauncherMenuModel* CreateApplicationMenu( 261 virtual ash::LauncherMenuModel* CreateApplicationMenu(
272 const ash::LauncherItem& item, 262 const ash::LauncherItem& item,
273 int event_flags) OVERRIDE; 263 int event_flags) OVERRIDE;
274 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE;
275 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE; 264 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE;
276 virtual bool ShouldShowTooltip(const ash::LauncherItem& item) OVERRIDE; 265 virtual bool ShouldShowTooltip(const ash::LauncherItem& item) OVERRIDE;
266
267 // ash::LauncherDelegate overrides:
268 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE;
277 virtual void OnLauncherCreated(ash::Launcher* launcher) OVERRIDE; 269 virtual void OnLauncherCreated(ash::Launcher* launcher) OVERRIDE;
278 virtual void OnLauncherDestroyed(ash::Launcher* launcher) OVERRIDE; 270 virtual void OnLauncherDestroyed(ash::Launcher* launcher) OVERRIDE;
271 virtual ash::LauncherID GetLauncherIDForAppID(
272 const std::string& app_id) OVERRIDE;
273 virtual void PinAppWithID(const std::string& app_id) OVERRIDE;
274 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE;
275 virtual void UnpinAppsWithID(const std::string& app_id) OVERRIDE;
276 virtual ash::LauncherItemDelegate* GetLauncherItemDelegate(
277 const ash::LauncherItem& item) OVERRIDE;
279 278
280 // ash::LauncherModelObserver overrides: 279 // ash::LauncherModelObserver overrides:
281 virtual void LauncherItemAdded(int index) OVERRIDE; 280 virtual void LauncherItemAdded(int index) OVERRIDE;
282 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE; 281 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE;
283 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; 282 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE;
284 virtual void LauncherItemChanged(int index, 283 virtual void LauncherItemChanged(int index,
285 const ash::LauncherItem& old_item) OVERRIDE; 284 const ash::LauncherItem& old_item) OVERRIDE;
286 virtual void LauncherStatusChanged() OVERRIDE; 285 virtual void LauncherStatusChanged() OVERRIDE;
287 286
288 // content::NotificationObserver overrides: 287 // content::NotificationObserver overrides:
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 // The owned browser shortcut item. 498 // The owned browser shortcut item.
500 scoped_ptr<BrowserShortcutLauncherItemController> browser_item_controller_; 499 scoped_ptr<BrowserShortcutLauncherItemController> browser_item_controller_;
501 500
502 // If true, incoming pinned state changes should be ignored. 501 // If true, incoming pinned state changes should be ignored.
503 bool ignore_persist_pinned_state_change_; 502 bool ignore_persist_pinned_state_change_;
504 503
505 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPerApp); 504 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPerApp);
506 }; 505 };
507 506
508 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_ 507 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698