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

Unified Diff: chrome/browser/extensions/extension_settings_sync_util.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: Sync to tip. Latest comments. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_settings_sync_util.cc
diff --git a/chrome/browser/extensions/extension_settings_sync_util.cc b/chrome/browser/extensions/extension_settings_sync_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d41a3e431dbc3b45d071826779d0766dacd97f0f
--- /dev/null
+++ b/chrome/browser/extensions/extension_settings_sync_util.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_settings_sync_util.h"
+
+#include "base/values.h"
+#include "base/json/json_writer.h"
+#include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h"
+
+namespace extension_settings_sync_util {
+
+SyncData CreateData(
+ const std::string& extension_id,
+ const std::string& key,
+ const Value& value) {
+ sync_pb::EntitySpecifics specifics;
+ sync_pb::ExtensionSettingSpecifics* setting_specifics =
+ specifics.MutableExtension(sync_pb::extension_setting);
+ setting_specifics->set_extension_id(extension_id);
+ setting_specifics->set_key(key);
+ std::string value_as_json;
+ base::JSONWriter::Write(&value, false, &value_as_json);
+ setting_specifics->set_value(value_as_json);
+ return SyncData::CreateLocalData(extension_id + "/" + key, key, specifics);
+}
+
+SyncChange CreateAdd(
+ const std::string& extension_id,
+ const std::string& key,
+ const Value& value) {
+ return SyncChange(
+ SyncChange::ACTION_ADD, CreateData(extension_id, key, value));
+}
+
+SyncChange CreateUpdate(
+ const std::string& extension_id,
+ const std::string& key,
+ const Value& value) {
+ return SyncChange(
+ SyncChange::ACTION_UPDATE, CreateData(extension_id, key, value));
+}
+
+SyncChange CreateDelete(
+ const std::string& extension_id, const std::string& key) {
+ DictionaryValue no_value;
+ return SyncChange(
+ SyncChange::ACTION_DELETE, CreateData(extension_id, key, no_value));
+}
+
+} // namespace extension_settings_sync_util

Powered by Google App Engine
This is Rietveld 408576698