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. | |
not at google - send to devlin
2015/03/11 23:21:34
Mention these may be null (because...)
Yoyo Zhou
2015/03/12 00:25:48
Ok. Also changed to not use the implicit construct
| |
43 static scoped_ptr<AppSyncData> CreateFromSyncData( | |
44 const syncer::SyncData& sync_data); | |
45 static scoped_ptr<AppSyncData> CreateFromSyncChange( | |
46 const syncer::SyncChange& sync_change); | |
47 | |
43 // Retrive sync data from this class. | 48 // Retrive sync data from this class. |
44 syncer::SyncData GetSyncData() const; | 49 syncer::SyncData GetSyncData() const; |
45 syncer::SyncChange GetSyncChange( | 50 syncer::SyncChange GetSyncChange( |
46 syncer::SyncChange::SyncChangeType change_type) const; | 51 syncer::SyncChange::SyncChangeType change_type) const; |
47 | 52 |
48 const std::string& id() const { return extension_sync_data_.id(); } | 53 const std::string& id() const { return extension_sync_data_.id(); } |
49 | 54 |
50 bool uninstalled() const { return extension_sync_data_.uninstalled(); } | 55 bool uninstalled() const { return extension_sync_data_.uninstalled(); } |
51 | 56 |
52 // These ordinals aren't necessarily valid. Some applications don't have | 57 // These ordinals aren't necessarily valid. Some applications don't have |
(...skipping 20 matching lines...) Expand all Loading... | |
73 } | 78 } |
74 | 79 |
75 const std::string& bookmark_app_icon_color() const { | 80 const std::string& bookmark_app_icon_color() const { |
76 return bookmark_app_icon_color_; | 81 return bookmark_app_icon_color_; |
77 } | 82 } |
78 | 83 |
79 private: | 84 private: |
80 // Convert an AppSyncData back out to a sync structure. | 85 // Convert an AppSyncData back out to a sync structure. |
81 void PopulateAppSpecifics(sync_pb::AppSpecifics* specifics) const; | 86 void PopulateAppSpecifics(sync_pb::AppSpecifics* specifics) const; |
82 | 87 |
83 // Populate this class from sync inputs. | 88 // Populate this class from sync inputs. Return true if the input |
84 void PopulateFromAppSpecifics( | 89 // was valid. |
85 const sync_pb::AppSpecifics& specifics); | 90 bool PopulateFromAppSpecifics(const sync_pb::AppSpecifics& specifics); |
86 void PopulateFromSyncData(const syncer::SyncData& sync_data); | 91 bool PopulateFromSyncData(const syncer::SyncData& sync_data); |
87 | 92 |
88 ExtensionSyncData extension_sync_data_; | 93 ExtensionSyncData extension_sync_data_; |
89 syncer::StringOrdinal app_launch_ordinal_; | 94 syncer::StringOrdinal app_launch_ordinal_; |
90 syncer::StringOrdinal page_ordinal_; | 95 syncer::StringOrdinal page_ordinal_; |
91 extensions::LaunchType launch_type_; | 96 extensions::LaunchType launch_type_; |
92 std::string bookmark_app_url_; | 97 std::string bookmark_app_url_; |
93 std::string bookmark_app_description_; | 98 std::string bookmark_app_description_; |
94 std::string bookmark_app_icon_color_; | 99 std::string bookmark_app_icon_color_; |
95 }; | 100 }; |
96 | 101 |
97 } // namespace extensions | 102 } // namespace extensions |
98 | 103 |
99 #endif // CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_ | 104 #endif // CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_ |
100 | |
OLD | NEW |