| 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_EXTENSIONS_EXTENSION_SYNC_BUNDLE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_BUNDLE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_BUNDLE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_BUNDLE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "chrome/browser/extensions/extension_sync_data.h" | 16 #include "chrome/browser/extensions/extension_sync_data.h" |
| 17 #include "sync/api/syncable_service.h" | 17 #include "sync/api/syncable_service.h" |
| 18 | 18 |
| 19 class SyncChangeProcessor; | |
| 20 class ExtensionService; | 19 class ExtensionService; |
| 21 class ExtensionSet; | 20 class ExtensionSet; |
| 21 |
| 22 namespace csync { |
| 23 class SyncChangeProcessor; |
| 22 class SyncErrorFactory; | 24 class SyncErrorFactory; |
| 25 } |
| 23 | 26 |
| 24 namespace extensions { | 27 namespace extensions { |
| 25 | 28 |
| 26 class Extension; | 29 class Extension; |
| 27 | 30 |
| 28 // Bundle of extension specific sync stuff. | 31 // Bundle of extension specific sync stuff. |
| 29 class ExtensionSyncBundle { | 32 class ExtensionSyncBundle { |
| 30 public: | 33 public: |
| 31 explicit ExtensionSyncBundle(ExtensionService* extension_service); | 34 explicit ExtensionSyncBundle(ExtensionService* extension_service); |
| 32 ~ExtensionSyncBundle(); | 35 ~ExtensionSyncBundle(); |
| 33 | 36 |
| 34 // Setup this bundle to be sync extension data. | 37 // Setup this bundle to be sync extension data. |
| 35 void SetupSync(SyncChangeProcessor* sync_processor, | 38 void SetupSync(csync::SyncChangeProcessor* sync_processor, |
| 36 SyncErrorFactory* sync_error_factory, | 39 csync::SyncErrorFactory* sync_error_factory, |
| 37 const SyncDataList& initial_sync_data); | 40 const csync::SyncDataList& initial_sync_data); |
| 38 | 41 |
| 39 // Resets this class back to it default values, which will disable all syncing | 42 // Resets this class back to it default values, which will disable all syncing |
| 40 // until a new sync processor is set. | 43 // until a new sync processor is set. |
| 41 void Reset(); | 44 void Reset(); |
| 42 | 45 |
| 43 // Returns a SyncChange that will delete the given extension. | 46 // Returns a csync::SyncChange that will delete the given extension. |
| 44 SyncChange CreateSyncChangeToDelete(const Extension* extension) const; | 47 csync::SyncChange CreateSyncChangeToDelete(const Extension* extension) const; |
| 45 | 48 |
| 46 // Process the sync deletion of the given extension. | 49 // Process the sync deletion of the given extension. |
| 47 void ProcessDeletion(std::string extension_id, const SyncChange& sync_change); | 50 void ProcessDeletion( |
| 51 std::string extension_id, const csync::SyncChange& sync_change); |
| 48 | 52 |
| 49 // Create a sync change based on |sync_data|. | 53 // Create a sync change based on |sync_data|. |
| 50 SyncChange CreateSyncChange(const SyncData& sync_data); | 54 csync::SyncChange CreateSyncChange(const csync::SyncData& sync_data); |
| 51 | 55 |
| 52 // Get all the sync data contained in this bundle. | 56 // Get all the sync data contained in this bundle. |
| 53 SyncDataList GetAllSyncData() const; | 57 csync::SyncDataList GetAllSyncData() const; |
| 54 | 58 |
| 55 // Process the given sync change and apply it. | 59 // Process the given sync change and apply it. |
| 56 void ProcessSyncChange(ExtensionSyncData extension_sync_data); | 60 void ProcessSyncChange(ExtensionSyncData extension_sync_data); |
| 57 | 61 |
| 58 // Sync a newly-installed extension or change an existing one. | 62 // Sync a newly-installed extension or change an existing one. |
| 59 void SyncChangeIfNeeded(const Extension& extension); | 63 void SyncChangeIfNeeded(const Extension& extension); |
| 60 | 64 |
| 61 // Process the list of sync changes. | 65 // Process the list of sync changes. |
| 62 void ProcessSyncChangeList(SyncChangeList sync_change_list); | 66 void ProcessSyncChangeList(csync::SyncChangeList sync_change_list); |
| 63 | 67 |
| 64 // Check to see if the given |id| is either synced or pending to be synced. | 68 // Check to see if the given |id| is either synced or pending to be synced. |
| 65 bool HasExtensionId(const std::string& id) const; | 69 bool HasExtensionId(const std::string& id) const; |
| 66 bool HasPendingExtensionId(const std::string& id) const; | 70 bool HasPendingExtensionId(const std::string& id) const; |
| 67 | 71 |
| 68 // Add a pending extension to be synced. | 72 // Add a pending extension to be synced. |
| 69 void AddPendingExtension(const std::string& id, | 73 void AddPendingExtension(const std::string& id, |
| 70 const ExtensionSyncData& extension_sync_data); | 74 const ExtensionSyncData& extension_sync_data); |
| 71 | 75 |
| 72 // Returns true if |extension| should be handled by this sync bundle. | 76 // Returns true if |extension| should be handled by this sync bundle. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 84 // Add a synced extension. | 88 // Add a synced extension. |
| 85 void AddExtension(const std::string& id); | 89 void AddExtension(const std::string& id); |
| 86 | 90 |
| 87 // Remove a synced extension. | 91 // Remove a synced extension. |
| 88 void RemoveExtension(const std::string& id); | 92 void RemoveExtension(const std::string& id); |
| 89 | 93 |
| 90 // Change an extension from being pending to synced. | 94 // Change an extension from being pending to synced. |
| 91 void MarkPendingExtensionSynced(const std::string& id); | 95 void MarkPendingExtensionSynced(const std::string& id); |
| 92 | 96 |
| 93 ExtensionService* extension_service_; // Owns us. | 97 ExtensionService* extension_service_; // Owns us. |
| 94 scoped_ptr<SyncChangeProcessor> sync_processor_; | 98 scoped_ptr<csync::SyncChangeProcessor> sync_processor_; |
| 95 scoped_ptr<SyncErrorFactory> sync_error_factory_; | 99 scoped_ptr<csync::SyncErrorFactory> sync_error_factory_; |
| 96 | 100 |
| 97 std::set<std::string> synced_extensions_; | 101 std::set<std::string> synced_extensions_; |
| 98 std::map<std::string, ExtensionSyncData> pending_sync_data_; | 102 std::map<std::string, ExtensionSyncData> pending_sync_data_; |
| 99 | 103 |
| 100 DISALLOW_COPY_AND_ASSIGN(ExtensionSyncBundle); | 104 DISALLOW_COPY_AND_ASSIGN(ExtensionSyncBundle); |
| 101 }; | 105 }; |
| 102 | 106 |
| 103 } // namespace extensions | 107 } // namespace extensions |
| 104 | 108 |
| 105 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_BUNDLE_H_ | 109 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_BUNDLE_H_ |
| OLD | NEW |