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_DATA_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | |
10 #include "base/version.h" | 11 #include "base/version.h" |
11 #include "sync/api/sync_change.h" | 12 #include "sync/api/sync_change.h" |
12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
13 | 14 |
14 namespace syncer { | 15 namespace syncer { |
15 class SyncData; | 16 class SyncData; |
16 } | 17 } |
17 | 18 |
18 namespace sync_pb { | 19 namespace sync_pb { |
19 class ExtensionSpecifics; | 20 class ExtensionSpecifics; |
20 } | 21 } |
21 | 22 |
22 namespace extensions { | 23 namespace extensions { |
23 | 24 |
24 class Extension; | 25 class Extension; |
25 | 26 |
26 // A class that encapsulates the synced properties of an Extension. | 27 // A class that encapsulates the synced properties of an Extension. |
27 class ExtensionSyncData { | 28 class ExtensionSyncData { |
28 public: | 29 public: |
29 enum OptionalBoolean { | 30 enum OptionalBoolean { |
30 BOOLEAN_UNSET, | 31 BOOLEAN_UNSET, |
31 BOOLEAN_TRUE, | 32 BOOLEAN_TRUE, |
32 BOOLEAN_FALSE | 33 BOOLEAN_FALSE |
33 }; | 34 }; |
34 | 35 |
35 ExtensionSyncData(); | 36 ExtensionSyncData(); |
36 explicit ExtensionSyncData(const syncer::SyncData& sync_data); | |
37 explicit ExtensionSyncData(const syncer::SyncChange& sync_change); | |
38 ExtensionSyncData(const Extension& extension, | 37 ExtensionSyncData(const Extension& extension, |
39 bool enabled, | 38 bool enabled, |
40 bool incognito_enabled, | 39 bool incognito_enabled, |
41 bool remote_install, | 40 bool remote_install, |
42 OptionalBoolean all_urls_enabled); | 41 OptionalBoolean all_urls_enabled); |
43 ~ExtensionSyncData(); | 42 ~ExtensionSyncData(); |
44 | 43 |
44 // For constructing an ExtensionSyncData from received sync data. | |
not at google - send to devlin
2015/03/11 23:21:34
Same comment as before.
Yoyo Zhou
2015/03/12 00:25:49
Done.
| |
45 static scoped_ptr<ExtensionSyncData> CreateFromSyncData( | |
46 const syncer::SyncData& sync_data); | |
47 static scoped_ptr<ExtensionSyncData> CreateFromSyncChange( | |
48 const syncer::SyncChange& sync_change); | |
49 | |
45 // Retrieve sync data from this class. | 50 // Retrieve sync data from this class. |
46 syncer::SyncData GetSyncData() const; | 51 syncer::SyncData GetSyncData() const; |
47 syncer::SyncChange GetSyncChange( | 52 syncer::SyncChange GetSyncChange( |
48 syncer::SyncChange::SyncChangeType change_type) const; | 53 syncer::SyncChange::SyncChangeType change_type) const; |
49 | 54 |
50 // Convert an ExtensionSyncData back out to a sync structure. | 55 // Convert an ExtensionSyncData back out to a sync structure. |
51 void PopulateExtensionSpecifics(sync_pb::ExtensionSpecifics* specifics) const; | 56 void PopulateExtensionSpecifics(sync_pb::ExtensionSpecifics* specifics) const; |
52 | 57 |
53 // Populate this class from sync inputs. | 58 // Populate this class from sync inputs. Returns true if the input was valid. |
54 void PopulateFromExtensionSpecifics( | 59 bool PopulateFromExtensionSpecifics( |
55 const sync_pb::ExtensionSpecifics& specifics); | 60 const sync_pb::ExtensionSpecifics& specifics); |
56 | 61 |
57 void set_uninstalled(bool uninstalled); | 62 void set_uninstalled(bool uninstalled); |
58 | 63 |
59 const std::string& id() const { return id_; } | 64 const std::string& id() const { return id_; } |
60 | 65 |
61 // Version-independent properties (i.e., used even when the | 66 // Version-independent properties (i.e., used even when the |
62 // version of the currently-installed extension doesn't match | 67 // version of the currently-installed extension doesn't match |
63 // |version|). | 68 // |version|). |
64 bool uninstalled() const { return uninstalled_; } | 69 bool uninstalled() const { return uninstalled_; } |
65 bool enabled() const { return enabled_; } | 70 bool enabled() const { return enabled_; } |
66 bool incognito_enabled() const { return incognito_enabled_; } | 71 bool incognito_enabled() const { return incognito_enabled_; } |
67 bool remote_install() const { return remote_install_; } | 72 bool remote_install() const { return remote_install_; } |
68 OptionalBoolean all_urls_enabled() const { return all_urls_enabled_; } | 73 OptionalBoolean all_urls_enabled() const { return all_urls_enabled_; } |
69 bool installed_by_custodian() const { return installed_by_custodian_; } | 74 bool installed_by_custodian() const { return installed_by_custodian_; } |
70 | 75 |
71 // Version-dependent properties (i.e., should be used only when the | 76 // Version-dependent properties (i.e., should be used only when the |
72 // version of the currenty-installed extension matches |version|). | 77 // version of the currenty-installed extension matches |version|). |
73 const Version& version() const { return version_; } | 78 const Version& version() const { return version_; } |
74 const GURL& update_url() const { return update_url_; } | 79 const GURL& update_url() const { return update_url_; } |
75 // Used only for debugging. | 80 // Used only for debugging. |
76 const std::string& name() const { return name_; } | 81 const std::string& name() const { return name_; } |
77 | 82 |
78 private: | 83 private: |
79 // Populate this class from sync inputs. | 84 // Populate this class from sync inputs. |
80 void PopulateFromSyncData(const syncer::SyncData& sync_data); | 85 bool PopulateFromSyncData(const syncer::SyncData& sync_data); |
81 | 86 |
82 std::string id_; | 87 std::string id_; |
83 bool uninstalled_; | 88 bool uninstalled_; |
84 bool enabled_; | 89 bool enabled_; |
85 bool incognito_enabled_; | 90 bool incognito_enabled_; |
86 bool remote_install_; | 91 bool remote_install_; |
87 OptionalBoolean all_urls_enabled_; | 92 OptionalBoolean all_urls_enabled_; |
88 bool installed_by_custodian_; | 93 bool installed_by_custodian_; |
89 Version version_; | 94 Version version_; |
90 GURL update_url_; | 95 GURL update_url_; |
91 std::string name_; | 96 std::string name_; |
92 }; | 97 }; |
93 | 98 |
94 } // namespace extensions | 99 } // namespace extensions |
95 | 100 |
96 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ | 101 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ |
OLD | NEW |