OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_GLUE_EXTENSION_SYNC_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_EXTENSION_SYNC_H_ |
| 7 #pragma once |
| 8 |
| 9 // This file contains functions necessary for syncing |
| 10 // extensions-related data types. |
| 11 |
| 12 #include <map> |
| 13 #include <string> |
| 14 |
| 15 class Extension; |
| 16 class ExtensionsService; |
| 17 class Profile; |
| 18 class ProfileSyncService; |
| 19 |
| 20 namespace sync_pb { |
| 21 class ExtensionSpecifics; |
| 22 } // namespace sync_pb |
| 23 |
| 24 namespace browser_sync { |
| 25 |
| 26 class ExtensionData; |
| 27 struct ExtensionSyncTraits; |
| 28 |
| 29 // A map from extension IDs to ExtensionData objects. |
| 30 typedef std::map<std::string, ExtensionData> ExtensionDataMap; |
| 31 |
| 32 // Fills in |has_children| with whether or not the root node with the |
| 33 // given tag has child nodes. Returns true iff the lookup succeeded. |
| 34 // |
| 35 // TODO(akalin): Move this somewhere where it can be used by |
| 36 // other data types. |
| 37 bool RootNodeHasChildren(const char* tag, |
| 38 ProfileSyncService* sync_service, |
| 39 bool* has_children); |
| 40 |
| 41 ExtensionsService* GetExtensionsServiceFromProfile(Profile* profile); |
| 42 |
| 43 // Fills |extension_data_map| with both client-side information about |
| 44 // installed extensions and the server-side information about |
| 45 // extensions to be synced. Returns true iff this was successful; if |
| 46 // unsuccessful, the contents of |extension_data_map| are undefined. |
| 47 bool SlurpExtensionData(const ExtensionSyncTraits& traits, |
| 48 ProfileSyncService* sync_service, |
| 49 ExtensionDataMap* extension_data_map); |
| 50 |
| 51 // Updates the server and client as necessary from |
| 52 // |extension_data_map|. Returns true iff this was successful. |
| 53 // |
| 54 // NOTE(akalin): Keep in mind that updating the client is an |
| 55 // asynchronous process; the only thing that's guaranteed if this |
| 56 // function is returned is that the updates were successfully started. |
| 57 bool FlushExtensionData(const ExtensionSyncTraits& traits, |
| 58 const ExtensionDataMap& extension_data_map, |
| 59 ProfileSyncService* sync_service); |
| 60 |
| 61 // Updates the server data for the given extension. Returns true iff |
| 62 // this was successful; if unsuccessful, an error string is put into |
| 63 // |error|. |
| 64 bool UpdateServerData(const ExtensionSyncTraits& traits, |
| 65 const Extension& extension, |
| 66 ProfileSyncService* sync_service, |
| 67 std::string* error); |
| 68 |
| 69 // Updates the server data for the given extension, if it exists. |
| 70 void RemoveServerData(const ExtensionSyncTraits& traits, |
| 71 const Extension& extension, |
| 72 ProfileSyncService* sync_service); |
| 73 |
| 74 // Starts updating the client data from the given server data. |
| 75 void UpdateClient(const ExtensionSyncTraits& traits, |
| 76 const sync_pb::ExtensionSpecifics& server_data, |
| 77 ExtensionsService* extensions_service); |
| 78 |
| 79 // Removes existing client data for the given extension. |
| 80 void RemoveFromClient(const ExtensionSyncTraits& traits, |
| 81 const std::string& id, |
| 82 ExtensionsService* extensions_service); |
| 83 |
| 84 } // namespace browser_sync |
| 85 |
| 86 #endif // CHROME_BROWSER_SYNC_GLUE_EXTENSION_SYNC_H_ |
OLD | NEW |