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