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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_
6 #define CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_
8 #include "chrome/browser/extensions/extension_sync_data.h"
9 #include "chrome/common/extensions/extension_constants.h"
10 #include "sync/api/string_ordinal.h"
11 #include "sync/api/sync_change.h"
21 namespace extensions
{
24 class ExtensionSyncData
;
26 // A class that encapsulates the synced properties of an Application.
30 explicit AppSyncData(const syncer::SyncData
& sync_data
);
31 explicit AppSyncData(const syncer::SyncChange
& sync_change
);
32 AppSyncData(const Extension
& extension
,
34 bool incognito_enabled
,
36 const syncer::StringOrdinal
& app_launch_ordinal
,
37 const syncer::StringOrdinal
& page_ordinal
,
38 extensions::LaunchType launch_type
);
41 // Retrive sync data from this class.
42 syncer::SyncData
GetSyncData() const;
43 syncer::SyncChange
GetSyncChange(
44 syncer::SyncChange::SyncChangeType change_type
) const;
46 const std::string
& id() const { return extension_sync_data_
.id(); }
48 bool uninstalled() const { return extension_sync_data_
.uninstalled(); }
50 // These ordinals aren't necessarily valid. Some applications don't have
51 // valid ordinals because they don't appear on the new tab page.
52 const syncer::StringOrdinal
& app_launch_ordinal() const {
53 return app_launch_ordinal_
;
55 const syncer::StringOrdinal
& page_ordinal() const { return page_ordinal_
; }
57 const ExtensionSyncData
& extension_sync_data() const {
58 return extension_sync_data_
;
61 extensions::LaunchType
launch_type() const {
65 const std::string
& bookmark_app_url() const {
66 return bookmark_app_url_
;
69 const std::string
& bookmark_app_description() const {
70 return bookmark_app_description_
;
74 // Convert an AppSyncData back out to a sync structure.
75 void PopulateAppSpecifics(sync_pb::AppSpecifics
* specifics
) const;
77 // Populate this class from sync inputs.
78 void PopulateFromAppSpecifics(
79 const sync_pb::AppSpecifics
& specifics
);
80 void PopulateFromSyncData(const syncer::SyncData
& sync_data
);
82 ExtensionSyncData extension_sync_data_
;
83 syncer::StringOrdinal app_launch_ordinal_
;
84 syncer::StringOrdinal page_ordinal_
;
85 extensions::LaunchType launch_type_
;
86 std::string bookmark_app_url_
;
87 std::string bookmark_app_description_
;
90 } // namespace extensions
92 #endif // CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_