OLD | NEW |
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 <string> | 10 #include <string> |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // Returns true if the item identified by |id| is pinned. | 116 // Returns true if the item identified by |id| is pinned. |
117 virtual bool IsPinned(ash::LauncherID id) OVERRIDE; | 117 virtual bool IsPinned(ash::LauncherID id) OVERRIDE; |
118 | 118 |
119 // Pins/unpins the specified id. | 119 // Pins/unpins the specified id. |
120 virtual void TogglePinned(ash::LauncherID id) OVERRIDE; | 120 virtual void TogglePinned(ash::LauncherID id) OVERRIDE; |
121 | 121 |
122 // Returns true if the specified item can be pinned or unpinned. Only apps can | 122 // Returns true if the specified item can be pinned or unpinned. Only apps can |
123 // be pinned. | 123 // be pinned. |
124 virtual bool IsPinnable(ash::LauncherID id) const OVERRIDE; | 124 virtual bool IsPinnable(ash::LauncherID id) const OVERRIDE; |
125 | 125 |
| 126 // If there is no launcher item in the launcher for application |app_id|, one |
| 127 // gets created. The (existing or created) launcher items get then locked |
| 128 // against a users un-pinning removal. |
| 129 virtual void LockV1AppWithID(const std::string& app_id) OVERRIDE; |
| 130 |
| 131 // A previously locked launcher item of type |app_id| gets unlocked. If the |
| 132 // lock count reaches 0 and the item is not pinned it will go away. |
| 133 virtual void UnlockV1AppWithID(const std::string& app_id) OVERRIDE; |
| 134 |
126 // Requests that the launcher item controller specified by |id| open a new | 135 // Requests that the launcher item controller specified by |id| open a new |
127 // instance of the app. |event_flags| holds the flags of the event which | 136 // instance of the app. |event_flags| holds the flags of the event which |
128 // triggered this command. | 137 // triggered this command. |
129 virtual void Launch(ash::LauncherID id, int event_flags) OVERRIDE; | 138 virtual void Launch(ash::LauncherID id, int event_flags) OVERRIDE; |
130 | 139 |
131 // Closes the specified item. | 140 // Closes the specified item. |
132 virtual void Close(ash::LauncherID id) OVERRIDE; | 141 virtual void Close(ash::LauncherID id) OVERRIDE; |
133 | 142 |
134 // Returns true if the specified item is open. | 143 // Returns true if the specified item is open. |
135 virtual bool IsOpen(ash::LauncherID id) OVERRIDE; | 144 virtual bool IsOpen(ash::LauncherID id) OVERRIDE; |
(...skipping 22 matching lines...) Expand all Loading... |
158 const std::string& app_id) OVERRIDE; | 167 const std::string& app_id) OVERRIDE; |
159 virtual std::string GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE; | 168 virtual std::string GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE; |
160 | 169 |
161 // Set the image for a specific launcher item (e.g. when set by the app). | 170 // Set the image for a specific launcher item (e.g. when set by the app). |
162 virtual void SetLauncherItemImage(ash::LauncherID launcher_id, | 171 virtual void SetLauncherItemImage(ash::LauncherID launcher_id, |
163 const gfx::ImageSkia& image) OVERRIDE; | 172 const gfx::ImageSkia& image) OVERRIDE; |
164 | 173 |
165 // Returns true if a pinned launcher item with given |app_id| could be found. | 174 // Returns true if a pinned launcher item with given |app_id| could be found. |
166 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE; | 175 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE; |
167 | 176 |
| 177 // Find out if the given application |id| is a windowed app item and not a |
| 178 // pinned item in the launcher. |
| 179 bool IsWindowedAppInLauncher(const std::string& app_id); |
| 180 |
168 // Pins an app with |app_id| to launcher. If there is a running instance in | 181 // Pins an app with |app_id| to launcher. If there is a running instance in |
169 // launcher, the running instance is pinned. If there is no running instance, | 182 // launcher, the running instance is pinned. If there is no running instance, |
170 // a new launcher item is created and pinned. | 183 // a new launcher item is created and pinned. |
171 virtual void PinAppWithID(const std::string& app_id) OVERRIDE; | 184 virtual void PinAppWithID(const std::string& app_id) OVERRIDE; |
172 | 185 |
173 // Updates the launche type of the app for the specified id to |launch_type|. | 186 // Updates the launche type of the app for the specified id to |launch_type|. |
174 virtual void SetLaunchType( | 187 virtual void SetLaunchType( |
175 ash::LauncherID id, | 188 ash::LauncherID id, |
176 extensions::ExtensionPrefs::LaunchType launch_type) OVERRIDE; | 189 extensions::ExtensionPrefs::LaunchType launch_type) OVERRIDE; |
177 | 190 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 // These are intended for testing. | 324 // These are intended for testing. |
312 virtual void SetAppTabHelperForTest(AppTabHelper* helper) OVERRIDE; | 325 virtual void SetAppTabHelperForTest(AppTabHelper* helper) OVERRIDE; |
313 virtual void SetAppIconLoaderForTest(ash::AppIconLoader* loader) OVERRIDE; | 326 virtual void SetAppIconLoaderForTest(ash::AppIconLoader* loader) OVERRIDE; |
314 virtual const std::string& GetAppIdFromLauncherIdForTest( | 327 virtual const std::string& GetAppIdFromLauncherIdForTest( |
315 ash::LauncherID id) OVERRIDE; | 328 ash::LauncherID id) OVERRIDE; |
316 | 329 |
317 private: | 330 private: |
318 friend class ChromeLauncherControllerPerAppTest; | 331 friend class ChromeLauncherControllerPerAppTest; |
319 friend class LauncherPerAppAppBrowserTest; | 332 friend class LauncherPerAppAppBrowserTest; |
320 | 333 |
| 334 // Creates a new app shortcut item and controller on the launcher at |index|. |
| 335 // Use kInsertItemAtEnd to add a shortcut as the last item. |
| 336 virtual ash::LauncherID CreateAppShortcutLauncherItemWithType( |
| 337 const std::string& app_id, |
| 338 int index, |
| 339 ash::LauncherItemType launcher_item_type); |
| 340 |
321 // Updates the activation state of the Broswer item. | 341 // Updates the activation state of the Broswer item. |
322 void UpdateBrowserItemStatus(); | 342 void UpdateBrowserItemStatus(); |
323 | 343 |
324 typedef std::map<ash::LauncherID, LauncherItemController*> | 344 typedef std::map<ash::LauncherID, LauncherItemController*> |
325 IDToItemControllerMap; | 345 IDToItemControllerMap; |
326 typedef std::list<content::WebContents*> WebContentsList; | 346 typedef std::list<content::WebContents*> WebContentsList; |
327 typedef std::map<std::string, WebContentsList> AppIDToWebContentsListMap; | 347 typedef std::map<std::string, WebContentsList> AppIDToWebContentsListMap; |
328 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap; | 348 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap; |
329 | 349 |
330 // Returns the profile used for new windows. | 350 // Returns the profile used for new windows. |
(...skipping 21 matching lines...) Expand all Loading... |
352 void SetShelfAlignmentFromPrefs(); | 372 void SetShelfAlignmentFromPrefs(); |
353 | 373 |
354 // Sets both of auto-hide behavior and alignment from prefs. | 374 // Sets both of auto-hide behavior and alignment from prefs. |
355 void SetShelfBehaviorsFromPrefs(); | 375 void SetShelfBehaviorsFromPrefs(); |
356 | 376 |
357 // Returns the most recently active web contents for an app. | 377 // Returns the most recently active web contents for an app. |
358 content::WebContents* GetLastActiveWebContents(const std::string& app_id); | 378 content::WebContents* GetLastActiveWebContents(const std::string& app_id); |
359 | 379 |
360 // Creates an app launcher to insert at |index|. Note that |index| may be | 380 // Creates an app launcher to insert at |index|. Note that |index| may be |
361 // adjusted by the model to meet ordering constraints. | 381 // adjusted by the model to meet ordering constraints. |
| 382 // The |launcher_item_type| will be set into the LauncherModel. |
362 ash::LauncherID InsertAppLauncherItem( | 383 ash::LauncherID InsertAppLauncherItem( |
363 LauncherItemController* controller, | 384 LauncherItemController* controller, |
364 const std::string& app_id, | 385 const std::string& app_id, |
365 ash::LauncherItemStatus status, | 386 ash::LauncherItemStatus status, |
366 int index); | 387 int index, |
| 388 ash::LauncherItemType launcher_item_type); |
367 | 389 |
368 bool HasItemController(ash::LauncherID id) const; | 390 bool HasItemController(ash::LauncherID id) const; |
369 | 391 |
370 // Enumerate all Web contents which match a given shortcut |controller|. | 392 // Enumerate all Web contents which match a given shortcut |controller|. |
371 std::vector<content::WebContents*> GetV1ApplicationsFromController( | 393 std::vector<content::WebContents*> GetV1ApplicationsFromController( |
372 LauncherItemController* controller); | 394 LauncherItemController* controller); |
373 | 395 |
374 // Returns the list of all browsers runing. | 396 // Returns the list of all browsers runing. |
375 // TODO(skuhne): Move to wherever the BrowserLauncherItemController | 397 // TODO(skuhne): Move to wherever the BrowserLauncherItemController |
376 // functionality moves to. | 398 // functionality moves to. |
(...skipping 27 matching lines...) Expand all Loading... |
404 PrefChangeRegistrar pref_change_registrar_; | 426 PrefChangeRegistrar pref_change_registrar_; |
405 | 427 |
406 AppSyncUIState* app_sync_ui_state_; | 428 AppSyncUIState* app_sync_ui_state_; |
407 | 429 |
408 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; | 430 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; |
409 | 431 |
410 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPerApp); | 432 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPerApp); |
411 }; | 433 }; |
412 | 434 |
413 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_ | 435 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_PER_APP_H_ |
OLD | NEW |