| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 js_controller_ = service->GetJsController(); | 88 js_controller_ = service->GetJsController(); |
| 89 js_controller_->AddJsEventHandler(this); | 89 js_controller_->AddJsEventHandler(this); |
| 90 is_registered_ = true; | 90 is_registered_ = true; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 void SyncInternalsMessageHandler::HandleRegisterForPerTypeCounters( | 94 void SyncInternalsMessageHandler::HandleRegisterForPerTypeCounters( |
| 95 const base::ListValue* args) { | 95 const base::ListValue* args) { |
| 96 DCHECK(args->empty()); | 96 DCHECK(args->empty()); |
| 97 | 97 |
| 98 ProfileSyncService* service = GetProfileSyncService(); | 98 if (ProfileSyncService* service = GetProfileSyncService()) { |
| 99 if (service && !is_registered_for_counters_) { | 99 if (!is_registered_for_counters_) { |
| 100 service->AddTypeDebugInfoObserver(this); | 100 service->AddTypeDebugInfoObserver(this); |
| 101 is_registered_for_counters_ = true; | 101 is_registered_for_counters_ = true; |
| 102 } else { | 102 } else { |
| 103 // Re-register to ensure counters get re-emitted. | 103 // Re-register to ensure counters get re-emitted. |
| 104 service->RemoveTypeDebugInfoObserver(this); | 104 service->RemoveTypeDebugInfoObserver(this); |
| 105 service->AddTypeDebugInfoObserver(this); | 105 service->AddTypeDebugInfoObserver(this); |
| 106 } |
| 106 } | 107 } |
| 107 } | 108 } |
| 108 | 109 |
| 109 void SyncInternalsMessageHandler::HandleRequestUpdatedAboutInfo( | 110 void SyncInternalsMessageHandler::HandleRequestUpdatedAboutInfo( |
| 110 const base::ListValue* args) { | 111 const base::ListValue* args) { |
| 111 DCHECK(args->empty()); | 112 DCHECK(args->empty()); |
| 112 SendAboutInfo(); | 113 SendAboutInfo(); |
| 113 } | 114 } |
| 114 | 115 |
| 115 void SyncInternalsMessageHandler::HandleRequestListOfTypes( | 116 void SyncInternalsMessageHandler::HandleRequestListOfTypes( |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 *value); | 217 *value); |
| 217 } | 218 } |
| 218 | 219 |
| 219 // Gets the ProfileSyncService of the underlying original profile. | 220 // Gets the ProfileSyncService of the underlying original profile. |
| 220 // May return NULL (e.g., if sync is disabled on the command line). | 221 // May return NULL (e.g., if sync is disabled on the command line). |
| 221 ProfileSyncService* SyncInternalsMessageHandler::GetProfileSyncService() { | 222 ProfileSyncService* SyncInternalsMessageHandler::GetProfileSyncService() { |
| 222 Profile* profile = Profile::FromWebUI(web_ui()); | 223 Profile* profile = Profile::FromWebUI(web_ui()); |
| 223 ProfileSyncServiceFactory* factory = ProfileSyncServiceFactory::GetInstance(); | 224 ProfileSyncServiceFactory* factory = ProfileSyncServiceFactory::GetInstance(); |
| 224 return factory->GetForProfile(profile->GetOriginalProfile()); | 225 return factory->GetForProfile(profile->GetOriginalProfile()); |
| 225 } | 226 } |
| OLD | NEW |