Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: chrome/browser/extensions/extension_settings_sync_util.cc

Issue 7977018: Enable sync for the settings from the Extension Settings API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix race condition in ExtensionSettingsUIWrapper::Core Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 #include "chrome/browser/extensions/extension_settings_sync_util.h"
6
7 #include "base/values.h"
8 #include "base/json/json_writer.h"
9 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h"
10
11 namespace extension_settings_sync_util {
12
13 SyncData CreateData(
14 const std::string& extension_id,
15 const std::string& key,
16 const Value& value) {
17 sync_pb::EntitySpecifics specifics;
18 sync_pb::ExtensionSettingSpecifics* setting_specifics =
19 specifics.MutableExtension(sync_pb::extension_setting);
20 setting_specifics->set_extension_id(extension_id);
21 setting_specifics->set_key(key);
22 std::string value_as_json;
23 base::JSONWriter::Write(&value, false, &value_as_json);
24 setting_specifics->set_value(value_as_json);
25 return SyncData::CreateLocalData(extension_id + "/" + key, key, specifics);
26 }
27
28 SyncChange CreateAdd(
29 const std::string& extension_id,
30 const std::string& key,
31 const Value& value) {
32 return SyncChange(
33 SyncChange::ACTION_ADD, CreateData(extension_id, key, value));
34 }
35
36 SyncChange CreateUpdate(
37 const std::string& extension_id,
38 const std::string& key,
39 const Value& value) {
40 return SyncChange(
41 SyncChange::ACTION_UPDATE, CreateData(extension_id, key, value));
42 }
43
44 SyncChange CreateDelete(
45 const std::string& extension_id, const std::string& key) {
46 DictionaryValue no_value;
47 return SyncChange(
48 SyncChange::ACTION_DELETE, CreateData(extension_id, key, no_value));
49 }
50
51 } // namespace extension_settings_sync_util
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_settings_sync_util.h ('k') | chrome/browser/extensions/extension_settings_ui_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698