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

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

Issue 7775008: Enable sync for the settings from the Extension Settings API. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Reordering 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_helper.h"
6
7 #include "base/json/json_writer.h"
8 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h"
9
10 /* static */
11 SyncData ExtensionSettingsSyncHelper::CreateData(
12 const std::string& extension_id,
13 const std::string& key,
14 const Value& value) {
15 sync_pb::EntitySpecifics specifics;
16 sync_pb::ExtensionSettingSpecifics* setting_specifics =
17 specifics.MutableExtension(sync_pb::extension_setting);
18 setting_specifics->set_extension_id(extension_id);
19 setting_specifics->set_key(key);
20 std::string value_as_json;
21 base::JSONWriter::Write(&value, false, &value_as_json);
22 setting_specifics->set_value(value_as_json);
23 return SyncData::CreateLocalData(extension_id + "/" + key, key, specifics);
24 }
25
26 /* static */
27 SyncChange ExtensionSettingsSyncHelper::CreateAdd(
28 const std::string& extension_id,
29 const std::string& key,
30 const Value& value) {
31 return SyncChange(
32 SyncChange::ACTION_ADD, CreateData(extension_id, key, value));
33 }
34
35 /* static */
36 SyncChange ExtensionSettingsSyncHelper::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 /* static */
45 SyncChange ExtensionSettingsSyncHelper::CreateDelete(
46 const std::string& extension_id, const std::string& key) {
47 DictionaryValue no_value;
48 return SyncChange(
49 SyncChange::ACTION_DELETE, CreateData(extension_id, key, no_value));
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698