Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / api / storage / setting_sync_data.h
blob181e3e70a5e291fe34efa41dedd487ee4697ae77
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_API_STORAGE_SETTING_SYNC_DATA_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h"
13 #include "base/values.h"
14 #include "sync/api/sync_change.h"
16 namespace syncer {
17 class SyncData;
20 namespace sync_pb {
21 class ExtensionSettingSpecifics;
24 namespace extensions {
26 // Container for data interpreted from sync data/changes for an extension or
27 // app setting. Safe and efficient to copy.
28 class SettingSyncData {
29 public:
30 // Creates from a sync change.
31 explicit SettingSyncData(const syncer::SyncChange& sync_change);
33 // Creates from sync data. |change_type| will be ACTION_INVALID.
34 explicit SettingSyncData(const syncer::SyncData& sync_data);
36 // Creates explicitly.
37 SettingSyncData(
38 syncer::SyncChange::SyncChangeType change_type,
39 const std::string& extension_id,
40 const std::string& key,
41 scoped_ptr<base::Value> value);
43 ~SettingSyncData();
45 // May return ACTION_INVALID if this object represents sync data that isn't
46 // associated with a sync operation.
47 syncer::SyncChange::SyncChangeType change_type() const {
48 return change_type_;
50 const std::string& extension_id() const { return extension_id_; }
51 const std::string& key() const { return key_; }
52 // value() cannot be called if PassValue() has been called.
53 const base::Value& value() const { return *value_; }
55 // Releases ownership of the value to the caller. Neither value() nor
56 // PassValue() can be after this.
57 scoped_ptr<base::Value> PassValue();
59 private:
60 // Populates the extension ID, key, and value from |sync_data|. This will be
61 // either an extension or app settings data type.
62 void ExtractSyncData(const syncer::SyncData& sync_data);
64 syncer::SyncChange::SyncChangeType change_type_;
65 std::string extension_id_;
66 std::string key_;
67 scoped_ptr<base::Value> value_;
69 DISALLOW_COPY_AND_ASSIGN(SettingSyncData);
72 typedef ScopedVector<SettingSyncData> SettingSyncDataList;
74 } // namespace extensions
76 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_