Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / extension_sync_data.h
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.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_
7
8 #include <string>
9
10 #include "base/version.h"
11 #include "sync/api/sync_change.h"
12 #include "url/gurl.h"
13
14 namespace syncer {
15 class SyncData;
16 }
17
18 namespace sync_pb {
19 class ExtensionSpecifics;
20 }
21
22 namespace extensions {
23
24 class Extension;
25
26 // A class that encapsulates the synced properties of an Extension.
27 class ExtensionSyncData {
28  public:
29   ExtensionSyncData();
30   explicit ExtensionSyncData(const syncer::SyncData& sync_data);
31   explicit ExtensionSyncData(const syncer::SyncChange& sync_change);
32   ExtensionSyncData(const Extension& extension,
33                     bool enabled,
34                     bool incognito_enabled);
35   ~ExtensionSyncData();
36
37   // Retrieve sync data from this class.
38   syncer::SyncData GetSyncData() const;
39   syncer::SyncChange GetSyncChange(
40       syncer::SyncChange::SyncChangeType change_type) const;
41
42   // Convert an ExtensionSyncData back out to a sync structure.
43   void PopulateExtensionSpecifics(sync_pb::ExtensionSpecifics* specifics) const;
44
45   // Populate this class from sync inputs.
46   void PopulateFromExtensionSpecifics(
47       const sync_pb::ExtensionSpecifics& specifics);
48
49   void set_uninstalled(bool uninstalled);
50
51   const std::string& id() const { return id_; }
52
53   // Version-independent properties (i.e., used even when the
54   // version of the currently-installed extension doesn't match
55   // |version|).
56   bool uninstalled() const { return uninstalled_; }
57   bool enabled() const { return enabled_; }
58   bool incognito_enabled() const { return incognito_enabled_; }
59
60   // Version-dependent properties (i.e., should be used only when the
61   // version of the currenty-installed extension matches |version|).
62   const Version& version() const { return version_; }
63   const GURL& update_url() const { return update_url_; }
64   // Used only for debugging.
65   const std::string& name() const { return name_; }
66
67  private:
68   // Populate this class from sync inputs.
69   void PopulateFromSyncData(const syncer::SyncData& sync_data);
70
71   std::string id_;
72   bool uninstalled_;
73   bool enabled_;
74   bool incognito_enabled_;
75   bool remote_install_;
76   Version version_;
77   GURL update_url_;
78   std::string name_;
79 };
80
81 }  // namespace extensions
82
83 #endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_