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_APP_SYNC_DATA_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_ |
7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/extensions/extension_sync_data.h" | 9 #include "chrome/browser/extensions/extension_sync_data.h" |
9 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
10 #include "sync/api/string_ordinal.h" | 11 #include "sync/api/string_ordinal.h" |
11 #include "sync/api/sync_change.h" | 12 #include "sync/api/sync_change.h" |
12 #include "third_party/skia/include/core/SkColor.h" | 13 #include "third_party/skia/include/core/SkColor.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 AppSpecifics; | 20 class AppSpecifics; |
20 } | 21 } |
21 | 22 |
22 namespace extensions { | 23 namespace extensions { |
23 | 24 |
24 class Extension; | 25 class Extension; |
25 class ExtensionSyncData; | 26 class ExtensionSyncData; |
26 | 27 |
27 // A class that encapsulates the synced properties of an Application. | 28 // A class that encapsulates the synced properties of an Application. |
28 class AppSyncData { | 29 class AppSyncData { |
29 public: | 30 public: |
30 AppSyncData(); | 31 AppSyncData(); |
31 explicit AppSyncData(const syncer::SyncData& sync_data); | |
32 explicit AppSyncData(const syncer::SyncChange& sync_change); | |
33 AppSyncData(const Extension& extension, | 32 AppSyncData(const Extension& extension, |
34 bool enabled, | 33 bool enabled, |
35 bool incognito_enabled, | 34 bool incognito_enabled, |
36 bool remote_install, | 35 bool remote_install, |
37 ExtensionSyncData::OptionalBoolean all_urls_enabled, | 36 ExtensionSyncData::OptionalBoolean all_urls_enabled, |
38 const syncer::StringOrdinal& app_launch_ordinal, | 37 const syncer::StringOrdinal& app_launch_ordinal, |
39 const syncer::StringOrdinal& page_ordinal, | 38 const syncer::StringOrdinal& page_ordinal, |
40 extensions::LaunchType launch_type); | 39 extensions::LaunchType launch_type); |
41 ~AppSyncData(); | 40 ~AppSyncData(); |
42 | 41 |
| 42 // For constructing an AppSyncData from received sync data. |
| 43 // May return null if the sync data was invalid. |
| 44 static scoped_ptr<AppSyncData> CreateFromSyncData( |
| 45 const syncer::SyncData& sync_data); |
| 46 static scoped_ptr<AppSyncData> CreateFromSyncChange( |
| 47 const syncer::SyncChange& sync_change); |
| 48 |
43 // Retrive sync data from this class. | 49 // Retrive sync data from this class. |
44 syncer::SyncData GetSyncData() const; | 50 syncer::SyncData GetSyncData() const; |
45 syncer::SyncChange GetSyncChange( | 51 syncer::SyncChange GetSyncChange( |
46 syncer::SyncChange::SyncChangeType change_type) const; | 52 syncer::SyncChange::SyncChangeType change_type) const; |
47 | 53 |
48 const std::string& id() const { return extension_sync_data_.id(); } | 54 const std::string& id() const { return extension_sync_data_.id(); } |
49 | 55 |
50 bool uninstalled() const { return extension_sync_data_.uninstalled(); } | 56 bool uninstalled() const { return extension_sync_data_.uninstalled(); } |
51 | 57 |
52 // These ordinals aren't necessarily valid. Some applications don't have | 58 // These ordinals aren't necessarily valid. Some applications don't have |
(...skipping 20 matching lines...) Expand all Loading... |
73 } | 79 } |
74 | 80 |
75 const std::string& bookmark_app_icon_color() const { | 81 const std::string& bookmark_app_icon_color() const { |
76 return bookmark_app_icon_color_; | 82 return bookmark_app_icon_color_; |
77 } | 83 } |
78 | 84 |
79 private: | 85 private: |
80 // Convert an AppSyncData back out to a sync structure. | 86 // Convert an AppSyncData back out to a sync structure. |
81 void PopulateAppSpecifics(sync_pb::AppSpecifics* specifics) const; | 87 void PopulateAppSpecifics(sync_pb::AppSpecifics* specifics) const; |
82 | 88 |
83 // Populate this class from sync inputs. | 89 // Populate this class from sync inputs. Return true if the input |
84 void PopulateFromAppSpecifics( | 90 // was valid. |
85 const sync_pb::AppSpecifics& specifics); | 91 bool PopulateFromAppSpecifics(const sync_pb::AppSpecifics& specifics); |
86 void PopulateFromSyncData(const syncer::SyncData& sync_data); | 92 bool PopulateFromSyncData(const syncer::SyncData& sync_data); |
87 | 93 |
88 ExtensionSyncData extension_sync_data_; | 94 ExtensionSyncData extension_sync_data_; |
89 syncer::StringOrdinal app_launch_ordinal_; | 95 syncer::StringOrdinal app_launch_ordinal_; |
90 syncer::StringOrdinal page_ordinal_; | 96 syncer::StringOrdinal page_ordinal_; |
91 extensions::LaunchType launch_type_; | 97 extensions::LaunchType launch_type_; |
92 std::string bookmark_app_url_; | 98 std::string bookmark_app_url_; |
93 std::string bookmark_app_description_; | 99 std::string bookmark_app_description_; |
94 std::string bookmark_app_icon_color_; | 100 std::string bookmark_app_icon_color_; |
95 }; | 101 }; |
96 | 102 |
97 } // namespace extensions | 103 } // namespace extensions |
98 | 104 |
99 #endif // CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_ | 105 #endif // CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_ |
100 | |
OLD | NEW |