| 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/values.h" | 10 #include "base/values.h" |
| 11 #include "components/browser_sync/profile_sync_service.h" | 11 #include "components/browser_sync/profile_sync_service.h" |
| 12 #include "components/signin/core/browser/signin_manager.h" | |
| 13 #include "components/sync/base/weak_handle.h" | 12 #include "components/sync/base/weak_handle.h" |
| 14 #include "components/sync/driver/about_sync_util.h" | 13 #include "components/sync/driver/about_sync_util.h" |
| 15 #include "components/sync/driver/sync_service.h" | 14 #include "components/sync/driver/sync_service.h" |
| 16 #include "components/sync/engine/cycle/commit_counters.h" | 15 #include "components/sync/engine/cycle/commit_counters.h" |
| 17 #include "components/sync/engine/cycle/status_counters.h" | 16 #include "components/sync/engine/cycle/status_counters.h" |
| 18 #include "components/sync/engine/cycle/update_counters.h" | 17 #include "components/sync/engine/cycle/update_counters.h" |
| 19 #include "components/sync/engine/events/protocol_event.h" | 18 #include "components/sync/engine/events/protocol_event.h" |
| 20 #include "components/sync/js/js_event_details.h" | 19 #include "components/sync/js/js_event_details.h" |
| 21 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 22 #include "ios/chrome/browser/signin/signin_manager_factory.h" | |
| 23 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" | 21 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" |
| 24 #include "ios/chrome/common/channel_info.h" | 22 #include "ios/chrome/common/channel_info.h" |
| 25 #include "ios/web/public/web_thread.h" | 23 #include "ios/web/public/web_thread.h" |
| 26 #include "ios/web/public/webui/web_ui_ios.h" | 24 #include "ios/web/public/webui/web_ui_ios.h" |
| 27 | 25 |
| 28 using syncer::JsEventDetails; | 26 using syncer::JsEventDetails; |
| 29 using syncer::ModelTypeSet; | 27 using syncer::ModelTypeSet; |
| 30 using syncer::WeakHandle; | 28 using syncer::WeakHandle; |
| 31 | 29 |
| 32 SyncInternalsMessageHandler::SyncInternalsMessageHandler() | 30 SyncInternalsMessageHandler::SyncInternalsMessageHandler() |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 200 |
| 203 void SyncInternalsMessageHandler::HandleJsEvent(const std::string& name, | 201 void SyncInternalsMessageHandler::HandleJsEvent(const std::string& name, |
| 204 const JsEventDetails& details) { | 202 const JsEventDetails& details) { |
| 205 DVLOG(1) << "Handling event: " << name << " with details " | 203 DVLOG(1) << "Handling event: " << name << " with details " |
| 206 << details.ToString(); | 204 << details.ToString(); |
| 207 web_ui()->CallJavascriptFunction(syncer::sync_ui_util::kDispatchEvent, | 205 web_ui()->CallJavascriptFunction(syncer::sync_ui_util::kDispatchEvent, |
| 208 base::Value(name), details.Get()); | 206 base::Value(name), details.Get()); |
| 209 } | 207 } |
| 210 | 208 |
| 211 void SyncInternalsMessageHandler::SendAboutInfo() { | 209 void SyncInternalsMessageHandler::SendAboutInfo() { |
| 212 ios::ChromeBrowserState* browser_state = | |
| 213 ios::ChromeBrowserState::FromWebUIIOS(web_ui()); | |
| 214 SigninManager* signin_manager = | |
| 215 ios::SigninManagerFactory::GetForBrowserState(browser_state); | |
| 216 syncer::SyncService* sync_service = GetSyncService(); | 210 syncer::SyncService* sync_service = GetSyncService(); |
| 217 std::unique_ptr<base::DictionaryValue> value = | 211 std::unique_ptr<base::DictionaryValue> value = |
| 218 syncer::sync_ui_util::ConstructAboutInformation( | 212 syncer::sync_ui_util::ConstructAboutInformation(sync_service, |
| 219 sync_service, signin_manager, GetChannel()); | 213 GetChannel()); |
| 220 web_ui()->CallJavascriptFunction( | 214 web_ui()->CallJavascriptFunction( |
| 221 syncer::sync_ui_util::kDispatchEvent, | 215 syncer::sync_ui_util::kDispatchEvent, |
| 222 base::Value(syncer::sync_ui_util::kOnAboutInfoUpdated), *value); | 216 base::Value(syncer::sync_ui_util::kOnAboutInfoUpdated), *value); |
| 223 } | 217 } |
| 224 | 218 |
| 225 // Gets the SyncService of the underlying original profile. May return null. | 219 // Gets the SyncService of the underlying original profile. May return null. |
| 226 syncer::SyncService* SyncInternalsMessageHandler::GetSyncService() { | 220 syncer::SyncService* SyncInternalsMessageHandler::GetSyncService() { |
| 227 ios::ChromeBrowserState* browser_state = | 221 ios::ChromeBrowserState* browser_state = |
| 228 ios::ChromeBrowserState::FromWebUIIOS(web_ui()); | 222 ios::ChromeBrowserState::FromWebUIIOS(web_ui()); |
| 229 return IOSChromeProfileSyncServiceFactory::GetForBrowserState( | 223 return IOSChromeProfileSyncServiceFactory::GetForBrowserState( |
| 230 browser_state->GetOriginalChromeBrowserState()); | 224 browser_state->GetOriginalChromeBrowserState()); |
| 231 } | 225 } |
| OLD | NEW |