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_UTIL_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_EXTENSION_UTIL_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_EXTENSION_UTIL_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_EXTENSION_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 // This file contains some low-level utility functions used by |
| 10 // extensions sync. |
| 11 |
| 12 #include <set> |
9 #include <string> | 13 #include <string> |
10 | 14 |
11 class Extension; | 15 class Extension; |
| 16 class ExtensionTypeSet; |
12 class ExtensionsService; | 17 class ExtensionsService; |
13 | 18 |
14 namespace sync_pb { | 19 namespace sync_pb { |
15 class ExtensionSpecifics; | 20 class ExtensionSpecifics; |
16 } // sync_pb | 21 } // sync_pb |
17 | 22 |
18 namespace browser_sync { | 23 namespace browser_sync { |
19 | 24 |
| 25 enum ExtensionType { |
| 26 THEME, |
| 27 EXTENSION, |
| 28 USER_SCRIPT, |
| 29 APP, |
| 30 }; |
| 31 |
| 32 typedef std::set<ExtensionType> ExtensionTypeSet; |
| 33 |
| 34 // Returns the type of the given extension. |
| 35 // |
| 36 // TODO(akalin): Might be useful to move this into extension.cc. |
| 37 ExtensionType GetExtensionType(const Extension& extension); |
| 38 |
20 // Returns whether or not the given extension is one we want to sync. | 39 // Returns whether or not the given extension is one we want to sync. |
21 bool IsExtensionSyncable(const Extension& extension); | 40 bool IsExtensionValid(const Extension& extension); |
| 41 |
| 42 // Returns whether or not the given extension is one we want to sync. |
| 43 bool IsExtensionValidAndSyncable(const Extension& extension, |
| 44 const ExtensionTypeSet& allowed_types); |
22 | 45 |
23 // Stringifies the given ExtensionSpecifics. | 46 // Stringifies the given ExtensionSpecifics. |
24 std::string ExtensionSpecificsToString( | 47 std::string ExtensionSpecificsToString( |
25 const sync_pb::ExtensionSpecifics& specifics); | 48 const sync_pb::ExtensionSpecifics& specifics); |
26 | 49 |
27 // Returns whether or not the values of the given specifics are valid, | 50 // Returns whether or not the values of the given specifics are valid, |
28 // in particular the id, version, and update URL. | 51 // in particular the id, version, and update URL. |
29 bool IsExtensionSpecificsValid( | 52 bool IsExtensionSpecificsValid( |
30 const sync_pb::ExtensionSpecifics& specifics); | 53 const sync_pb::ExtensionSpecifics& specifics); |
31 | 54 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // user properties if |merge_user_properties| is set) if |specifics| | 127 // user properties if |merge_user_properties| is set) if |specifics| |
105 // has a more recent or the same version as |merged_specifics|. | 128 // has a more recent or the same version as |merged_specifics|. |
106 void MergeExtensionSpecifics( | 129 void MergeExtensionSpecifics( |
107 const sync_pb::ExtensionSpecifics& specifics, | 130 const sync_pb::ExtensionSpecifics& specifics, |
108 bool merge_user_properties, | 131 bool merge_user_properties, |
109 sync_pb::ExtensionSpecifics* merged_specifics); | 132 sync_pb::ExtensionSpecifics* merged_specifics); |
110 | 133 |
111 } // namespace browser_sync | 134 } // namespace browser_sync |
112 | 135 |
113 #endif // CHROME_BROWSER_SYNC_GLUE_EXTENSION_UTIL_H_ | 136 #endif // CHROME_BROWSER_SYNC_GLUE_EXTENSION_UTIL_H_ |
OLD | NEW |