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 "base/memory/scoped_ptr.h"
9 #include "chrome/browser/extensions/extension_sync_data.h"
10 #include "extensions/common/constants.h"
11 #include "sync/api/string_ordinal.h"
12 #include "sync/api/sync_change.h"
13 #include "third_party/skia/include/core/SkColor.h"
23 namespace extensions
{
26 class ExtensionSyncData
;
28 // A class that encapsulates the synced properties of an Application.
31 struct LinkedAppIconInfo
{
40 AppSyncData(const Extension
& extension
,
43 bool incognito_enabled
,
45 ExtensionSyncData::OptionalBoolean all_urls_enabled
,
46 const syncer::StringOrdinal
& app_launch_ordinal
,
47 const syncer::StringOrdinal
& page_ordinal
,
48 extensions::LaunchType launch_type
);
51 // For constructing an AppSyncData from received sync data.
52 // May return null if the sync data was invalid.
53 static scoped_ptr
<AppSyncData
> CreateFromSyncData(
54 const syncer::SyncData
& sync_data
);
55 static scoped_ptr
<AppSyncData
> CreateFromSyncChange(
56 const syncer::SyncChange
& sync_change
);
58 // Retrive sync data from this class.
59 syncer::SyncData
GetSyncData() const;
60 syncer::SyncChange
GetSyncChange(
61 syncer::SyncChange::SyncChangeType change_type
) const;
63 const std::string
& id() const { return extension_sync_data_
.id(); }
65 bool uninstalled() const { return extension_sync_data_
.uninstalled(); }
67 // These ordinals aren't necessarily valid. Some applications don't have
68 // valid ordinals because they don't appear on the new tab page.
69 const syncer::StringOrdinal
& app_launch_ordinal() const {
70 return app_launch_ordinal_
;
72 const syncer::StringOrdinal
& page_ordinal() const { return page_ordinal_
; }
74 const ExtensionSyncData
& extension_sync_data() const {
75 return extension_sync_data_
;
78 extensions::LaunchType
launch_type() const {
82 const std::string
& bookmark_app_url() const {
83 return bookmark_app_url_
;
86 const std::string
& bookmark_app_description() const {
87 return bookmark_app_description_
;
90 const std::string
& bookmark_app_icon_color() const {
91 return bookmark_app_icon_color_
;
94 const std::vector
<LinkedAppIconInfo
>& linked_icons() const {
99 // Convert an AppSyncData back out to a sync structure.
100 void PopulateAppSpecifics(sync_pb::AppSpecifics
* specifics
) const;
102 // Populate this class from sync inputs. Return true if the input
104 bool PopulateFromAppSpecifics(const sync_pb::AppSpecifics
& specifics
);
105 bool PopulateFromSyncData(const syncer::SyncData
& sync_data
);
107 ExtensionSyncData extension_sync_data_
;
108 syncer::StringOrdinal app_launch_ordinal_
;
109 syncer::StringOrdinal page_ordinal_
;
110 extensions::LaunchType launch_type_
;
111 std::string bookmark_app_url_
;
112 std::string bookmark_app_description_
;
113 std::string bookmark_app_icon_color_
;
114 std::vector
<LinkedAppIconInfo
> linked_icons_
;
117 } // namespace extensions
119 #endif // CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_