Add a webstorePrivate API to show a permission prompt for delegated bundle installs
[chromium-blink-merge.git] / chrome / browser / extensions / app_sync_data.h
blob4d19060ac4e1e42fb54ff65775be549f49a009d3
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"
15 namespace syncer {
16 class SyncData;
19 namespace sync_pb {
20 class AppSpecifics;
23 namespace extensions {
25 class Extension;
26 class ExtensionSyncData;
28 // A class that encapsulates the synced properties of an Application.
29 class AppSyncData {
30 public:
31 struct LinkedAppIconInfo {
32 LinkedAppIconInfo();
33 ~LinkedAppIconInfo();
35 GURL url;
36 int size;
39 AppSyncData();
40 AppSyncData(const Extension& extension,
41 bool enabled,
42 int disable_reasons,
43 bool incognito_enabled,
44 bool remote_install,
45 ExtensionSyncData::OptionalBoolean all_urls_enabled,
46 const syncer::StringOrdinal& app_launch_ordinal,
47 const syncer::StringOrdinal& page_ordinal,
48 extensions::LaunchType launch_type);
49 ~AppSyncData();
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 {
79 return launch_type_;
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 {
95 return linked_icons_;
98 private:
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
103 // was valid.
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_