| OLD | NEW |
| 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_APP_LIST_APP_LIST_SYNCABLE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SYNCABLE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SYNCABLE_SERVICE_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SYNCABLE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 class Profile; | 32 class Profile; |
| 33 | 33 |
| 34 namespace extensions { | 34 namespace extensions { |
| 35 class ExtensionSystem; | 35 class ExtensionSystem; |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace sync_pb { | 38 namespace sync_pb { |
| 39 class AppListSpecifics; | 39 class AppListSpecifics; |
| 40 } | 40 } |
| 41 | 41 |
| 42 namespace user_prefs { |
| 43 class PrefRegistrySyncable; |
| 44 } |
| 45 |
| 42 namespace app_list { | 46 namespace app_list { |
| 43 | 47 |
| 44 class AppListFolderItem; | 48 class AppListFolderItem; |
| 45 class AppListItem; | 49 class AppListItem; |
| 46 class AppListModel; | 50 class AppListModel; |
| 47 | 51 |
| 48 // Keyed Service that owns, stores, and syncs an AppListModel for a profile. | 52 // Keyed Service that owns, stores, and syncs an AppListModel for a profile. |
| 49 class AppListSyncableService : public syncer::SyncableService, | 53 class AppListSyncableService : public syncer::SyncableService, |
| 50 public KeyedService, | 54 public KeyedService, |
| 51 public DriveAppUninstallSyncService { | 55 public DriveAppUninstallSyncService { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 74 }; | 78 }; |
| 75 | 79 |
| 76 using SyncItemMap = std::map<std::string, std::unique_ptr<SyncItem>>; | 80 using SyncItemMap = std::map<std::string, std::unique_ptr<SyncItem>>; |
| 77 | 81 |
| 78 // Populates the model when |extension_system| is ready. | 82 // Populates the model when |extension_system| is ready. |
| 79 AppListSyncableService(Profile* profile, | 83 AppListSyncableService(Profile* profile, |
| 80 extensions::ExtensionSystem* extension_system); | 84 extensions::ExtensionSystem* extension_system); |
| 81 | 85 |
| 82 ~AppListSyncableService() override; | 86 ~AppListSyncableService() override; |
| 83 | 87 |
| 88 // Registers prefs to support local storage. |
| 89 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 90 |
| 84 // Adds |item| to |sync_items_| and |model_|. If a sync item already exists, | 91 // Adds |item| to |sync_items_| and |model_|. If a sync item already exists, |
| 85 // updates the existing sync item instead. | 92 // updates the existing sync item instead. |
| 86 void AddItem(std::unique_ptr<AppListItem> app_item); | 93 void AddItem(std::unique_ptr<AppListItem> app_item); |
| 87 | 94 |
| 88 // Removes sync item matching |id|. | 95 // Removes sync item matching |id|. |
| 89 void RemoveItem(const std::string& id); | 96 void RemoveItem(const std::string& id); |
| 90 | 97 |
| 91 // Removes sync item matching |id| after item uninstall. | 98 // Removes sync item matching |id| after item uninstall. |
| 92 void RemoveUninstalledItem(const std::string& id); | 99 void RemoveUninstalledItem(const std::string& id); |
| 93 | 100 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 std::string FindOrCreateOemFolder(); | 229 std::string FindOrCreateOemFolder(); |
| 223 | 230 |
| 224 // Gets the location for the OEM folder. Called when the folder is first | 231 // Gets the location for the OEM folder. Called when the folder is first |
| 225 // created. | 232 // created. |
| 226 syncer::StringOrdinal GetOemFolderPos(); | 233 syncer::StringOrdinal GetOemFolderPos(); |
| 227 | 234 |
| 228 // Returns true if an extension matching |id| exists and was installed by | 235 // Returns true if an extension matching |id| exists and was installed by |
| 229 // an OEM (extension->was_installed_by_oem() is true). | 236 // an OEM (extension->was_installed_by_oem() is true). |
| 230 bool AppIsOem(const std::string& id); | 237 bool AppIsOem(const std::string& id); |
| 231 | 238 |
| 239 // Initializes sync items from the local storage while sync service is not |
| 240 // enabled. |
| 241 void InitFromLocalStorage(); |
| 242 |
| 232 // Helper that notifies observers that sync model has been updated. | 243 // Helper that notifies observers that sync model has been updated. |
| 233 void NotifyObserversSyncUpdated(); | 244 void NotifyObserversSyncUpdated(); |
| 234 | 245 |
| 235 Profile* profile_; | 246 Profile* profile_; |
| 236 extensions::ExtensionSystem* extension_system_; | 247 extensions::ExtensionSystem* extension_system_; |
| 237 std::unique_ptr<AppListModel> model_; | 248 std::unique_ptr<AppListModel> model_; |
| 238 std::unique_ptr<ModelObserver> model_observer_; | 249 std::unique_ptr<ModelObserver> model_observer_; |
| 239 std::unique_ptr<ExtensionAppModelBuilder> apps_builder_; | 250 std::unique_ptr<ExtensionAppModelBuilder> apps_builder_; |
| 240 #if defined(OS_CHROMEOS) | 251 #if defined(OS_CHROMEOS) |
| 241 std::unique_ptr<ArcAppModelBuilder> arc_apps_builder_; | 252 std::unique_ptr<ArcAppModelBuilder> arc_apps_builder_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 253 | 264 |
| 254 // Provides integration with Drive apps. | 265 // Provides integration with Drive apps. |
| 255 std::unique_ptr<DriveAppProvider> drive_app_provider_; | 266 std::unique_ptr<DriveAppProvider> drive_app_provider_; |
| 256 | 267 |
| 257 DISALLOW_COPY_AND_ASSIGN(AppListSyncableService); | 268 DISALLOW_COPY_AND_ASSIGN(AppListSyncableService); |
| 258 }; | 269 }; |
| 259 | 270 |
| 260 } // namespace app_list | 271 } // namespace app_list |
| 261 | 272 |
| 262 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SYNCABLE_SERVICE_H_ | 273 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SYNCABLE_SERVICE_H_ |
| OLD | NEW |