| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 81 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 82 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; | 82 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; |
| 83 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; | 83 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; |
| 84 virtual syncer::SyncDataList GetAllSyncData( | 84 virtual syncer::SyncDataList GetAllSyncData( |
| 85 syncer::ModelType type) const OVERRIDE; | 85 syncer::ModelType type) const OVERRIDE; |
| 86 virtual syncer::SyncError ProcessSyncChanges( | 86 virtual syncer::SyncError ProcessSyncChanges( |
| 87 const tracked_objects::Location& from_here, | 87 const tracked_objects::Location& from_here, |
| 88 const syncer::SyncChangeList& change_list) OVERRIDE; | 88 const syncer::SyncChangeList& change_list) OVERRIDE; |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 class ItemListObserver; | 91 class ModelObserver; |
| 92 typedef std::map<std::string, SyncItem*> SyncItemMap; | 92 typedef std::map<std::string, SyncItem*> SyncItemMap; |
| 93 | 93 |
| 94 // content::NotificationObserver | 94 // content::NotificationObserver |
| 95 virtual void Observe(int type, | 95 virtual void Observe(int type, |
| 96 const content::NotificationSource& source, | 96 const content::NotificationSource& source, |
| 97 const content::NotificationDetails& details) OVERRIDE; | 97 const content::NotificationDetails& details) OVERRIDE; |
| 98 | 98 |
| 99 // Builds the model once ExtensionService is ready. | 99 // Builds the model once ExtensionService is ready. |
| 100 void BuildModel(); | 100 void BuildModel(); |
| 101 | 101 |
| 102 // Returns true if sync has restarted, otherwise runs |flare_|. | 102 // Returns true if sync has restarted, otherwise runs |flare_|. |
| 103 bool SyncStarted(); | 103 bool SyncStarted(); |
| 104 | 104 |
| 105 // If |app_item| matches an existing sync item, updates the sync item and | 105 // If |app_item| matches an existing sync item, returns it. Otherwise adds |
| 106 // returns it. Otherwise adds |app_item| to |sync_items_| and returns the new | 106 // |app_item| to |sync_items_| and returns the new item. If |app_item| is |
| 107 // item. If |app_item| is invalid returns NULL. | 107 // invalid returns NULL. |
| 108 SyncItem* AddOrUpdateSyncItem(AppListItem* app_item); | 108 SyncItem* FindOrAddSyncItem(AppListItem* app_item); |
| 109 | 109 |
| 110 // Creates a sync item for |app_item| and sends an ADD SyncChange event. | 110 // Creates a sync item for |app_item| and sends an ADD SyncChange event. |
| 111 SyncItem* CreateSyncItemFromAppItem(AppListItem* app_item); | 111 SyncItem* CreateSyncItemFromAppItem(AppListItem* app_item); |
| 112 | 112 |
| 113 // If a sync item for |app_item| already exists, update |app_item| from the | 113 // If a sync item for |app_item| already exists, update |app_item| from the |
| 114 // sync item, otherwise create a new sync item from |app_item|. | 114 // sync item, otherwise create a new sync item from |app_item|. |
| 115 void AddOrUpdateFromSyncItem(AppListItem* app_item); | 115 void AddOrUpdateFromSyncItem(AppListItem* app_item); |
| 116 | 116 |
| 117 // Either uninstalling a default app or remove the REMOVE_DEFAULT sync item. | 117 // Either uninstalling a default app or remove the REMOVE_DEFAULT sync item. |
| 118 // Returns true if the app is removed. Otherwise deletes the existing sync | 118 // Returns true if the app is removed. Otherwise deletes the existing sync |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 const std::string& item_id, | 155 const std::string& item_id, |
| 156 sync_pb::AppListSpecifics::AppListItemType item_type); | 156 sync_pb::AppListSpecifics::AppListItemType item_type); |
| 157 | 157 |
| 158 // Deletes a SyncItem matching |specifics|. | 158 // Deletes a SyncItem matching |specifics|. |
| 159 void DeleteSyncItemSpecifics(const sync_pb::AppListSpecifics& specifics); | 159 void DeleteSyncItemSpecifics(const sync_pb::AppListSpecifics& specifics); |
| 160 | 160 |
| 161 Profile* profile_; | 161 Profile* profile_; |
| 162 extensions::ExtensionSystem* extension_system_; | 162 extensions::ExtensionSystem* extension_system_; |
| 163 content::NotificationRegistrar registrar_; | 163 content::NotificationRegistrar registrar_; |
| 164 scoped_ptr<AppListModel> model_; | 164 scoped_ptr<AppListModel> model_; |
| 165 scoped_ptr<ItemListObserver> item_list_observer_; | 165 scoped_ptr<ModelObserver> model_observer_; |
| 166 scoped_ptr<ExtensionAppModelBuilder> apps_builder_; | 166 scoped_ptr<ExtensionAppModelBuilder> apps_builder_; |
| 167 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 167 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; |
| 168 scoped_ptr<syncer::SyncErrorFactory> sync_error_handler_; | 168 scoped_ptr<syncer::SyncErrorFactory> sync_error_handler_; |
| 169 SyncItemMap sync_items_; | 169 SyncItemMap sync_items_; |
| 170 syncer::SyncableService::StartSyncFlare flare_; | 170 syncer::SyncableService::StartSyncFlare flare_; |
| 171 | 171 |
| 172 DISALLOW_COPY_AND_ASSIGN(AppListSyncableService); | 172 DISALLOW_COPY_AND_ASSIGN(AppListSyncableService); |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 } // namespace app_list | 175 } // namespace app_list |
| 176 | 176 |
| 177 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SYNCABLE_SERVICE_H_ | 177 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SYNCABLE_SERVICE_H_ |
| OLD | NEW |