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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller.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_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ash/launcher/launcher_delegate.h" 10 #include "ash/launcher/launcher_delegate.h"
11 #include "ash/launcher/launcher_types.h" 11 #include "ash/launcher/launcher_types.h"
12 #include "ash/shelf/shelf_types.h" 12 #include "ash/shelf/shelf_types.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "chrome/browser/extensions/app_icon_loader.h" 14 #include "chrome/browser/extensions/app_icon_loader.h"
15 #include "chrome/browser/extensions/extension_prefs.h" 15 #include "chrome/browser/extensions/extension_prefs.h"
16 16
17 class LauncherItemControllerPerAppTest; 17 class LauncherItemControllerPerAppTest;
18 class LauncherItemController; 18 class LauncherItemController;
19 class Profile; 19 class Profile;
20 class ChromeLauncherAppMenuItem; 20 class ChromeLauncherAppMenuItem;
21 class ChromeLauncherControllerPerApp; 21 class ChromeLauncherControllerPerApp;
22 22
23 namespace ash { 23 namespace ash {
24 class LauncherItemDelegate;
24 class LauncherModel; 25 class LauncherModel;
25 } 26 }
26 27
27 namespace aura { 28 namespace aura {
28 class Window; 29 class Window;
29 class RootWindow; 30 class RootWindow;
30 } 31 }
31 32
32 namespace content { 33 namespace content {
33 class WebContents; 34 class WebContents;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // Used by the app-list, and by pinned-app launcher items. 173 // Used by the app-list, and by pinned-app launcher items.
173 virtual void ActivateApp(const std::string& app_id, int event_flags) = 0; 174 virtual void ActivateApp(const std::string& app_id, int event_flags) = 0;
174 175
175 // Returns the launch type of app for the specified id. 176 // Returns the launch type of app for the specified id.
176 virtual extensions::ExtensionPrefs::LaunchType GetLaunchType( 177 virtual extensions::ExtensionPrefs::LaunchType GetLaunchType(
177 ash::LauncherID id) = 0; 178 ash::LauncherID id) = 0;
178 179
179 // Returns the id of the app for the specified tab. 180 // Returns the id of the app for the specified tab.
180 virtual std::string GetAppID(content::WebContents* tab) = 0; 181 virtual std::string GetAppID(content::WebContents* tab) = 0;
181 182
182 // Returns the launcherID of the first non-panel item whose app_id
183 // matches |app_id| or 0 if none match.
184 virtual ash::LauncherID GetLauncherIDForAppID(const std::string& app_id) = 0;
185
186 // Returns the id of the app for the specified id (which must exist). 183 // Returns the id of the app for the specified id (which must exist).
187 virtual std::string GetAppIDForLauncherID(ash::LauncherID id) = 0; 184 virtual std::string GetAppIDForLauncherID(ash::LauncherID id) = 0;
188 185
189 // Set the image for a specific launcher item (e.g. when set by the app). 186 // Set the image for a specific launcher item (e.g. when set by the app).
190 virtual void SetLauncherItemImage(ash::LauncherID launcher_id, 187 virtual void SetLauncherItemImage(ash::LauncherID launcher_id,
191 const gfx::ImageSkia& image) = 0; 188 const gfx::ImageSkia& image) = 0;
192 189
193 // Returns true if a pinned launcher item with given |app_id| could be found.
194 virtual bool IsAppPinned(const std::string& app_id) = 0;
195
196 // Pins an app with |app_id| to launcher. If there is a running instance in
197 // launcher, the running instance is pinned. If there is no running instance,
198 // a new launcher item is created and pinned.
199 virtual void PinAppWithID(const std::string& app_id) = 0;
200 190
201 // Updates the launche type of the app for the specified id to |launch_type|. 191 // Updates the launche type of the app for the specified id to |launch_type|.
202 virtual void SetLaunchType( 192 virtual void SetLaunchType(
203 ash::LauncherID id, 193 ash::LauncherID id,
204 extensions::ExtensionPrefs::LaunchType launch_type) = 0; 194 extensions::ExtensionPrefs::LaunchType launch_type) = 0;
205 195
206 // Unpins any app items whose id is |app_id|.
207 virtual void UnpinAppsWithID(const std::string& app_id) = 0;
208
209 // Returns true if the user is currently logged in as a guest. 196 // Returns true if the user is currently logged in as a guest.
210 virtual bool IsLoggedInAsGuest() = 0; 197 virtual bool IsLoggedInAsGuest() = 0;
211 198
212 // Invoked when user clicks on button in the launcher and there is no last 199 // Invoked when user clicks on button in the launcher and there is no last
213 // used window (or CTRL is held with the click). 200 // used window (or CTRL is held with the click).
214 virtual void CreateNewWindow() = 0; 201 virtual void CreateNewWindow() = 0;
215 202
216 // Invoked when the user clicks on button in the launcher to create a new 203 // Invoked when the user clicks on button in the launcher to create a new
217 // incognito window. 204 // incognito window.
218 virtual void CreateNewIncognitoWindow() = 0; 205 virtual void CreateNewIncognitoWindow() = 0;
219 206
220 // Checks whether the user is allowed to pin apps. Pinning may be disallowed
221 // by policy in case there is a pre-defined set of pinned apps.
222 virtual bool CanPin() const = 0;
223
224 // Updates the pinned pref state. The pinned state consists of a list pref. 207 // Updates the pinned pref state. The pinned state consists of a list pref.
225 // Each item of the list is a dictionary. The key |kAppIDPath| gives the 208 // Each item of the list is a dictionary. The key |kAppIDPath| gives the
226 // id of the app. 209 // id of the app.
227 virtual void PersistPinnedState() = 0; 210 virtual void PersistPinnedState() = 0;
228 211
229 virtual ash::LauncherModel* model() = 0; 212 virtual ash::LauncherModel* model() = 0;
230 213
231 virtual Profile* profile() = 0; 214 virtual Profile* profile() = 0;
232 215
233 // Gets the shelf auto-hide behavior on |root_window|. 216 // Gets the shelf auto-hide behavior on |root_window|.
(...skipping 23 matching lines...) Expand all
257 const GURL& url) = 0; 240 const GURL& url) = 0;
258 241
259 // Returns the extension identified by |app_id|. 242 // Returns the extension identified by |app_id|.
260 virtual const extensions::Extension* GetExtensionForAppID( 243 virtual const extensions::Extension* GetExtensionForAppID(
261 const std::string& app_id) const = 0; 244 const std::string& app_id) const = 0;
262 245
263 // 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
264 // it, the the window will get minimized instead. 247 // it, the the window will get minimized instead.
265 virtual void ActivateWindowOrMinimizeIfActive(ui::BaseWindow* window, 248 virtual void ActivateWindowOrMinimizeIfActive(ui::BaseWindow* window,
266 bool allow_minimize) = 0; 249 bool allow_minimize) = 0;
250
267 // ash::LauncherDelegate overrides: 251 // ash::LauncherDelegate overrides:
268 virtual void ItemSelected(const ash::LauncherItem& item,
269 const ui::Event& event) OVERRIDE = 0;
270 virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE = 0;
271 virtual ui::MenuModel* CreateContextMenu(
272 const ash::LauncherItem& item, aura::RootWindow* root) OVERRIDE = 0;
273 virtual ash::LauncherMenuModel* CreateApplicationMenu(
274 const ash::LauncherItem& item,
275 int event_flags) OVERRIDE = 0;
276 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE = 0; 252 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE = 0;
277 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE = 0; 253 virtual void OnLauncherCreated(ash::Launcher* launcher) OVERRIDE = 0;
278 virtual bool ShouldShowTooltip(const ash::LauncherItem& item) OVERRIDE = 0; 254 virtual void OnLauncherDestroyed(ash::Launcher* launcher) OVERRIDE = 0;
279 virtual bool IsPerAppLauncher() OVERRIDE; 255 virtual ash::LauncherID GetLauncherIDForAppID(
256 const std::string& app_id) OVERRIDE= 0;
257 virtual void PinAppWithID(const std::string& app_id) OVERRIDE = 0;
258 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE = 0;
259 virtual void UnpinAppsWithID(const std::string& app_id) OVERRIDE = 0;
260 virtual ash::LauncherItemDelegate* GetLauncherItemDelegate(
261 const ash::LauncherItem& item) OVERRIDE = 0;
280 262
281 // extensions::AppIconLoader overrides: 263 // extensions::AppIconLoader overrides:
282 virtual void SetAppImage(const std::string& app_id, 264 virtual void SetAppImage(const std::string& app_id,
283 const gfx::ImageSkia& image) OVERRIDE = 0; 265 const gfx::ImageSkia& image) OVERRIDE = 0;
284 266
285 protected: 267 protected:
286 friend class LauncherItemControllerPerAppTest; 268 friend class LauncherItemControllerPerAppTest;
287 friend class LauncherPlatformAppBrowserTest; 269 friend class LauncherPlatformAppBrowserTest;
288 friend class LauncherAppBrowserTest; 270 friend class LauncherAppBrowserTest;
289 // TODO(skuhne): Remove these when the old launcher get removed. 271 // TODO(skuhne): Remove these when the old launcher get removed.
(...skipping 11 matching lines...) Expand all
301 virtual void SetAppTabHelperForTest(AppTabHelper* helper) = 0; 283 virtual void SetAppTabHelperForTest(AppTabHelper* helper) = 0;
302 virtual void SetAppIconLoaderForTest(extensions::AppIconLoader* loader) = 0; 284 virtual void SetAppIconLoaderForTest(extensions::AppIconLoader* loader) = 0;
303 virtual const std::string& GetAppIdFromLauncherIdForTest( 285 virtual const std::string& GetAppIdFromLauncherIdForTest(
304 ash::LauncherID id) = 0; 286 ash::LauncherID id) = 0;
305 287
306 private: 288 private:
307 static ChromeLauncherController* instance_; 289 static ChromeLauncherController* instance_;
308 }; 290 };
309 291
310 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 292 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698