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

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

Issue 2052013002: Adding ChromeLauncherController interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome_launcher_smaller_api
Patch Set: Fix method order Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_IMPL_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map>
10 #include <memory> 9 #include <memory>
11 #include <string>
12 #include <vector>
13 10
14 #include "ash/common/shelf/shelf_item_delegate.h"
15 #include "ash/common/shelf/shelf_item_delegate_manager.h" 11 #include "ash/common/shelf/shelf_item_delegate_manager.h"
16 #include "ash/common/shelf/shelf_item_types.h"
17 #include "ash/common/shelf/shelf_model_observer.h" 12 #include "ash/common/shelf/shelf_model_observer.h"
18 #include "ash/common/shelf/shelf_types.h" 13 #include "ash/common/shelf/shelf_types.h"
19 #include "ash/display/window_tree_host_manager.h" 14 #include "ash/display/window_tree_host_manager.h"
20 #include "ash/shelf/shelf_delegate.h" 15 #include "ash/shelf/shelf_delegate.h"
21 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
22 #include "base/macros.h" 17 #include "base/macros.h"
23 #include "base/memory/scoped_vector.h"
24 #include "build/build_config.h" 18 #include "build/build_config.h"
25 #include "chrome/browser/ui/app_icon_loader.h" 19 #include "chrome/browser/ui/app_icon_loader.h"
26 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
27 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" 20 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h"
28 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" 21 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
29 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h"
30 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h" 22 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h"
31 #include "components/prefs/pref_change_registrar.h" 23 #include "components/prefs/pref_change_registrar.h"
32 #include "extensions/common/constants.h"
33 #include "ui/aura/window_observer.h" 24 #include "ui/aura/window_observer.h"
34 25
35 class AppSyncUIState; 26 class AppSyncUIState;
36 class ArcAppDeferredLauncherController;
37 class Browser;
38 class BrowserShortcutLauncherItemController;
39 class BrowserStatusMonitor; 27 class BrowserStatusMonitor;
40 class GURL;
41 class LauncherControllerHelper; 28 class LauncherControllerHelper;
42 class LauncherItemController;
43 class Profile; 29 class Profile;
44 class AppWindowLauncherController; 30 class AppWindowLauncherController;
45 class TabContents; 31 class TabContents;
46 32
47 namespace ash { 33 namespace ash {
48 class ChromeLauncherPrefsObserver; 34 class ChromeLauncherPrefsObserver;
49 class ShelfItemDelegateManager; 35 class ShelfItemDelegateManager;
50 class ShelfModel; 36 class ShelfModel;
51 } 37 }
52 38
53 namespace aura { 39 namespace aura {
54 class Window; 40 class Window;
55 } 41 }
56 42
57 namespace content { 43 namespace content {
58 class BrowserContext; 44 class BrowserContext;
59 class WebContents;
60 } 45 }
61 46
62 namespace extensions { 47 namespace extensions {
63 class Extension; 48 class Extension;
64 } 49 }
65 50
66 namespace ui {
67 class BaseWindow;
68 }
69
70 class ChromeLauncherControllerUserSwitchObserver; 51 class ChromeLauncherControllerUserSwitchObserver;
71 52
72 // A list of the elements which makes up a simple menu description. 53 // A list of the elements which makes up a simple menu description.
msw 2016/06/10 22:44:38 nit: you should be able to remove this and just in
mfomitchev 2016/06/13 17:29:18 Done.
73 typedef ScopedVector<ChromeLauncherAppMenuItem> ChromeLauncherAppMenuItems; 54 typedef ScopedVector<ChromeLauncherAppMenuItem> ChromeLauncherAppMenuItems;
74 55
75 // ChromeLauncherController manages the launcher items needed for content 56 // Implementation of ChromeLauncherController, used for classic Ash.
76 // windows. Launcher items have a type, an optional app id, and a controller. 57 // In addition to implementing ChromeLauncherController, this class performs
77 // This incarnation groups running tabs/windows in application specific lists. 58 // a lot of other responsibilities, such as implementing ash::ShelfDelegate,
78 // * Browser app windows have BrowserShortcutLauncherItemController, owned by 59 // updating the UI state and the shelf model when apps are uninstalled, etc.
79 // the BrowserView instance. 60 class ChromeLauncherControllerImpl
80 // * App windows have AppWindowLauncherItemController, owned by 61 : public ChromeLauncherController,
81 // AppWindowLauncherController. 62 public ash::ShelfDelegate,
82 // * Shortcuts have no LauncherItemController.
83 class ChromeLauncherController
84 : public ash::ShelfDelegate,
85 public ash::ShelfModelObserver, 63 public ash::ShelfModelObserver,
86 public ash::WindowTreeHostManager::Observer, 64 public ash::WindowTreeHostManager::Observer,
87 public AppIconLoaderDelegate, 65 public AppIconLoaderDelegate,
88 public AppSyncUIStateObserver, 66 public AppSyncUIStateObserver,
89 public LauncherAppUpdater::Delegate, 67 public LauncherAppUpdater::Delegate,
90 public ash::ShelfItemDelegateManagerObserver { 68 public ash::ShelfItemDelegateManagerObserver {
91 public: 69 public:
92 // Used to update the state of non plaform apps, as web contents change. 70 ChromeLauncherControllerImpl(Profile* profile, ash::ShelfModel* model);
93 enum AppState { 71 ~ChromeLauncherControllerImpl() override;
94 APP_STATE_ACTIVE,
95 APP_STATE_WINDOW_ACTIVE,
96 APP_STATE_INACTIVE,
97 APP_STATE_REMOVED
98 };
99 72
100 ChromeLauncherController(Profile* profile, ash::ShelfModel* model); 73 // Create ChromeLauncherControllerImpl instance and set is as the
101 ~ChromeLauncherController() override; 74 // ChromeLauncherController singleton.
75 static ChromeLauncherControllerImpl* CreateInstance(Profile* profile,
76 ash::ShelfModel* model);
102 77
103 // Initializes this ChromeLauncherController. 78 // ChromeLauncherController:
104 void Init(); 79 void Init() override;
105
106 // Creates an instance.
107 static ChromeLauncherController* CreateInstance(Profile* profile,
108 ash::ShelfModel* model);
109
110 // Returns the single ChromeLauncherController instance.
111 static ChromeLauncherController* instance() { return instance_; }
112
113 // Creates a new app item on the shelf for |controller|.
114 ash::ShelfID CreateAppLauncherItem(LauncherItemController* controller, 80 ash::ShelfID CreateAppLauncherItem(LauncherItemController* controller,
115 const std::string& app_id, 81 const std::string& app_id,
116 ash::ShelfItemStatus status); 82 ash::ShelfItemStatus status) override;
117 83 void SetItemStatus(ash::ShelfID id, ash::ShelfItemStatus status) override;
118 // Updates the running status of an item. It will also update the status of 84 void SetItemController(ash::ShelfID id,
119 // browsers shelf item if needed. 85 LauncherItemController* controller) override;
120 void SetItemStatus(ash::ShelfID id, ash::ShelfItemStatus status); 86 void CloseLauncherItem(ash::ShelfID id) override;
121 87 void Pin(ash::ShelfID id) override;
122 // Updates the controller associated with id (which should be a shortcut). 88 void Unpin(ash::ShelfID id) override;
123 // |controller| will be owned by the |ChromeLauncherController| and then 89 bool IsPinned(ash::ShelfID id) override;
124 // passed on to |ShelfItemDelegateManager|. 90 void TogglePinned(ash::ShelfID id) override;
125 // TODO(skuhne): Pass in scoped_ptr to make ownership clear. 91 bool IsPinnable(ash::ShelfID id) const override;
126 void SetItemController(ash::ShelfID id, LauncherItemController* controller); 92 void LockV1AppWithID(const std::string& app_id) override;
127 93 void UnlockV1AppWithID(const std::string& app_id) override;
128 // Closes or unpins the shelf item. 94 void Launch(ash::ShelfID id, int event_flags) override;
129 void CloseLauncherItem(ash::ShelfID id); 95 void Close(ash::ShelfID id) override;
130 96 bool IsOpen(ash::ShelfID id) override;
131 // Pins the specified id. Currently only supports platform apps. 97 bool IsPlatformApp(ash::ShelfID id) override;
132 void Pin(ash::ShelfID id);
133
134 // Unpins the specified id, closing if not running.
135 void Unpin(ash::ShelfID id);
136
137 // Returns true if the item identified by |id| is pinned.
138 bool IsPinned(ash::ShelfID id);
139
140 // Pins/unpins the specified id.
141 void TogglePinned(ash::ShelfID id);
142
143 // Returns true if the specified item can be pinned or unpinned. Only apps can
144 // be pinned.
145 bool IsPinnable(ash::ShelfID id) const;
146
147 // If there is no shelf item in the shelf for application |app_id|, one
148 // gets created. The (existing or created) shelf items get then locked
149 // against a users un-pinning removal.
150 void LockV1AppWithID(const std::string& app_id);
151
152 // A previously locked shelf item of type |app_id| gets unlocked. If the
153 // lock count reaches 0 and the item is not pinned it will go away.
154 void UnlockV1AppWithID(const std::string& app_id);
155
156 // Requests that the shelf item controller specified by |id| open a new
157 // instance of the app. |event_flags| holds the flags of the event which
158 // triggered this command.
159 void Launch(ash::ShelfID id, int event_flags);
160
161 // Closes the specified item.
162 void Close(ash::ShelfID id);
163
164 // Returns true if the specified item is open.
165 bool IsOpen(ash::ShelfID id);
166
167 // Returns true if the specified item is for a platform app.
168 bool IsPlatformApp(ash::ShelfID id);
169
170 // Opens a new instance of the application identified by |app_id|.
171 // Used by the app-list, and by pinned-app shelf items.
172 void LaunchApp(const std::string& app_id, 98 void LaunchApp(const std::string& app_id,
173 ash::LaunchSource source, 99 ash::LaunchSource source,
174 int event_flags); 100 int event_flags) override;
175
176 // If |app_id| is running, reactivates the app's most recently active window,
177 // otherwise launches and activates the app.
178 // Used by the app-list, and by pinned-app shelf items.
179 void ActivateApp(const std::string& app_id, 101 void ActivateApp(const std::string& app_id,
180 ash::LaunchSource source, 102 ash::LaunchSource source,
181 int event_flags); 103 int event_flags) override;
182 104 extensions::LaunchType GetLaunchType(ash::ShelfID id) override;
183 // Returns the launch type of app for the specified id. 105 void SetLauncherItemImage(ash::ShelfID shelf_id,
184 extensions::LaunchType GetLaunchType(ash::ShelfID id); 106 const gfx::ImageSkia& image) override;
185 107 bool IsWindowedAppInLauncher(const std::string& app_id) override;
186 // Set the image for a specific shelf item (e.g. when set by the app). 108 void SetLaunchType(ash::ShelfID id,
187 void SetLauncherItemImage(ash::ShelfID shelf_id, const gfx::ImageSkia& image); 109 extensions::LaunchType launch_type) override;
188 110 void PersistPinnedState() override;
189 // Find out if the given application |id| is a windowed app item and not a 111 Profile* GetProfile() override;
190 // pinned item in the shelf. 112 void UpdateAppState(content::WebContents* contents,
191 bool IsWindowedAppInLauncher(const std::string& app_id); 113 AppState app_state) override;
192 114 ash::ShelfID GetShelfIDForWebContents(
193 // Updates the launch type of the app for the specified id to |launch_type|. 115 content::WebContents* contents) override;
194 void SetLaunchType(ash::ShelfID id, extensions::LaunchType launch_type); 116 void SetRefocusURLPatternForTest(ash::ShelfID id, const GURL& url) override;
195
196 // Updates the pinned pref state. The pinned state consists of a list pref.
197 // Each item of the list is a dictionary. The key |kAppIDPath| gives the
198 // id of the app.
199 void PersistPinnedState();
200
201 // Accessor to the currently loaded profile. Note that in multi profile use
202 // cases this might change over time.
203 Profile* profile();
204
205 // Notify the controller that the state of an non platform app's tabs
206 // have changed,
207 void UpdateAppState(content::WebContents* contents, AppState app_state);
208
209 // Returns ShelfID for |contents|. If |contents| is not an app or is not
210 // pinned, returns the id of browser shrotcut.
211 ash::ShelfID GetShelfIDForWebContents(content::WebContents* contents);
212
213 // Limits application refocusing to urls that match |url| for |id|.
214 void SetRefocusURLPatternForTest(ash::ShelfID id, const GURL& url);
215
216 // Returns the extension identified by |app_id|.
217 const extensions::Extension* GetExtensionForAppID( 117 const extensions::Extension* GetExtensionForAppID(
218 const std::string& app_id) const; 118 const std::string& app_id) const override;
219
220 // Activates a |window|. If |allow_minimize| is true and the system allows
221 // it, the the window will get minimized instead.
222 // Returns the action performed. Should be one of kNoAction,
223 // kExistingWindowActivated, or kExistingWindowMinimized.
224 ash::ShelfItemDelegate::PerformedAction ActivateWindowOrMinimizeIfActive( 119 ash::ShelfItemDelegate::PerformedAction ActivateWindowOrMinimizeIfActive(
225 ui::BaseWindow* window, 120 ui::BaseWindow* window,
226 bool allow_minimize); 121 bool allow_minimize) override;
122 void ActiveUserChanged(const std::string& user_email) override;
123 void AdditionalUserAddedToSession(Profile* profile) override;
124 ChromeLauncherAppMenuItems GetApplicationList(const ash::ShelfItem& item,
125 int event_flags) override;
126 std::vector<content::WebContents*> GetV1ApplicationsFromAppId(
127 const std::string& app_id) override;
128 void ActivateShellApp(const std::string& app_id, int index) override;
129 bool IsWebContentHandledByApplication(content::WebContents* web_contents,
130 const std::string& app_id) override;
131 bool ContentCanBeHandledByGmailApp(
132 content::WebContents* web_contents) override;
133 gfx::Image GetAppListIcon(content::WebContents* web_contents) const override;
134 base::string16 GetAppListTitle(
135 content::WebContents* web_contents) const override;
136 BrowserShortcutLauncherItemController*
137 GetBrowserShortcutLauncherItemController() override;
138 LauncherItemController* GetLauncherItemController(
139 const ash::ShelfID id) override;
140 bool IsBrowserFromActiveUser(Browser* browser) override;
141 bool ShelfBoundsChangesProbablyWithUser(
142 ash::Shelf* shelf,
143 const std::string& user_id) const override;
144 void OnUserProfileReadyToSwitch(Profile* profile) override;
145 AppListControllerDelegate::Pinnable GetPinnable(
146 const std::string& app_id) override;
147 ArcAppDeferredLauncherController* GetArcDeferredLauncher() override;
148
149 // Access to the BrowserStatusMonitor for tests.
150 BrowserStatusMonitor* browser_status_monitor_for_test() {
151 return browser_status_monitor_.get();
152 }
153
154 // Access to the AppWindowLauncherController for tests.
155 AppWindowLauncherController* app_window_controller_for_test() {
156 return app_window_controllers_[0].get();
157 }
227 158
228 // ash::ShelfDelegate: 159 // ash::ShelfDelegate:
msw 2016/06/10 22:44:38 nit: if possible, we should make the base class ov
mfomitchev 2016/06/10 23:29:09 Hmm.. this might be possible for some of them, but
msw 2016/06/10 23:42:51 Acknowledged.
229 void OnShelfCreated(ash::Shelf* shelf) override; 160 void OnShelfCreated(ash::Shelf* shelf) override;
230 void OnShelfDestroyed(ash::Shelf* shelf) override; 161 void OnShelfDestroyed(ash::Shelf* shelf) override;
231 void OnShelfAlignmentChanged(ash::Shelf* shelf) override; 162 void OnShelfAlignmentChanged(ash::Shelf* shelf) override;
232 void OnShelfAutoHideBehaviorChanged(ash::Shelf* shelf) override; 163 void OnShelfAutoHideBehaviorChanged(ash::Shelf* shelf) override;
233 void OnShelfAutoHideStateChanged(ash::Shelf* shelf) override; 164 void OnShelfAutoHideStateChanged(ash::Shelf* shelf) override;
234 void OnShelfVisibilityStateChanged(ash::Shelf* shelf) override; 165 void OnShelfVisibilityStateChanged(ash::Shelf* shelf) override;
235 ash::ShelfID GetShelfIDForAppID(const std::string& app_id) override; 166 ash::ShelfID GetShelfIDForAppID(const std::string& app_id) override;
236 bool HasShelfIDToAppIDMapping(ash::ShelfID id) const override; 167 bool HasShelfIDToAppIDMapping(ash::ShelfID id) const override;
237 const std::string& GetAppIDForShelfID(ash::ShelfID id) override; 168 const std::string& GetAppIDForShelfID(ash::ShelfID id) override;
238 bool GetAppIDForShelfIDConst(ash::ShelfID id, std::string* app_id) const; 169 bool GetAppIDForShelfIDConst(ash::ShelfID id, std::string* app_id) const;
(...skipping 22 matching lines...) Expand all
261 void OnAppUninstalled(content::BrowserContext* browser_context, 192 void OnAppUninstalled(content::BrowserContext* browser_context,
262 const std::string& app_id) override; 193 const std::string& app_id) override;
263 194
264 // AppSyncUIStateObserver: 195 // AppSyncUIStateObserver:
265 void OnAppSyncUIStatusChanged() override; 196 void OnAppSyncUIStatusChanged() override;
266 197
267 // AppIconLoaderDelegate: 198 // AppIconLoaderDelegate:
268 void OnAppImageUpdated(const std::string& app_id, 199 void OnAppImageUpdated(const std::string& app_id,
269 const gfx::ImageSkia& image) override; 200 const gfx::ImageSkia& image) override;
270 201
271 // Called when the active user has changed.
272 void ActiveUserChanged(const std::string& user_email);
273 202
274 // Called when a user got added to the session.
275 void AdditionalUserAddedToSession(Profile* profile);
276
277 // Get the list of all running incarnations of this item.
278 // |event_flags| specifies the flags which were set by the event which
279 // triggered this menu generation. It can be used to generate different lists.
280 ChromeLauncherAppMenuItems GetApplicationList(const ash::ShelfItem& item,
281 int event_flags);
282
283 // Get the list of all tabs which belong to a certain application type.
284 std::vector<content::WebContents*> GetV1ApplicationsFromAppId(
285 const std::string& app_id);
286
287 // Activates a specified shell application.
288 void ActivateShellApp(const std::string& app_id, int index);
289
290 // Checks if a given |web_contents| is known to be associated with an
291 // application of type |app_id|.
292 bool IsWebContentHandledByApplication(content::WebContents* web_contents,
293 const std::string& app_id);
294
295 // Check if the gMail app is loaded and it can handle the given web content.
296 // This special treatment is required to address crbug.com/234268.
297 bool ContentCanBeHandledByGmailApp(content::WebContents* web_contents);
298
299 // Get the favicon for the application list entry for |web_contents|.
300 // Note that for incognito windows the incognito icon will be returned.
301 // If |web_contents| has not loaded, returns the default favicon.
302 gfx::Image GetAppListIcon(content::WebContents* web_contents) const;
303
304 // Get the title for the applicatoin list entry for |web_contents|.
305 // If |web_contents| has not loaded, returns "Net Tab".
306 base::string16 GetAppListTitle(content::WebContents* web_contents) const;
307
308 // Returns the LauncherItemController of BrowserShortcut.
309 BrowserShortcutLauncherItemController*
310 GetBrowserShortcutLauncherItemController();
311
312 LauncherItemController* GetLauncherItemController(const ash::ShelfID id);
313
314 // Returns true if |browser| is owned by the active user.
315 bool IsBrowserFromActiveUser(Browser* browser);
316
317 // Check if the shelf visibility (location, visibility) will change with a new
318 // user profile or not. However, since the full visibility calculation of the
319 // shelf cannot be performed here, this is only a probability used for
320 // animation predictions.
321 bool ShelfBoundsChangesProbablyWithUser(ash::Shelf* shelf,
322 const std::string& user_id) const;
323
324 // Called when the user profile is fully loaded and ready to switch to.
325 void OnUserProfileReadyToSwitch(Profile* profile);
326
327 // Access to the BrowserStatusMonitor for tests.
328 BrowserStatusMonitor* browser_status_monitor_for_test() {
329 return browser_status_monitor_.get();
330 }
331
332 // Access to the AppWindowLauncherController for tests.
333 AppWindowLauncherController* app_window_controller_for_test() {
334 return app_window_controllers_[0].get();
335 }
336
337 // Controller to launch Arc apps in deferred mode.
338 ArcAppDeferredLauncherController* arc_deferred_launcher() {
339 return arc_deferred_launcher_.get();
340 }
341
342 // TODO(khmel): Find better home for Pinnable enum.
343 AppListControllerDelegate::Pinnable GetPinnable(const std::string& app_id);
344 203
345 protected: 204 protected:
346 // Creates a new app shortcut item and controller on the shelf at |index|. 205 // Creates a new app shortcut item and controller on the shelf at |index|.
347 // Use kInsertItemAtEnd to add a shortcut as the last item. 206 // Use kInsertItemAtEnd to add a shortcut as the last item.
348 ash::ShelfID CreateAppShortcutLauncherItem(const std::string& app_id, 207 ash::ShelfID CreateAppShortcutLauncherItem(const std::string& app_id,
349 int index); 208 int index);
350 209
351 // Sets LauncherControllerHelper/AppIconLoader for test, taking ownership. 210 // Sets LauncherControllerHelper/AppIconLoader for test, taking ownership.
352 void SetLauncherControllerHelperForTest(LauncherControllerHelper* helper); 211 void SetLauncherControllerHelperForTest(LauncherControllerHelper* helper);
353 void SetAppIconLoadersForTest( 212 void SetAppIconLoadersForTest(
354 std::vector<std::unique_ptr<AppIconLoader>>& loaders); 213 std::vector<std::unique_ptr<AppIconLoader>>& loaders);
355 const std::string& GetAppIdFromShelfIdForTest(ash::ShelfID id); 214 const std::string& GetAppIdFromShelfIdForTest(ash::ShelfID id);
356 215
357 // Sets the ash::ShelfItemDelegateManager only for unittests and doesn't 216 // Sets the ash::ShelfItemDelegateManager only for unittests and doesn't
358 // take an ownership of it. 217 // take an ownership of it.
359 void SetShelfItemDelegateManagerForTest( 218 void SetShelfItemDelegateManagerForTest(
360 ash::ShelfItemDelegateManager* manager); 219 ash::ShelfItemDelegateManager* manager);
361 220
362 private: 221 private:
363 friend class ChromeLauncherControllerTest; 222 friend class ChromeLauncherControllerImplTest;
364 friend class ShelfAppBrowserTest; 223 friend class ShelfAppBrowserTest;
365 friend class LauncherPlatformAppBrowserTest; 224 friend class LauncherPlatformAppBrowserTest;
366 225
367 typedef std::map<ash::ShelfID, LauncherItemController*> IDToItemControllerMap; 226 typedef std::map<ash::ShelfID, LauncherItemController*> IDToItemControllerMap;
368 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap; 227 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap;
369 228
370 // Remembers / restores list of running applications. 229 // Remembers / restores list of running applications.
371 // Note that this order will neither be stored in the preference nor will it 230 // Note that this order will neither be stored in the preference nor will it
372 // remember the order of closed applications since it is only temporary. 231 // remember the order of closed applications since it is only temporary.
373 void RememberUnpinnedRunningApplicationOrder(); 232 void RememberUnpinnedRunningApplicationOrder();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 273
415 // Returns the shelf item status for the given |app_id|, which can be either 274 // Returns the shelf item status for the given |app_id|, which can be either
416 // STATUS_ACTIVE (if the app is active), STATUS_RUNNING (if there is such an 275 // STATUS_ACTIVE (if the app is active), STATUS_RUNNING (if there is such an
417 // app) or STATUS_CLOSED. 276 // app) or STATUS_CLOSED.
418 ash::ShelfItemStatus GetAppState(const std::string& app_id); 277 ash::ShelfItemStatus GetAppState(const std::string& app_id);
419 278
420 // Creates an app launcher to insert at |index|. Note that |index| may be 279 // Creates an app launcher to insert at |index|. Note that |index| may be
421 // adjusted by the model to meet ordering constraints. 280 // adjusted by the model to meet ordering constraints.
422 // The |shelf_item_type| will be set into the ShelfModel. 281 // The |shelf_item_type| will be set into the ShelfModel.
423 ash::ShelfID InsertAppLauncherItem(LauncherItemController* controller, 282 ash::ShelfID InsertAppLauncherItem(LauncherItemController* controller,
424 const std::string& app_id, 283 const std::string& app_id,
425 ash::ShelfItemStatus status, 284 ash::ShelfItemStatus status,
426 int index, 285 int index,
427 ash::ShelfItemType shelf_item_type); 286 ash::ShelfItemType shelf_item_type);
428 287
429 // Enumerate all Web contents which match a given shortcut |controller|. 288 // Enumerate all Web contents which match a given shortcut |controller|.
430 std::vector<content::WebContents*> GetV1ApplicationsFromController( 289 std::vector<content::WebContents*> GetV1ApplicationsFromController(
431 LauncherItemController* controller); 290 LauncherItemController* controller);
432 291
433 // Create ShelfItem for Browser Shortcut. 292 // Create ShelfItem for Browser Shortcut.
434 ash::ShelfID CreateBrowserShortcutLauncherItem(); 293 ash::ShelfID CreateBrowserShortcutLauncherItem();
435 294
436 // Check if the given |web_contents| is in incognito mode. 295 // Check if the given |web_contents| is in incognito mode.
437 bool IsIncognito(const content::WebContents* web_contents) const; 296 bool IsIncognito(const content::WebContents* web_contents) const;
438 297
439 // Update browser shortcut's index. 298 // Update browser shortcut's index.
440 void PersistChromeItemIndex(int index); 299 void PersistChromeItemIndex(int index);
441 300
442 // Depending on the provided flags, move either the chrome icon, the app icon 301 // Depending on the provided flags, move either the chrome icon, the app icon
443 // or none to the given |target_index|. The provided |chrome_index| and 302 // or none to the given |target_index|. The provided |chrome_index| and
444 // |app_list_index| locations will get adjusted within this call to finalize 303 // |app_list_index| locations will get adjusted within this call to finalize
445 // the action and to make sure that the other item can still be moved 304 // the action and to make sure that the other item can still be moved
446 // afterwards (index adjustments). 305 // afterwards (index adjustments).
447 void MoveChromeOrApplistToFinalPosition( 306 void MoveChromeOrApplistToFinalPosition(bool is_chrome,
448 bool is_chrome, 307 bool is_app_list,
449 bool is_app_list, 308 int target_index,
450 int target_index, 309 int* chrome_index,
451 int* chrome_index, 310 int* app_list_index);
452 int* app_list_index);
453 311
454 // Finds the index of where to insert the next item. 312 // Finds the index of where to insert the next item.
455 int FindInsertionPoint(bool is_app_list); 313 int FindInsertionPoint(bool is_app_list);
456 314
457 // Get the browser shortcut's index in the shelf using the current's systems 315 // Get the browser shortcut's index in the shelf using the current's systems
458 // configuration of pinned and known (but not running) apps. 316 // configuration of pinned and known (but not running) apps.
459 int GetChromeIconIndexForCreation(); 317 int GetChromeIconIndexForCreation();
460 318
461 // Close all windowed V1 applications of a certain extension which was already 319 // Close all windowed V1 applications of a certain extension which was already
462 // deleted. 320 // deleted.
463 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id, 321 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id,
464 const Profile* profile); 322 const Profile* profile);
465 323
466 // Set ShelfItemDelegate |item_delegate| for |id| and take an ownership. 324 // Set ShelfItemDelegate |item_delegate| for |id| and take an ownership.
467 // TODO(simon.hong81): Make this take a scoped_ptr of |item_delegate|. 325 // TODO(simon.hong81): Make this take a scoped_ptr of |item_delegate|.
468 void SetShelfItemDelegate(ash::ShelfID id, 326 void SetShelfItemDelegate(ash::ShelfID id,
469 ash::ShelfItemDelegate* item_delegate); 327 ash::ShelfItemDelegate* item_delegate);
470 328
471 // Attach to a specific profile. 329 // Attach to a specific profile.
472 void AttachProfile(Profile* proifile); 330 void AttachProfile(Profile* proifile);
473 331
474 // Forget the current profile to allow attaching to a new one. 332 // Forget the current profile to allow attaching to a new one.
475 void ReleaseProfile(); 333 void ReleaseProfile();
476 334
477 AppIconLoader* GetAppIconLoaderForApp(const std::string& app_id); 335 AppIconLoader* GetAppIconLoaderForApp(const std::string& app_id);
478 336
479 static ChromeLauncherController* instance_;
480
481 ash::ShelfModel* model_; 337 ash::ShelfModel* model_;
482 338
483 ash::ShelfItemDelegateManager* item_delegate_manager_; 339 ash::ShelfItemDelegateManager* item_delegate_manager_;
484 340
485 // Profile used for prefs and loading extensions. This is NOT necessarily the 341 // Profile used for prefs and loading extensions. This is NOT necessarily the
486 // profile new windows are created with. 342 // profile new windows are created with.
487 Profile* profile_; 343 Profile* profile_;
488 344
489 // Controller items in this map are owned by |ShelfItemDelegateManager|. 345 // Controller items in this map are owned by |ShelfItemDelegateManager|.
490 IDToItemControllerMap id_to_item_controller_map_; 346 IDToItemControllerMap id_to_item_controller_map_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 378
523 // If true, incoming pinned state changes should be ignored. 379 // If true, incoming pinned state changes should be ignored.
524 bool ignore_persist_pinned_state_change_; 380 bool ignore_persist_pinned_state_change_;
525 381
526 // The list of running & un-pinned applications for different users on hidden 382 // The list of running & un-pinned applications for different users on hidden
527 // desktops. 383 // desktops.
528 typedef std::vector<std::string> RunningAppListIds; 384 typedef std::vector<std::string> RunningAppListIds;
529 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap; 385 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap;
530 RunningAppListIdMap last_used_running_application_order_; 386 RunningAppListIdMap last_used_running_application_order_;
531 387
532 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); 388 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImpl);
533 }; 389 };
534 390
535 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 391 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698