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

Unified 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 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
« 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