Index: chrome/browser/metrics/chrome_metrics_service_client.cc |
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc |
index 7d0e51a86d3d827a99ae55809847694fb3b9a475..81d1521ae2f4fd32a75a2ce12e80564cd8e4db02 100644 |
--- a/chrome/browser/metrics/chrome_metrics_service_client.cc |
+++ b/chrome/browser/metrics/chrome_metrics_service_client.cc |
@@ -41,6 +41,7 @@ |
#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/safe_browsing/certificate_reporting_metrics_provider.h" |
#include "chrome/browser/sync/chrome_sync_client.h" |
+#include "chrome/browser/sync/profile_sync_service_factory.h" |
#include "chrome/browser/ui/browser_otr_state.h" |
#include "chrome/common/channel_info.h" |
#include "chrome/common/chrome_paths.h" |
@@ -50,6 +51,7 @@ |
#include "chrome/common/features.h" |
#include "chrome/common/pref_names.h" |
#include "chrome/installer/util/util_constants.h" |
+#include "components/browser_sync/profile_sync_service.h" |
#include "components/browser_watcher/stability_debugging.h" |
#include "components/history/core/browser/history_service.h" |
#include "components/metrics/call_stack_profile_metrics_provider.h" |
@@ -877,15 +879,19 @@ void ChromeMetricsServiceClient::RegisterForNotifications() { |
content::NotificationService::AllBrowserContextsAndSources()); |
for (Profile* profile : |
g_browser_process->profile_manager()->GetLoadedProfiles()) { |
- RegisterForHistoryDeletions(profile); |
+ RegisterForProfileEvents(profile); |
} |
} |
-void ChromeMetricsServiceClient::RegisterForHistoryDeletions(Profile* profile) { |
+void ChromeMetricsServiceClient::RegisterForProfileEvents(Profile* profile) { |
history::HistoryService* history_service = |
HistoryServiceFactory::GetForProfile(profile, |
ServiceAccessType::IMPLICIT_ACCESS); |
ObserveServiceForDeletions(history_service); |
+ browser_sync::ProfileSyncService* sync = |
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
+ if (sync) |
+ ObserveServiceForSyncDisables(static_cast<syncer::SyncService*>(sync)); |
} |
void ChromeMetricsServiceClient::Observe( |
@@ -907,7 +913,7 @@ void ChromeMetricsServiceClient::Observe( |
break; |
case chrome::NOTIFICATION_PROFILE_ADDED: |
- RegisterForHistoryDeletions(content::Source<Profile>(source).ptr()); |
+ RegisterForProfileEvents(content::Source<Profile>(source).ptr()); |
break; |
default: |
@@ -927,3 +933,15 @@ void ChromeMetricsServiceClient::OnHistoryDeleted() { |
if (ukm_service_) |
ukm_service_->Purge(); |
} |
+ |
+void ChromeMetricsServiceClient::OnSyncPrefsChanged(bool must_purge) { |
+ if (ukm_service_) { |
Alexei Svitkine (slow)
2017/02/04 00:52:23
Nit: Early return instead.
Steven Holte
2017/02/06 21:57:54
Done.
|
+ if (must_purge) { |
+ ukm_service_->Purge(); |
+ ukm_service_->ResetClientId(); |
+ } |
+ // Signal service manager to enable/disable UKM based on new state. |
+ if (update_running_services_) |
+ update_running_services_.Run(); |
+ } |
+} |