Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/version.h" | 11 #include "base/version.h" |
| 12 #include "chrome/browser/sync/api/sync_change.h" | |
| 13 #include "chrome/common/extensions/extension.h" | |
| 12 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 13 | 15 |
| 14 // A struct that encapsulates the synced properties of an Extension. | 16 class ExtensionService; |
| 15 struct ExtensionSyncData { | 17 class SyncData; |
|
akalin
2011/08/12 03:35:02
need to #include sync_data.h, since you're returni
| |
| 18 namespace sync_pb { class ExtensionSpecifics; } | |
| 19 | |
| 20 // A class that encapsulates the synced properties of an Extension. | |
| 21 class ExtensionSyncData { | |
| 22 public: | |
| 16 ExtensionSyncData(); | 23 ExtensionSyncData(); |
| 24 explicit ExtensionSyncData(const SyncData& sync_data); | |
| 25 explicit ExtensionSyncData(const SyncChange& sync_change); | |
| 26 ExtensionSyncData(const Extension& extension, | |
| 27 bool enabled, | |
| 28 bool incognito_enabled); | |
| 17 ~ExtensionSyncData(); | 29 ~ExtensionSyncData(); |
| 18 | 30 |
| 19 // Merge |new_data| into this object. All version-independent | 31 // Convert an ExtensionSyncData back out to a sync structure. |
| 20 // properties are copied from |new_data|, and version-dependent | 32 void PopulateSyncSpecifics(sync_pb::ExtensionSpecifics* specifics) const; |
| 21 // properties are copied only if |new_data|'s version is equal to or | 33 SyncData GetSyncData() const; |
| 22 // greater than the current version. | 34 SyncChange GetSyncChange(SyncChange::SyncChangeType change_type) const; |
| 23 void Merge(const ExtensionSyncData& new_data); | |
| 24 | 35 |
| 25 std::string id; | 36 std::string id() const { return id_; } |
|
asargent_no_longer_on_chrome
2011/08/12 20:50:39
nit: should return "const std::string&"
| |
| 26 | 37 |
| 27 // Version-independent properties (i.e., used even when the | 38 // Version-independent properties (i.e., used even when the |
| 28 // version of the currently-installed extension doesn't match | 39 // version of the currently-installed extension doesn't match |
| 29 // |version|). | 40 // |version|). |
| 30 bool uninstalled; | 41 bool uninstalled() const { return uninstalled_; } |
| 31 bool enabled; | 42 bool enabled() const { return enabled_; } |
| 32 bool incognito_enabled; | 43 bool incognito_enabled() const { return incognito_enabled_; } |
| 44 Extension::SyncType type() const { return type_; } | |
| 33 | 45 |
| 34 // Version-dependent properties (i.e., should be used only when the | 46 // Version-dependent properties (i.e., should be used only when the |
| 35 // version of the currenty-installed extension matches |version|). | 47 // version of the currenty-installed extension matches |version|). |
| 36 Version version; | 48 Version version() const { return version_; } |
|
asargent_no_longer_on_chrome
2011/08/12 20:50:39
nit: should return "const Version&"
| |
| 37 GURL update_url; | 49 GURL update_url() const { return update_url_; } |
| 38 // Used only for debugging. | 50 // Used only for debugging. |
| 39 std::string name; | 51 std::string name() const { return name_; } |
| 52 | |
| 53 private: | |
| 54 void PopulateFromExtensionSpecifics( | |
| 55 const sync_pb::ExtensionSpecifics& specifics); | |
| 56 void PopulateFromSyncData(const SyncData& sync_data); | |
| 57 | |
| 58 std::string id_; | |
| 59 bool uninstalled_; | |
| 60 bool enabled_; | |
| 61 bool incognito_enabled_; | |
| 62 Extension::SyncType type_; | |
| 63 Version version_; | |
| 64 GURL update_url_; | |
| 65 std::string name_; | |
| 40 }; | 66 }; |
| 41 | 67 |
| 42 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ | 68 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ |
| OLD | NEW |