OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/webui/sync_internals_message_handler.h" | 5 #include "chrome/browser/ui/webui/sync_internals_message_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 void SyncInternalsMessageHandler::HandleRequestListOfTypes( | 137 void SyncInternalsMessageHandler::HandleRequestListOfTypes( |
138 const base::ListValue* args) { | 138 const base::ListValue* args) { |
139 DCHECK(args->empty()); | 139 DCHECK(args->empty()); |
140 base::DictionaryValue event_details; | 140 base::DictionaryValue event_details; |
141 std::unique_ptr<base::ListValue> type_list(new base::ListValue()); | 141 std::unique_ptr<base::ListValue> type_list(new base::ListValue()); |
142 ModelTypeSet protocol_types = syncer::ProtocolTypes(); | 142 ModelTypeSet protocol_types = syncer::ProtocolTypes(); |
143 for (ModelTypeSet::Iterator it = protocol_types.First(); | 143 for (ModelTypeSet::Iterator it = protocol_types.First(); |
144 it.Good(); it.Inc()) { | 144 it.Good(); it.Inc()) { |
145 type_list->AppendString(ModelTypeToString(it.Get())); | 145 type_list->AppendString(ModelTypeToString(it.Get())); |
146 } | 146 } |
147 event_details.Set(syncer::sync_ui_util::kTypes, type_list.release()); | 147 event_details.Set(syncer::sync_ui_util::kTypes, std::move(type_list)); |
148 web_ui()->CallJavascriptFunctionUnsafe( | 148 web_ui()->CallJavascriptFunctionUnsafe( |
149 syncer::sync_ui_util::kDispatchEvent, | 149 syncer::sync_ui_util::kDispatchEvent, |
150 base::Value(syncer::sync_ui_util::kOnReceivedListOfTypes), event_details); | 150 base::Value(syncer::sync_ui_util::kOnReceivedListOfTypes), event_details); |
151 } | 151 } |
152 | 152 |
153 void SyncInternalsMessageHandler::HandleGetAllNodes( | 153 void SyncInternalsMessageHandler::HandleGetAllNodes( |
154 const base::ListValue* args) { | 154 const base::ListValue* args) { |
155 DCHECK_EQ(1U, args->GetSize()); | 155 DCHECK_EQ(1U, args->GetSize()); |
156 int request_id = 0; | 156 int request_id = 0; |
157 bool success = ExtractIntegerValue(args, &request_id); | 157 bool success = ExtractIntegerValue(args, &request_id); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 EmitCounterUpdate(type, syncer::sync_ui_util::kStatus, counters.ToValue()); | 204 EmitCounterUpdate(type, syncer::sync_ui_util::kStatus, counters.ToValue()); |
205 } | 205 } |
206 | 206 |
207 void SyncInternalsMessageHandler::EmitCounterUpdate( | 207 void SyncInternalsMessageHandler::EmitCounterUpdate( |
208 syncer::ModelType type, | 208 syncer::ModelType type, |
209 const std::string& counter_type, | 209 const std::string& counter_type, |
210 std::unique_ptr<base::DictionaryValue> value) { | 210 std::unique_ptr<base::DictionaryValue> value) { |
211 std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue()); | 211 std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue()); |
212 details->SetString(syncer::sync_ui_util::kModelType, ModelTypeToString(type)); | 212 details->SetString(syncer::sync_ui_util::kModelType, ModelTypeToString(type)); |
213 details->SetString(syncer::sync_ui_util::kCounterType, counter_type); | 213 details->SetString(syncer::sync_ui_util::kCounterType, counter_type); |
214 details->Set(syncer::sync_ui_util::kCounters, value.release()); | 214 details->Set(syncer::sync_ui_util::kCounters, std::move(value)); |
215 web_ui()->CallJavascriptFunctionUnsafe( | 215 web_ui()->CallJavascriptFunctionUnsafe( |
216 syncer::sync_ui_util::kDispatchEvent, | 216 syncer::sync_ui_util::kDispatchEvent, |
217 base::Value(syncer::sync_ui_util::kOnCountersUpdated), *details); | 217 base::Value(syncer::sync_ui_util::kOnCountersUpdated), *details); |
218 } | 218 } |
219 | 219 |
220 void SyncInternalsMessageHandler::HandleJsEvent( | 220 void SyncInternalsMessageHandler::HandleJsEvent( |
221 const std::string& name, | 221 const std::string& name, |
222 const JsEventDetails& details) { | 222 const JsEventDetails& details) { |
223 DVLOG(1) << "Handling event: " << name | 223 DVLOG(1) << "Handling event: " << name |
224 << " with details " << details.ToString(); | 224 << " with details " << details.ToString(); |
(...skipping 12 matching lines...) Expand all Loading... |
237 base::Value(syncer::sync_ui_util::kOnAboutInfoUpdated), *value); | 237 base::Value(syncer::sync_ui_util::kOnAboutInfoUpdated), *value); |
238 } | 238 } |
239 | 239 |
240 // Gets the ProfileSyncService of the underlying original profile. | 240 // Gets the ProfileSyncService of the underlying original profile. |
241 // May return NULL (e.g., if sync is disabled on the command line). | 241 // May return NULL (e.g., if sync is disabled on the command line). |
242 ProfileSyncService* SyncInternalsMessageHandler::GetProfileSyncService() { | 242 ProfileSyncService* SyncInternalsMessageHandler::GetProfileSyncService() { |
243 Profile* profile = Profile::FromWebUI(web_ui()); | 243 Profile* profile = Profile::FromWebUI(web_ui()); |
244 return ProfileSyncServiceFactory::GetForProfile( | 244 return ProfileSyncServiceFactory::GetForProfile( |
245 profile->GetOriginalProfile()); | 245 profile->GetOriginalProfile()); |
246 } | 246 } |
OLD | NEW |