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

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

Issue 22429004: Refactor LauncherDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some comments 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_BROWSER_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_BROWSER_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_BROWSER_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_BROWSER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "ash/display/display_controller.h" 12 #include "ash/display/display_controller.h"
13 #include "ash/launcher/launcher_delegate.h" 13 #include "ash/launcher/launcher_item_delegate.h"
14 #include "ash/launcher/launcher_model_observer.h" 14 #include "ash/launcher/launcher_model_observer.h"
15 #include "ash/launcher/launcher_types.h" 15 #include "ash/launcher/launcher_types.h"
16 #include "ash/shelf/shelf_layout_manager_observer.h" 16 #include "ash/shelf/shelf_layout_manager_observer.h"
17 #include "ash/shelf/shelf_types.h" 17 #include "ash/shelf/shelf_types.h"
18 #include "ash/shell_observer.h" 18 #include "ash/shell_observer.h"
19 #include "base/basictypes.h" 19 #include "base/basictypes.h"
20 #include "base/compiler_specific.h" 20 #include "base/compiler_specific.h"
21 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
22 #include "base/prefs/pref_change_registrar.h" 22 #include "base/prefs/pref_change_registrar.h"
23 #include "chrome/browser/extensions/extension_prefs.h" 23 #include "chrome/browser/extensions/extension_prefs.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // ChromeLauncherControllerPerBrowser manages the launcher items needed for 56 // ChromeLauncherControllerPerBrowser manages the launcher items needed for
57 // content windows. Launcher items have a type, an optional app id, and a 57 // content windows. Launcher items have a type, an optional app id, and a
58 // controller. This incarnation manages the items on a per browser base using 58 // controller. This incarnation manages the items on a per browser base using
59 // browser proxies and application icons. 59 // browser proxies and application icons.
60 // * Tabbed browsers and browser app windows have BrowserLauncherItemController, 60 // * Tabbed browsers and browser app windows have BrowserLauncherItemController,
61 // owned by the BrowserView instance. 61 // owned by the BrowserView instance.
62 // * App shell windows have ShellWindowLauncherItemController, owned by 62 // * App shell windows have ShellWindowLauncherItemController, owned by
63 // ShellWindowLauncherController. 63 // ShellWindowLauncherController.
64 // * Shortcuts have no LauncherItemController. 64 // * Shortcuts have no LauncherItemController.
65 class ChromeLauncherControllerPerBrowser 65 class ChromeLauncherControllerPerBrowser
66 : public ash::LauncherModelObserver, 66 : public ash::LauncherItemDelegate,
67 public ash::LauncherModelObserver,
67 public ash::ShellObserver, 68 public ash::ShellObserver,
68 public ash::DisplayController::Observer, 69 public ash::DisplayController::Observer,
69 public ChromeLauncherController, 70 public ChromeLauncherController,
70 public content::NotificationObserver, 71 public content::NotificationObserver,
71 public PrefServiceSyncableObserver, 72 public PrefServiceSyncableObserver,
72 public AppSyncUIStateObserver, 73 public AppSyncUIStateObserver,
73 public ExtensionEnableFlowDelegate, 74 public ExtensionEnableFlowDelegate,
74 public ash::ShelfLayoutManagerObserver { 75 public ash::ShelfLayoutManagerObserver {
75 public: 76 public:
76 ChromeLauncherControllerPerBrowser(Profile* profile, 77 ChromeLauncherControllerPerBrowser(Profile* profile,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // Used by the app-list, and by pinned-app launcher items. 160 // Used by the app-list, and by pinned-app launcher items.
160 virtual void ActivateApp(const std::string& app_id, int event_flags) OVERRIDE; 161 virtual void ActivateApp(const std::string& app_id, int event_flags) OVERRIDE;
161 162
162 // Returns the launch type of app for the specified id. 163 // Returns the launch type of app for the specified id.
163 virtual extensions::ExtensionPrefs::LaunchType GetLaunchType( 164 virtual extensions::ExtensionPrefs::LaunchType GetLaunchType(
164 ash::LauncherID id) OVERRIDE; 165 ash::LauncherID id) OVERRIDE;
165 166
166 // Returns the id of the app for the specified tab. 167 // Returns the id of the app for the specified tab.
167 virtual std::string GetAppID(content::WebContents* tab) OVERRIDE; 168 virtual std::string GetAppID(content::WebContents* tab) OVERRIDE;
168 169
169 virtual ash::LauncherID GetLauncherIDForAppID(
170 const std::string& app_id) OVERRIDE;
171 virtual std::string GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE; 170 virtual std::string GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE;
172 171
173 // Set the image for a specific launcher item (e.g. when set by the app). 172 // Set the image for a specific launcher item (e.g. when set by the app).
174 virtual void SetLauncherItemImage(ash::LauncherID launcher_id, 173 virtual void SetLauncherItemImage(ash::LauncherID launcher_id,
175 const gfx::ImageSkia& image) OVERRIDE; 174 const gfx::ImageSkia& image) OVERRIDE;
176 175
177 // Returns true if a pinned launcher item with given |app_id| could be found.
178 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE;
179
180 // Pins an app with |app_id| to launcher. If there is a running instance in
181 // launcher, the running instance is pinned. If there is no running instance,
182 // a new launcher item is created and pinned.
183 virtual void PinAppWithID(const std::string& app_id) OVERRIDE;
184
185 // Updates the launche type of the app for the specified id to |launch_type|. 176 // Updates the launche type of the app for the specified id to |launch_type|.
186 virtual void SetLaunchType( 177 virtual void SetLaunchType(
187 ash::LauncherID id, 178 ash::LauncherID id,
188 extensions::ExtensionPrefs::LaunchType launch_type) OVERRIDE; 179 extensions::ExtensionPrefs::LaunchType launch_type) OVERRIDE;
189 180
190 // Unpins any app items whose id is |app_id|.
191 virtual void UnpinAppsWithID(const std::string& app_id) OVERRIDE;
192
193 // Returns true if the user is currently logged in as a guest. 181 // Returns true if the user is currently logged in as a guest.
194 virtual bool IsLoggedInAsGuest() OVERRIDE; 182 virtual bool IsLoggedInAsGuest() OVERRIDE;
195 183
196 // Invoked when user clicks on button in the launcher and there is no last 184 // Invoked when user clicks on button in the launcher and there is no last
197 // used window (or CTRL is held with the click). 185 // used window (or CTRL is held with the click).
198 virtual void CreateNewWindow() OVERRIDE; 186 virtual void CreateNewWindow() OVERRIDE;
199 187
200 // Invoked when the user clicks on button in the launcher to create a new 188 // Invoked when the user clicks on button in the launcher to create a new
201 // incognito window. 189 // incognito window.
202 virtual void CreateNewIncognitoWindow() OVERRIDE; 190 virtual void CreateNewIncognitoWindow() OVERRIDE;
203 191
204 // Checks whether the user is allowed to pin apps. Pinning may be disallowed
205 // by policy in case there is a pre-defined set of pinned apps.
206 virtual bool CanPin() const OVERRIDE;
207
208 // Updates the pinned pref state. The pinned state consists of a list pref. 192 // Updates the pinned pref state. The pinned state consists of a list pref.
209 // Each item of the list is a dictionary. The key |kAppIDPath| gives the 193 // Each item of the list is a dictionary. The key |kAppIDPath| gives the
210 // id of the app. 194 // id of the app.
211 virtual void PersistPinnedState() OVERRIDE; 195 virtual void PersistPinnedState() OVERRIDE;
212 196
213 virtual ash::LauncherModel* model() OVERRIDE; 197 virtual ash::LauncherModel* model() OVERRIDE;
214 198
215 virtual Profile* profile() OVERRIDE; 199 virtual Profile* profile() OVERRIDE;
216 200
217 // Gets the shelf auto-hide behavior on |root_window|. 201 // Gets the shelf auto-hide behavior on |root_window|.
(...skipping 25 matching lines...) Expand all
243 227
244 // Returns the extension identified by |app_id|. 228 // Returns the extension identified by |app_id|.
245 virtual const extensions::Extension* GetExtensionForAppID( 229 virtual const extensions::Extension* GetExtensionForAppID(
246 const std::string& app_id) const OVERRIDE; 230 const std::string& app_id) const OVERRIDE;
247 231
248 // Activates a |window|. If |allow_minimize| is true and the system allows 232 // Activates a |window|. If |allow_minimize| is true and the system allows
249 // it, the the window will get minimized instead. 233 // it, the the window will get minimized instead.
250 virtual void ActivateWindowOrMinimizeIfActive(ui::BaseWindow* window, 234 virtual void ActivateWindowOrMinimizeIfActive(ui::BaseWindow* window,
251 bool allow_minimize) OVERRIDE; 235 bool allow_minimize) OVERRIDE;
252 236
237 // Checks whether the user is allowed to pin apps. Pinning may be disallowed
238 // by policy in case there is a pre-defined set of pinned apps.
239 virtual bool CanPin() const OVERRIDE;
240
253 // ash::LauncherDelegate overrides: 241 // ash::LauncherDelegate overrides:
242 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE;
243 virtual void OnLauncherCreated(ash::Launcher* launcher) OVERRIDE;
244 virtual void OnLauncherDestroyed(ash::Launcher* launcher) OVERRIDE;
245 virtual ash::LauncherID GetLauncherIDForAppID(
246 const std::string& app_id) OVERRIDE;
247 virtual void PinAppWithID(const std::string& app_id) OVERRIDE;
248 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE;
249 virtual void UnpinAppsWithID(const std::string& app_id) OVERRIDE;
250 virtual ash::LauncherItemDelegate* GetLauncherItemDelegate(
251 const ash::LauncherItem& item) OVERRIDE;
252
253 // ash::LauncherItemDelegate overrides:
254 virtual void ItemSelected(const ash::LauncherItem& item, 254 virtual void ItemSelected(const ash::LauncherItem& item,
255 const ui::Event& event) OVERRIDE; 255 const ui::Event& event) OVERRIDE;
256 virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE; 256 virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE;
257 virtual ui::MenuModel* CreateContextMenu( 257 virtual ui::MenuModel* CreateContextMenu(
258 const ash::LauncherItem& item, aura::RootWindow* root) OVERRIDE; 258 const ash::LauncherItem& item, aura::RootWindow* root) OVERRIDE;
259 virtual ash::LauncherMenuModel* CreateApplicationMenu( 259 virtual ash::LauncherMenuModel* CreateApplicationMenu(
260 const ash::LauncherItem& item, 260 const ash::LauncherItem& item,
261 int event_flags) OVERRIDE; 261 int event_flags) OVERRIDE;
262 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE;
263 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE; 262 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE;
264 virtual bool ShouldShowTooltip(const ash::LauncherItem& item) OVERRIDE; 263 virtual bool ShouldShowTooltip(const ash::LauncherItem& item) OVERRIDE;
265 virtual void OnLauncherCreated(ash::Launcher* launcher) OVERRIDE;
266 virtual void OnLauncherDestroyed(ash::Launcher* launcher) OVERRIDE;
267 264
268 // ash::LauncherModelObserver overrides: 265 // ash::LauncherModelObserver overrides:
269 virtual void LauncherItemAdded(int index) OVERRIDE; 266 virtual void LauncherItemAdded(int index) OVERRIDE;
270 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE; 267 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE;
271 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; 268 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE;
272 virtual void LauncherItemChanged(int index, 269 virtual void LauncherItemChanged(int index,
273 const ash::LauncherItem& old_item) OVERRIDE; 270 const ash::LauncherItem& old_item) OVERRIDE;
274 virtual void LauncherStatusChanged() OVERRIDE; 271 virtual void LauncherStatusChanged() OVERRIDE;
275 272
276 // content::NotificationObserver overrides: 273 // content::NotificationObserver overrides:
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // Launchers that are currently being observed. 418 // Launchers that are currently being observed.
422 std::set<ash::Launcher*> launchers_; 419 std::set<ash::Launcher*> launchers_;
423 420
424 // If true, incoming pinned state changes should be ignored. 421 // If true, incoming pinned state changes should be ignored.
425 bool ignore_persist_pinned_state_change_; 422 bool ignore_persist_pinned_state_change_;
426 423
427 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPerBrowser); 424 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPerBrowser);
428 }; 425 };
429 426
430 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_BROWSER _H_ 427 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_BROWSER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698