OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/settings/setting_sync_data.h" | 5 #include "chrome/browser/extensions/settings/setting_sync_data.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "chrome/browser/sync/api/sync_data.h" | 9 #include "chrome/browser/sync/api/sync_data.h" |
10 #include "sync/protocol/app_setting_specifics.pb.h" | 10 #include "sync/protocol/app_setting_specifics.pb.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 change_type, | 39 change_type, |
40 specifics.app_setting().extension_setting()); | 40 specifics.app_setting().extension_setting()); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 void SettingSyncData::InitFromExtensionSettingSpecifics( | 44 void SettingSyncData::InitFromExtensionSettingSpecifics( |
45 SyncChange::SyncChangeType change_type, | 45 SyncChange::SyncChangeType change_type, |
46 const sync_pb::ExtensionSettingSpecifics& specifics) { | 46 const sync_pb::ExtensionSettingSpecifics& specifics) { |
47 DCHECK(!internal_.get()); | 47 DCHECK(!internal_.get()); |
48 scoped_ptr<Value> value( | 48 scoped_ptr<Value> value( |
49 base::JSONReader().JsonToValue(specifics.value(), false, false)); | 49 base::JSONReader::Read(specifics.value())); |
50 if (!value.get()) { | 50 if (!value.get()) { |
51 LOG(WARNING) << "Specifics for " << specifics.extension_id() << "/" << | 51 LOG(WARNING) << "Specifics for " << specifics.extension_id() << "/" << |
52 specifics.key() << " had bad JSON for value: " << specifics.value(); | 52 specifics.key() << " had bad JSON for value: " << specifics.value(); |
53 value.reset(new DictionaryValue()); | 53 value.reset(new DictionaryValue()); |
54 } | 54 } |
55 internal_ = new Internal( | 55 internal_ = new Internal( |
56 change_type, | 56 change_type, |
57 specifics.extension_id(), | 57 specifics.extension_id(), |
58 specifics.key(), | 58 specifics.key(), |
59 value.Pass()); | 59 value.Pass()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 : change_type_(change_type), | 92 : change_type_(change_type), |
93 extension_id_(extension_id), | 93 extension_id_(extension_id), |
94 key_(key), | 94 key_(key), |
95 value_(value.Pass()) { | 95 value_(value.Pass()) { |
96 DCHECK(value_.get()); | 96 DCHECK(value_.get()); |
97 } | 97 } |
98 | 98 |
99 SettingSyncData::Internal::~Internal() {} | 99 SettingSyncData::Internal::~Internal() {} |
100 | 100 |
101 } // namespace extensions | 101 } // namespace extensions |
OLD | NEW |