| 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 <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 std::string parent_id; | 55 std::string parent_id; |
| 56 syncer::StringOrdinal item_ordinal; | 56 syncer::StringOrdinal item_ordinal; |
| 57 | 57 |
| 58 std::string ToString() const; | 58 std::string ToString() const; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // Populates the model when |extension_system| is ready. | 61 // Populates the model when |extension_system| is ready. |
| 62 AppListSyncableService(Profile* profile, | 62 AppListSyncableService(Profile* profile, |
| 63 extensions::ExtensionSystem* extension_system); | 63 extensions::ExtensionSystem* extension_system); |
| 64 | 64 |
| 65 virtual ~AppListSyncableService(); | 65 ~AppListSyncableService() override; |
| 66 | 66 |
| 67 // Adds |item| to |sync_items_| and |model_|. If a sync item already exists, | 67 // Adds |item| to |sync_items_| and |model_|. If a sync item already exists, |
| 68 // updates the existing sync item instead. | 68 // updates the existing sync item instead. |
| 69 void AddItem(scoped_ptr<AppListItem> app_item); | 69 void AddItem(scoped_ptr<AppListItem> app_item); |
| 70 | 70 |
| 71 // Removes sync item matching |id|. | 71 // Removes sync item matching |id|. |
| 72 void RemoveItem(const std::string& id); | 72 void RemoveItem(const std::string& id); |
| 73 | 73 |
| 74 // Called when properties of an item may have changed, e.g. default/oem state. | 74 // Called when properties of an item may have changed, e.g. default/oem state. |
| 75 void UpdateItem(AppListItem* app_item); | 75 void UpdateItem(AppListItem* app_item); |
| 76 | 76 |
| 77 // Returns the existing sync item matching |id| or NULL. | 77 // Returns the existing sync item matching |id| or NULL. |
| 78 const SyncItem* GetSyncItem(const std::string& id) const; | 78 const SyncItem* GetSyncItem(const std::string& id) const; |
| 79 | 79 |
| 80 // Sets the name of the folder for OEM apps. | 80 // Sets the name of the folder for OEM apps. |
| 81 void SetOemFolderName(const std::string& name); | 81 void SetOemFolderName(const std::string& name); |
| 82 | 82 |
| 83 Profile* profile() { return profile_; } | 83 Profile* profile() { return profile_; } |
| 84 AppListModel* model() { return model_.get(); } | 84 AppListModel* model() { return model_.get(); } |
| 85 size_t GetNumSyncItemsForTest() const { return sync_items_.size(); } | 85 size_t GetNumSyncItemsForTest() const { return sync_items_.size(); } |
| 86 const std::string& GetOemFolderNameForTest() const { | 86 const std::string& GetOemFolderNameForTest() const { |
| 87 return oem_folder_name_; | 87 return oem_folder_name_; |
| 88 } | 88 } |
| 89 void ResetDriveAppProviderForTest(); | 89 void ResetDriveAppProviderForTest(); |
| 90 | 90 |
| 91 // syncer::SyncableService | 91 // syncer::SyncableService |
| 92 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 92 syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 93 syncer::ModelType type, | 93 syncer::ModelType type, |
| 94 const syncer::SyncDataList& initial_sync_data, | 94 const syncer::SyncDataList& initial_sync_data, |
| 95 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 95 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 96 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; | 96 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; |
| 97 virtual void StopSyncing(syncer::ModelType type) override; | 97 void StopSyncing(syncer::ModelType type) override; |
| 98 virtual syncer::SyncDataList GetAllSyncData( | 98 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
| 99 syncer::ModelType type) const override; | 99 syncer::SyncError ProcessSyncChanges( |
| 100 virtual syncer::SyncError ProcessSyncChanges( | |
| 101 const tracked_objects::Location& from_here, | 100 const tracked_objects::Location& from_here, |
| 102 const syncer::SyncChangeList& change_list) override; | 101 const syncer::SyncChangeList& change_list) override; |
| 103 | 102 |
| 104 private: | 103 private: |
| 105 class ModelObserver; | 104 class ModelObserver; |
| 106 typedef std::map<std::string, SyncItem*> SyncItemMap; | 105 typedef std::map<std::string, SyncItem*> SyncItemMap; |
| 107 | 106 |
| 108 // KeyedService | 107 // KeyedService |
| 109 virtual void Shutdown() override; | 108 void Shutdown() override; |
| 110 | 109 |
| 111 // DriveAppUninstallSyncService | 110 // DriveAppUninstallSyncService |
| 112 virtual void TrackUninstalledDriveApp( | 111 void TrackUninstalledDriveApp(const std::string& drive_app_id) override; |
| 113 const std::string& drive_app_id) override; | 112 void UntrackUninstalledDriveApp(const std::string& drive_app_id) override; |
| 114 virtual void UntrackUninstalledDriveApp( | |
| 115 const std::string& drive_app_id) override; | |
| 116 | 113 |
| 117 // content::NotificationObserver | 114 // content::NotificationObserver |
| 118 virtual void Observe(int type, | 115 void Observe(int type, |
| 119 const content::NotificationSource& source, | 116 const content::NotificationSource& source, |
| 120 const content::NotificationDetails& details) override; | 117 const content::NotificationDetails& details) override; |
| 121 | 118 |
| 122 // Builds the model once ExtensionService is ready. | 119 // Builds the model once ExtensionService is ready. |
| 123 void BuildModel(); | 120 void BuildModel(); |
| 124 | 121 |
| 125 // Returns true if sync has restarted, otherwise runs |flare_|. | 122 // Returns true if sync has restarted, otherwise runs |flare_|. |
| 126 bool SyncStarted(); | 123 bool SyncStarted(); |
| 127 | 124 |
| 128 // If |app_item| matches an existing sync item, returns it. Otherwise adds | 125 // If |app_item| matches an existing sync item, returns it. Otherwise adds |
| 129 // |app_item| to |sync_items_| and returns the new item. If |app_item| is | 126 // |app_item| to |sync_items_| and returns the new item. If |app_item| is |
| 130 // invalid returns NULL. | 127 // invalid returns NULL. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 214 |
| 218 // Provides integration with Drive apps. | 215 // Provides integration with Drive apps. |
| 219 scoped_ptr<DriveAppProvider> drive_app_provider_; | 216 scoped_ptr<DriveAppProvider> drive_app_provider_; |
| 220 | 217 |
| 221 DISALLOW_COPY_AND_ASSIGN(AppListSyncableService); | 218 DISALLOW_COPY_AND_ASSIGN(AppListSyncableService); |
| 222 }; | 219 }; |
| 223 | 220 |
| 224 } // namespace app_list | 221 } // namespace app_list |
| 225 | 222 |
| 226 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SYNCABLE_SERVICE_H_ | 223 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SYNCABLE_SERVICE_H_ |
| OLD | NEW |