OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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_SYNC_GLUE_EXTENSION_SYNC_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_EXTENSION_SYNC_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_EXTENSION_SYNC_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_EXTENSION_SYNC_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // This file contains functions necessary for syncing | 9 // This file contains functions necessary for syncing |
10 // extensions-related data types. | 10 // extensions-related data types. |
11 | 11 |
12 #include <map> | 12 #include <map> |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 class Extension; | 15 class Extension; |
16 class ExtensionsService; | 16 class ExtensionService; |
17 class Profile; | 17 class Profile; |
18 class ProfileSyncService; | 18 class ProfileSyncService; |
19 | 19 |
20 namespace sync_pb { | 20 namespace sync_pb { |
21 class ExtensionSpecifics; | 21 class ExtensionSpecifics; |
22 } // namespace sync_pb | 22 } // namespace sync_pb |
23 | 23 |
24 namespace browser_sync { | 24 namespace browser_sync { |
25 | 25 |
26 class ExtensionData; | 26 class ExtensionData; |
27 struct ExtensionSyncTraits; | 27 struct ExtensionSyncTraits; |
28 | 28 |
29 // A map from extension IDs to ExtensionData objects. | 29 // A map from extension IDs to ExtensionData objects. |
30 typedef std::map<std::string, ExtensionData> ExtensionDataMap; | 30 typedef std::map<std::string, ExtensionData> ExtensionDataMap; |
31 | 31 |
32 // Fills in |has_children| with whether or not the root node with the | 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. | 33 // given tag has child nodes. Returns true iff the lookup succeeded. |
34 // | 34 // |
35 // TODO(akalin): Move this somewhere where it can be used by | 35 // TODO(akalin): Move this somewhere where it can be used by |
36 // other data types. | 36 // other data types. |
37 bool RootNodeHasChildren(const char* tag, | 37 bool RootNodeHasChildren(const char* tag, |
38 ProfileSyncService* sync_service, | 38 ProfileSyncService* sync_service, |
39 bool* has_children); | 39 bool* has_children); |
40 | 40 |
41 ExtensionsService* GetExtensionsServiceFromProfile(Profile* profile); | 41 ExtensionService* GetExtensionServiceFromProfile(Profile* profile); |
42 | 42 |
43 // Fills |extension_data_map| with both client-side information about | 43 // Fills |extension_data_map| with both client-side information about |
44 // installed extensions and the server-side information about | 44 // installed extensions and the server-side information about |
45 // extensions to be synced. Returns true iff this was successful; if | 45 // extensions to be synced. Returns true iff this was successful; if |
46 // unsuccessful, the contents of |extension_data_map| are undefined. | 46 // unsuccessful, the contents of |extension_data_map| are undefined. |
47 bool SlurpExtensionData(const ExtensionSyncTraits& traits, | 47 bool SlurpExtensionData(const ExtensionSyncTraits& traits, |
48 ProfileSyncService* sync_service, | 48 ProfileSyncService* sync_service, |
49 ExtensionDataMap* extension_data_map); | 49 ExtensionDataMap* extension_data_map); |
50 | 50 |
51 // Updates the server and client as necessary from | 51 // Updates the server and client as necessary from |
(...skipping 15 matching lines...) Expand all Loading... |
67 std::string* error); | 67 std::string* error); |
68 | 68 |
69 // Removes the server data for the given extension ID. | 69 // Removes the server data for the given extension ID. |
70 void RemoveServerData(const ExtensionSyncTraits& traits, | 70 void RemoveServerData(const ExtensionSyncTraits& traits, |
71 const std::string& id, | 71 const std::string& id, |
72 ProfileSyncService* sync_service); | 72 ProfileSyncService* sync_service); |
73 | 73 |
74 // Starts updating the client data from the given server data. | 74 // Starts updating the client data from the given server data. |
75 void UpdateClient(const ExtensionSyncTraits& traits, | 75 void UpdateClient(const ExtensionSyncTraits& traits, |
76 const sync_pb::ExtensionSpecifics& server_data, | 76 const sync_pb::ExtensionSpecifics& server_data, |
77 ExtensionsService* extensions_service); | 77 ExtensionService* extensions_service); |
78 | 78 |
79 // Removes existing client data for the given extension. | 79 // Removes existing client data for the given extension. |
80 void RemoveFromClient(const ExtensionSyncTraits& traits, | 80 void RemoveFromClient(const ExtensionSyncTraits& traits, |
81 const std::string& id, | 81 const std::string& id, |
82 ExtensionsService* extensions_service); | 82 ExtensionService* extensions_service); |
83 | 83 |
84 } // namespace browser_sync | 84 } // namespace browser_sync |
85 | 85 |
86 #endif // CHROME_BROWSER_SYNC_GLUE_EXTENSION_SYNC_H_ | 86 #endif // CHROME_BROWSER_SYNC_GLUE_EXTENSION_SYNC_H_ |
OLD | NEW |