| 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/metrics/chrome_metrics_service_client.h" | 5 #include "chrome/browser/metrics/chrome_metrics_service_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 wchar_t exe_file[MAX_PATH] = {}; | 274 wchar_t exe_file[MAX_PATH] = {}; |
| 275 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file))); | 275 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file))); |
| 276 | 276 |
| 277 base::string16 unused_special_build; | 277 base::string16 unused_special_build; |
| 278 install_static::GetExecutableVersionDetails( | 278 install_static::GetExecutableVersionDetails( |
| 279 exe_file, product_name, version_number, &unused_special_build, | 279 exe_file, product_name, version_number, &unused_special_build, |
| 280 channel_name); | 280 channel_name); |
| 281 } | 281 } |
| 282 #endif // OS_WIN | 282 #endif // OS_WIN |
| 283 | 283 |
| 284 ukm::UkmService* BindableGetUkmService() { | 284 ukm::UkmService* BindableGetUkmService( |
| 285 return g_browser_process->ukm_service(); | 285 base::WeakPtr<ChromeMetricsServiceClient> weak_ptr) { |
| 286 if (!weak_ptr) |
| 287 return nullptr; |
| 288 return weak_ptr->GetUkmService(); |
| 286 } | 289 } |
| 287 | 290 |
| 288 } // namespace | 291 } // namespace |
| 289 | 292 |
| 290 const char ChromeMetricsServiceClient::kBrowserMetricsName[] = "BrowserMetrics"; | 293 const char ChromeMetricsServiceClient::kBrowserMetricsName[] = "BrowserMetrics"; |
| 291 | 294 |
| 292 ChromeMetricsServiceClient::ChromeMetricsServiceClient( | 295 ChromeMetricsServiceClient::ChromeMetricsServiceClient( |
| 293 metrics::MetricsStateManager* state_manager) | 296 metrics::MetricsStateManager* state_manager) |
| 294 : metrics_state_manager_(state_manager), | 297 : metrics_state_manager_(state_manager), |
| 295 #if defined(OS_CHROMEOS) | 298 #if defined(OS_CHROMEOS) |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 content::NotificationService::AllBrowserContextsAndSources()); | 934 content::NotificationService::AllBrowserContextsAndSources()); |
| 932 for (Profile* profile : | 935 for (Profile* profile : |
| 933 g_browser_process->profile_manager()->GetLoadedProfiles()) { | 936 g_browser_process->profile_manager()->GetLoadedProfiles()) { |
| 934 RegisterForProfileEvents(profile); | 937 RegisterForProfileEvents(profile); |
| 935 } | 938 } |
| 936 } | 939 } |
| 937 | 940 |
| 938 void ChromeMetricsServiceClient::RegisterForProfileEvents(Profile* profile) { | 941 void ChromeMetricsServiceClient::RegisterForProfileEvents(Profile* profile) { |
| 939 // Register chrome://ukm handler | 942 // Register chrome://ukm handler |
| 940 content::URLDataSource::Add( | 943 content::URLDataSource::Add( |
| 941 profile, new ukm::debug::DebugPage(base::Bind(&BindableGetUkmService))); | 944 profile, new ukm::debug::DebugPage(base::Bind( |
| 945 &BindableGetUkmService, weak_ptr_factory_.GetWeakPtr()))); |
| 942 #if defined(OS_CHROMEOS) | 946 #if defined(OS_CHROMEOS) |
| 943 // Ignore the signin profile for sync disables / history deletion. | 947 // Ignore the signin profile for sync disables / history deletion. |
| 944 if (chromeos::ProfileHelper::IsSigninProfile(profile)) | 948 if (chromeos::ProfileHelper::IsSigninProfile(profile)) |
| 945 return; | 949 return; |
| 946 #endif | 950 #endif |
| 947 history::HistoryService* history_service = | 951 history::HistoryService* history_service = |
| 948 HistoryServiceFactory::GetForProfile(profile, | 952 HistoryServiceFactory::GetForProfile(profile, |
| 949 ServiceAccessType::IMPLICIT_ACCESS); | 953 ServiceAccessType::IMPLICIT_ACCESS); |
| 950 ObserveServiceForDeletions(history_service); | 954 ObserveServiceForDeletions(history_service); |
| 951 browser_sync::ProfileSyncService* sync = | 955 browser_sync::ProfileSyncService* sync = |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 ukm_service_->Purge(); | 1005 ukm_service_->Purge(); |
| 1002 ukm_service_->ResetClientId(); | 1006 ukm_service_->ResetClientId(); |
| 1003 } | 1007 } |
| 1004 // Signal service manager to enable/disable UKM based on new state. | 1008 // Signal service manager to enable/disable UKM based on new state. |
| 1005 UpdateRunningServices(); | 1009 UpdateRunningServices(); |
| 1006 } | 1010 } |
| 1007 | 1011 |
| 1008 bool ChromeMetricsServiceClient::IsHistorySyncEnabledOnAllProfiles() { | 1012 bool ChromeMetricsServiceClient::IsHistorySyncEnabledOnAllProfiles() { |
| 1009 return SyncDisableObserver::IsHistorySyncEnabledOnAllProfiles(); | 1013 return SyncDisableObserver::IsHistorySyncEnabledOnAllProfiles(); |
| 1010 } | 1014 } |
| OLD | NEW |