| 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_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 virtual bool IsValidID(const std::string& id) = 0; | 65 virtual bool IsValidID(const std::string& id) = 0; |
| 66 | 66 |
| 67 // Fetches the image for the specified id. When done (which may be | 67 // Fetches the image for the specified id. When done (which may be |
| 68 // synchronous), this should invoke SetAppImage() on the LauncherUpdater. | 68 // synchronous), this should invoke SetAppImage() on the LauncherUpdater. |
| 69 virtual void FetchImage(const std::string& id) = 0; | 69 virtual void FetchImage(const std::string& id) = 0; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 ChromeLauncherDelegate(Profile* profile, ash::LauncherModel* model); | 72 ChromeLauncherDelegate(Profile* profile, ash::LauncherModel* model); |
| 73 virtual ~ChromeLauncherDelegate(); | 73 virtual ~ChromeLauncherDelegate(); |
| 74 | 74 |
| 75 // Initializes this ChromeLauncherDelegate. | |
| 76 void Init(); | |
| 77 | |
| 78 // Returns the single ChromeLauncherDelegate instnace. | 75 // Returns the single ChromeLauncherDelegate instnace. |
| 79 static ChromeLauncherDelegate* instance() { return instance_; } | 76 static ChromeLauncherDelegate* instance() { return instance_; } |
| 80 | 77 |
| 81 // Registers the prefs used by ChromeLauncherDelegate. | 78 // Registers the prefs used by ChromeLauncherDelegate. |
| 82 static void RegisterUserPrefs(PrefService* user_prefs); | 79 static void RegisterUserPrefs(PrefService* user_prefs); |
| 83 | 80 |
| 84 // Creates a new tabbed item on the launcher for |updater|. | 81 // Creates a new tabbed item on the launcher for |updater|. |
| 85 ash::LauncherID CreateTabbedLauncherItem(LauncherUpdater* updater, | 82 ash::LauncherID CreateTabbedLauncherItem(LauncherUpdater* updater, |
| 86 IncognitoState is_incognito); | 83 IncognitoState is_incognito); |
| 87 | 84 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 194 |
| 198 // The LauncherUpdater this item came from. NULL if pinned and not open. | 195 // The LauncherUpdater this item came from. NULL if pinned and not open. |
| 199 LauncherUpdater* updater; | 196 LauncherUpdater* updater; |
| 200 | 197 |
| 201 // Whether the item is pinned. | 198 // Whether the item is pinned. |
| 202 bool pinned; | 199 bool pinned; |
| 203 }; | 200 }; |
| 204 | 201 |
| 205 typedef std::map<ash::LauncherID, Item> IDToItemMap; | 202 typedef std::map<ash::LauncherID, Item> IDToItemMap; |
| 206 | 203 |
| 204 // Initializes this ChromeLauncherDelegate. This is called after the |
| 205 // NOTIFICATION_PROFILE_CREATED event. |
| 206 void PostProfileInit(); |
| 207 |
| 207 // Updates the pinned pref state. The pinned state consists of a list pref. | 208 // Updates the pinned pref state. The pinned state consists of a list pref. |
| 208 // Each item of the list is a dictionary. The key |kAppIDPath| gives the | 209 // Each item of the list is a dictionary. The key |kAppIDPath| gives the |
| 209 // id of the app. |kAppTypePath| is one of |kAppTypeTab| or |kAppTypeWindow| | 210 // id of the app. |kAppTypePath| is one of |kAppTypeTab| or |kAppTypeWindow| |
| 210 // and indicates how the app is opened. | 211 // and indicates how the app is opened. |
| 211 void PersistPinnedState(); | 212 void PersistPinnedState(); |
| 212 | 213 |
| 213 // Unpins any app items whose id is |app_id|. | 214 // Unpins any app items whose id is |app_id|. |
| 214 void UnpinAppsWithID(const std::string& app_id); | 215 void UnpinAppsWithID(const std::string& app_id); |
| 215 | 216 |
| 216 // Sets the AppIconLoader, taking ownership of |loader|. This is intended for | 217 // Sets the AppIconLoader, taking ownership of |loader|. |
| 217 // testing. | 218 void SetAppIconLoader(AppIconLoader* loader); |
| 218 void SetAppIconLoaderForTest(AppIconLoader* loader); | |
| 219 | 219 |
| 220 // Returns the profile used for new windows. | 220 // Returns the profile used for new windows. |
| 221 Profile* GetProfileForNewWindows(); | 221 Profile* GetProfileForNewWindows(); |
| 222 | 222 |
| 223 static ChromeLauncherDelegate* instance_; | 223 static ChromeLauncherDelegate* instance_; |
| 224 | 224 |
| 225 ash::LauncherModel* model_; | 225 ash::LauncherModel* model_; |
| 226 | 226 |
| 227 // Profile used for prefs and loading extensions. This is NOT necessarily the | 227 // Profile used for prefs and loading extensions. This is NOT necessarily the |
| 228 // profile new windows are created with. | 228 // profile new windows are created with. |
| 229 Profile* profile_; | 229 Profile* profile_; |
| 230 | 230 |
| 231 IDToItemMap id_to_item_map_; | 231 IDToItemMap id_to_item_map_; |
| 232 | 232 |
| 233 // Used to load the image for an app tab. | 233 // Used to load the image for an app tab. |
| 234 scoped_ptr<AppIconLoader> app_icon_loader_; | 234 scoped_ptr<AppIconLoader> app_icon_loader_; |
| 235 | 235 |
| 236 content::NotificationRegistrar registrar_; | 236 content::NotificationRegistrar registrar_; |
| 237 | 237 |
| 238 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherDelegate); | 238 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherDelegate); |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_DELEGATE_H_ | 241 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_CHROME_LAUNCHER_DELEGATE_H_ |
| OLD | NEW |