Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_hand ler.h" | 5 #include "ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_hand ler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "components/browser_sync/profile_sync_service.h" | 12 #include "components/browser_sync/profile_sync_service.h" |
| 12 #include "components/signin/core/browser/signin_manager.h" | 13 #include "components/signin/core/browser/signin_manager.h" |
| 13 #include "components/sync/base/weak_handle.h" | 14 #include "components/sync/base/weak_handle.h" |
| 14 #include "components/sync/driver/about_sync_util.h" | 15 #include "components/sync/driver/about_sync_util.h" |
| 15 #include "components/sync/driver/sync_service.h" | 16 #include "components/sync/driver/sync_service.h" |
| 16 #include "components/sync/engine/cycle/commit_counters.h" | 17 #include "components/sync/engine/cycle/commit_counters.h" |
| 17 #include "components/sync/engine/cycle/status_counters.h" | 18 #include "components/sync/engine/cycle/status_counters.h" |
| 18 #include "components/sync/engine/cycle/update_counters.h" | 19 #include "components/sync/engine/cycle/update_counters.h" |
| 19 #include "components/sync/engine/events/protocol_event.h" | 20 #include "components/sync/engine/events/protocol_event.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 } | 119 } |
| 119 | 120 |
| 120 void SyncInternalsMessageHandler::HandleRequestListOfTypes( | 121 void SyncInternalsMessageHandler::HandleRequestListOfTypes( |
| 121 const base::ListValue* args) { | 122 const base::ListValue* args) { |
| 122 DCHECK(args->empty()); | 123 DCHECK(args->empty()); |
| 123 base::DictionaryValue event_details; | 124 base::DictionaryValue event_details; |
| 124 std::unique_ptr<base::ListValue> type_list(new base::ListValue()); | 125 std::unique_ptr<base::ListValue> type_list(new base::ListValue()); |
| 125 ModelTypeSet protocol_types = syncer::ProtocolTypes(); | 126 ModelTypeSet protocol_types = syncer::ProtocolTypes(); |
| 126 for (ModelTypeSet::Iterator it = protocol_types.First(); it.Good(); | 127 for (ModelTypeSet::Iterator it = protocol_types.First(); it.Good(); |
| 127 it.Inc()) { | 128 it.Inc()) { |
| 128 type_list->Append(new base::Value(ModelTypeToString(it.Get()))); | 129 type_list->Append( |
| 130 base::MakeUnique<base::Value>(ModelTypeToString(it.Get()))); | |
|
jdoerrie
2017/04/12 12:37:46
Consider using AppendString and removing the added
vabr (Chromium)
2017/04/12 12:55:04
Done.
| |
| 129 } | 131 } |
| 130 event_details.Set(syncer::sync_ui_util::kTypes, type_list.release()); | 132 event_details.Set(syncer::sync_ui_util::kTypes, type_list.release()); |
| 131 web_ui()->CallJavascriptFunction( | 133 web_ui()->CallJavascriptFunction( |
| 132 syncer::sync_ui_util::kDispatchEvent, | 134 syncer::sync_ui_util::kDispatchEvent, |
| 133 base::Value(syncer::sync_ui_util::kOnReceivedListOfTypes), event_details); | 135 base::Value(syncer::sync_ui_util::kOnReceivedListOfTypes), event_details); |
| 134 } | 136 } |
| 135 | 137 |
| 136 void SyncInternalsMessageHandler::HandleGetAllNodes( | 138 void SyncInternalsMessageHandler::HandleGetAllNodes( |
| 137 const base::ListValue* args) { | 139 const base::ListValue* args) { |
| 138 DCHECK_EQ(1U, args->GetSize()); | 140 DCHECK_EQ(1U, args->GetSize()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 base::Value(syncer::sync_ui_util::kOnAboutInfoUpdated), *value); | 224 base::Value(syncer::sync_ui_util::kOnAboutInfoUpdated), *value); |
| 223 } | 225 } |
| 224 | 226 |
| 225 // Gets the SyncService of the underlying original profile. May return null. | 227 // Gets the SyncService of the underlying original profile. May return null. |
| 226 syncer::SyncService* SyncInternalsMessageHandler::GetSyncService() { | 228 syncer::SyncService* SyncInternalsMessageHandler::GetSyncService() { |
| 227 ios::ChromeBrowserState* browser_state = | 229 ios::ChromeBrowserState* browser_state = |
| 228 ios::ChromeBrowserState::FromWebUIIOS(web_ui()); | 230 ios::ChromeBrowserState::FromWebUIIOS(web_ui()); |
| 229 return IOSChromeProfileSyncServiceFactory::GetForBrowserState( | 231 return IOSChromeProfileSyncServiceFactory::GetForBrowserState( |
| 230 browser_state->GetOriginalChromeBrowserState()); | 232 browser_state->GetOriginalChromeBrowserState()); |
| 231 } | 233 } |
| OLD | NEW |