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