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