| Index: chrome/browser/extensions/extension_settings_sync_helper.cc
|
| diff --git a/chrome/browser/extensions/extension_settings_sync_helper.cc b/chrome/browser/extensions/extension_settings_sync_helper.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..66be4832d382a29b94a5c281402be0e88fb2ca1e
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/extension_settings_sync_helper.cc
|
| @@ -0,0 +1,50 @@
|
| +// 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_helper.h"
|
| +
|
| +#include "base/json/json_writer.h"
|
| +#include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h"
|
| +
|
| +/* static */
|
| +SyncData ExtensionSettingsSyncHelper::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);
|
| +}
|
| +
|
| +/* static */
|
| +SyncChange ExtensionSettingsSyncHelper::CreateAdd(
|
| + const std::string& extension_id,
|
| + const std::string& key,
|
| + const Value& value) {
|
| + return SyncChange(
|
| + SyncChange::ACTION_ADD, CreateData(extension_id, key, value));
|
| +}
|
| +
|
| +/* static */
|
| +SyncChange ExtensionSettingsSyncHelper::CreateUpdate(
|
| + const std::string& extension_id,
|
| + const std::string& key,
|
| + const Value& value) {
|
| + return SyncChange(
|
| + SyncChange::ACTION_UPDATE, CreateData(extension_id, key, value));
|
| +}
|
| +
|
| +/* static */
|
| +SyncChange ExtensionSettingsSyncHelper::CreateDelete(
|
| + const std::string& extension_id, const std::string& key) {
|
| + DictionaryValue no_value;
|
| + return SyncChange(
|
| + SyncChange::ACTION_DELETE, CreateData(extension_id, key, no_value));
|
| +}
|
|
|