Chromium Code Reviews| Index: chrome/browser/extensions/extension_setting_sync_data.cc |
| diff --git a/chrome/browser/extensions/extension_setting_sync_data.cc b/chrome/browser/extensions/extension_setting_sync_data.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..99e032fc1a06aa69fb1e1ae30ab4806a01b42977 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/extension_setting_sync_data.cc |
| @@ -0,0 +1,63 @@ |
| +// 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_setting_sync_data.h" |
| + |
| +#include "base/json/json_reader.h" |
| +#include "base/json/json_writer.h" |
| +#include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" |
| + |
| +ExtensionSettingSyncData::ExtensionSettingSyncData( |
| + const SyncChange& sync_change) { |
| + *this = ExtensionSettingSyncData(sync_change.sync_data()); |
|
akalin
2011/09/15 19:56:44
prefer having an Init() method and calling that in
not at google - send to devlin
2011/09/16 05:18:59
Done.
|
| + internal_->change_type_ = sync_change.change_type(); |
| +} |
| + |
| +ExtensionSettingSyncData::ExtensionSettingSyncData( |
| + const SyncData& sync_data) { |
| + sync_pb::ExtensionSettingSpecifics specifics = |
| + sync_data.GetSpecifics().GetExtension(sync_pb::extension_setting); |
| + *this = ExtensionSettingSyncData( |
| + SyncChange::ACTION_INVALID, |
| + specifics.extension_id(), |
| + specifics.key(), |
| + base::JSONReader().JsonToValue(specifics.value(), false, false)); |
| +} |
| + |
| +ExtensionSettingSyncData::ExtensionSettingSyncData( |
| + SyncChange::SyncChangeType change_type, |
| + const std::string& extension_id, |
| + const std::string& key, |
| + Value* value) |
| + : internal_(new Internal(change_type, extension_id, key, value)) {} |
| + |
| +ExtensionSettingSyncData::~ExtensionSettingSyncData() {} |
| + |
| +SyncChange::SyncChangeType ExtensionSettingSyncData::change_type() const { |
| + return internal_->change_type_; |
| +} |
| + |
| +const std::string& ExtensionSettingSyncData::extension_id() const { |
| + return internal_->extension_id_; |
| +} |
| + |
| +const std::string& ExtensionSettingSyncData::key() const { |
| + return internal_->key_; |
| +} |
| + |
| +const Value* ExtensionSettingSyncData::value() const { |
| + return internal_->value_.get(); |
| +} |
| + |
| +ExtensionSettingSyncData::Internal::Internal( |
| + SyncChange::SyncChangeType change_type, |
| + const std::string& extension_id, |
| + const std::string& key, |
| + Value* value) |
| + : change_type_(change_type), |
| + extension_id_(extension_id), |
| + key_(key), |
| + value_(value) {} |
| + |
| +ExtensionSettingSyncData::Internal::~Internal() {} |