OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" | 10 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" |
| 11 #include "chrome/browser/sync/protocol/sync.pb.h" |
11 | 12 |
12 namespace extensions { | 13 namespace extensions { |
13 | 14 |
14 SettingSyncData::SettingSyncData( | 15 SettingSyncData::SettingSyncData( |
15 const SyncChange& sync_change) { | 16 const SyncChange& sync_change) { |
16 Init(sync_change.change_type(), sync_change.sync_data()); | 17 Init(sync_change.change_type(), sync_change.sync_data()); |
17 } | 18 } |
18 | 19 |
19 SettingSyncData::SettingSyncData( | 20 SettingSyncData::SettingSyncData( |
20 const SyncData& sync_data) { | 21 const SyncData& sync_data) { |
21 Init(SyncChange::ACTION_INVALID, sync_data); | 22 Init(SyncChange::ACTION_INVALID, sync_data); |
22 } | 23 } |
23 | 24 |
24 void SettingSyncData::Init( | 25 void SettingSyncData::Init( |
25 SyncChange::SyncChangeType change_type, const SyncData& sync_data) { | 26 SyncChange::SyncChangeType change_type, const SyncData& sync_data) { |
26 DCHECK(!internal_.get()); | 27 DCHECK(!internal_.get()); |
27 sync_pb::ExtensionSettingSpecifics specifics = | 28 sync_pb::ExtensionSettingSpecifics specifics = |
28 sync_data.GetSpecifics().GetExtension(sync_pb::extension_setting); | 29 sync_data.GetSpecifics().extension_setting(); |
29 Value* value = | 30 Value* value = |
30 base::JSONReader().JsonToValue(specifics.value(), false, false); | 31 base::JSONReader().JsonToValue(specifics.value(), false, false); |
31 if (!value) { | 32 if (!value) { |
32 LOG(WARNING) << "Specifics for " << specifics.extension_id() << "/" << | 33 LOG(WARNING) << "Specifics for " << specifics.extension_id() << "/" << |
33 specifics.key() << " had bad JSON for value: " << specifics.value(); | 34 specifics.key() << " had bad JSON for value: " << specifics.value(); |
34 value = new DictionaryValue(); | 35 value = new DictionaryValue(); |
35 } | 36 } |
36 internal_ = new Internal( | 37 internal_ = new Internal( |
37 change_type, | 38 change_type, |
38 specifics.extension_id(), | 39 specifics.extension_id(), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 const std::string& key, | 74 const std::string& key, |
74 Value* value) | 75 Value* value) |
75 : change_type_(change_type), | 76 : change_type_(change_type), |
76 extension_id_(extension_id), | 77 extension_id_(extension_id), |
77 key_(key), | 78 key_(key), |
78 value_(value) {} | 79 value_(value) {} |
79 | 80 |
80 SettingSyncData::Internal::~Internal() {} | 81 SettingSyncData::Internal::~Internal() {} |
81 | 82 |
82 } // namespace extensions | 83 } // namespace extensions |
OLD | NEW |