Add a webstorePrivate API to show a permission prompt for delegated bundle installs
[chromium-blink-merge.git] / chrome / browser / extensions / extension_sync_data.h
blob03ce9bd7ab1f97b776d8feb394b0b99957e66f76
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_EXTENSION_SYNC_DATA_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/version.h"
12 #include "sync/api/sync_change.h"
13 #include "url/gurl.h"
15 namespace syncer {
16 class SyncData;
19 namespace sync_pb {
20 class ExtensionSpecifics;
23 namespace extensions {
25 class Extension;
27 // A class that encapsulates the synced properties of an Extension.
28 class ExtensionSyncData {
29 public:
30 enum OptionalBoolean {
31 BOOLEAN_UNSET,
32 BOOLEAN_TRUE,
33 BOOLEAN_FALSE
36 ExtensionSyncData();
37 ExtensionSyncData(const Extension& extension,
38 bool enabled,
39 int disable_reasons,
40 bool incognito_enabled,
41 bool remote_install,
42 OptionalBoolean all_urls_enabled);
43 ~ExtensionSyncData();
45 // For constructing an ExtensionSyncData from received sync data.
46 // May return null if the sync data was invalid.
47 static scoped_ptr<ExtensionSyncData> CreateFromSyncData(
48 const syncer::SyncData& sync_data);
49 static scoped_ptr<ExtensionSyncData> CreateFromSyncChange(
50 const syncer::SyncChange& sync_change);
52 // Retrieve sync data from this class.
53 syncer::SyncData GetSyncData() const;
54 syncer::SyncChange GetSyncChange(
55 syncer::SyncChange::SyncChangeType change_type) const;
57 // Convert an ExtensionSyncData back out to a sync structure.
58 void PopulateExtensionSpecifics(sync_pb::ExtensionSpecifics* specifics) const;
60 // Populate this class from sync inputs. Returns true if the input was valid.
61 bool PopulateFromExtensionSpecifics(
62 const sync_pb::ExtensionSpecifics& specifics);
64 void set_uninstalled(bool uninstalled);
66 const std::string& id() const { return id_; }
68 // Version-independent properties (i.e., used even when the
69 // version of the currently-installed extension doesn't match
70 // |version|).
71 bool uninstalled() const { return uninstalled_; }
72 bool enabled() const { return enabled_; }
73 bool supports_disable_reasons() const { return supports_disable_reasons_; }
74 int disable_reasons() const { return disable_reasons_; }
75 bool incognito_enabled() const { return incognito_enabled_; }
76 bool remote_install() const { return remote_install_; }
77 OptionalBoolean all_urls_enabled() const { return all_urls_enabled_; }
78 bool installed_by_custodian() const { return installed_by_custodian_; }
80 // Version-dependent properties (i.e., should be used only when the
81 // version of the currently-installed extension matches |version|).
82 const Version& version() const { return version_; }
83 const GURL& update_url() const { return update_url_; }
84 // Used only for debugging.
85 const std::string& name() const { return name_; }
87 private:
88 // Populate this class from sync inputs.
89 bool PopulateFromSyncData(const syncer::SyncData& sync_data);
91 std::string id_;
92 bool uninstalled_;
93 bool enabled_;
94 // |supports_disable_reasons_| is true if the optional |disable_reasons_| was
95 // set to some value in the extension_specifics.proto. If not,
96 // |disable_reasons_| is given a default value and |supports_disable_reasons_|
97 // is false.
98 bool supports_disable_reasons_;
99 int disable_reasons_;
100 bool incognito_enabled_;
101 bool remote_install_;
102 OptionalBoolean all_urls_enabled_;
103 bool installed_by_custodian_;
104 Version version_;
105 GURL update_url_;
106 std::string name_;
109 } // namespace extensions
111 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_