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 "chrome/browser/extensions/extension_sync_data.h" | 8 #include "chrome/browser/extensions/extension_sync_data.h" |
| 9 #include "chrome/common/extensions/extension_constants.h" |
9 #include "sync/api/string_ordinal.h" | 10 #include "sync/api/string_ordinal.h" |
10 #include "sync/api/sync_change.h" | 11 #include "sync/api/sync_change.h" |
11 | 12 |
12 namespace syncer { | 13 namespace syncer { |
13 class SyncData; | 14 class SyncData; |
14 } | 15 } |
15 | 16 |
16 namespace sync_pb { | 17 namespace sync_pb { |
17 class AppSpecifics; | 18 class AppSpecifics; |
18 } | 19 } |
19 | 20 |
20 namespace extensions { | 21 namespace extensions { |
21 | 22 |
22 class Extension; | 23 class Extension; |
23 class ExtensionSyncData; | 24 class ExtensionSyncData; |
24 | 25 |
25 // A class that encapsulates the synced properties of an Application. | 26 // A class that encapsulates the synced properties of an Application. |
26 class AppSyncData { | 27 class AppSyncData { |
27 public: | 28 public: |
28 AppSyncData(); | 29 AppSyncData(); |
29 explicit AppSyncData(const syncer::SyncData& sync_data); | 30 explicit AppSyncData(const syncer::SyncData& sync_data); |
30 explicit AppSyncData(const syncer::SyncChange& sync_change); | 31 explicit AppSyncData(const syncer::SyncChange& sync_change); |
31 AppSyncData(const Extension& extension, | 32 AppSyncData(const Extension& extension, |
32 bool enabled, | 33 bool enabled, |
33 bool incognito_enabled, | 34 bool incognito_enabled, |
34 const syncer::StringOrdinal& app_launch_ordinal, | 35 const syncer::StringOrdinal& app_launch_ordinal, |
35 const syncer::StringOrdinal& page_ordinal); | 36 const syncer::StringOrdinal& page_ordinal, |
| 37 extensions::LaunchType launch_type); |
36 ~AppSyncData(); | 38 ~AppSyncData(); |
37 | 39 |
38 // Retrive sync data from this class. | 40 // Retrive sync data from this class. |
39 syncer::SyncData GetSyncData() const; | 41 syncer::SyncData GetSyncData() const; |
40 syncer::SyncChange GetSyncChange( | 42 syncer::SyncChange GetSyncChange( |
41 syncer::SyncChange::SyncChangeType change_type) const; | 43 syncer::SyncChange::SyncChangeType change_type) const; |
42 | 44 |
43 const std::string& id() const { return extension_sync_data_.id(); } | 45 const std::string& id() const { return extension_sync_data_.id(); } |
44 | 46 |
45 bool uninstalled() const { return extension_sync_data_.uninstalled(); } | 47 bool uninstalled() const { return extension_sync_data_.uninstalled(); } |
46 | 48 |
47 // These ordinals aren't necessarily valid. Some applications don't have | 49 // These ordinals aren't necessarily valid. Some applications don't have |
48 // valid ordinals because they don't appear on the new tab page. | 50 // valid ordinals because they don't appear on the new tab page. |
49 const syncer::StringOrdinal& app_launch_ordinal() const { | 51 const syncer::StringOrdinal& app_launch_ordinal() const { |
50 return app_launch_ordinal_; | 52 return app_launch_ordinal_; |
51 } | 53 } |
52 const syncer::StringOrdinal& page_ordinal() const { return page_ordinal_; } | 54 const syncer::StringOrdinal& page_ordinal() const { return page_ordinal_; } |
53 | 55 |
54 const ExtensionSyncData& extension_sync_data() const { | 56 const ExtensionSyncData& extension_sync_data() const { |
55 return extension_sync_data_; | 57 return extension_sync_data_; |
56 } | 58 } |
57 | 59 |
| 60 extensions::LaunchType launch_type() const { |
| 61 return launch_type_; |
| 62 } |
| 63 |
58 private: | 64 private: |
59 // Convert an AppSyncData back out to a sync structure. | 65 // Convert an AppSyncData back out to a sync structure. |
60 void PopulateAppSpecifics(sync_pb::AppSpecifics* specifics) const; | 66 void PopulateAppSpecifics(sync_pb::AppSpecifics* specifics) const; |
61 | 67 |
62 // Populate this class from sync inputs. | 68 // Populate this class from sync inputs. |
63 void PopulateFromAppSpecifics( | 69 void PopulateFromAppSpecifics( |
64 const sync_pb::AppSpecifics& specifics); | 70 const sync_pb::AppSpecifics& specifics); |
65 void PopulateFromSyncData(const syncer::SyncData& sync_data); | 71 void PopulateFromSyncData(const syncer::SyncData& sync_data); |
66 | 72 |
67 ExtensionSyncData extension_sync_data_; | 73 ExtensionSyncData extension_sync_data_; |
68 syncer::StringOrdinal app_launch_ordinal_; | 74 syncer::StringOrdinal app_launch_ordinal_; |
69 syncer::StringOrdinal page_ordinal_; | 75 syncer::StringOrdinal page_ordinal_; |
| 76 extensions::LaunchType launch_type_; |
70 }; | 77 }; |
71 | 78 |
72 } // namespace extensions | 79 } // namespace extensions |
73 | 80 |
74 #endif // CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_ | 81 #endif // CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_ |
75 | 82 |
OLD | NEW |