Index: chrome/browser/password_manager/sync_metrics.cc |
diff --git a/chrome/browser/password_manager/sync_metrics.cc b/chrome/browser/password_manager/sync_metrics.cc |
index 4eddf427ccd22db327b2fa421aaee66bd509056d..304bb6d92954ef2d4e4b11df73cdf10adb9550b4 100644 |
--- a/chrome/browser/password_manager/sync_metrics.cc |
+++ b/chrome/browser/password_manager/sync_metrics.cc |
@@ -14,10 +14,19 @@ |
namespace password_manager_sync_metrics { |
std::string GetSyncUsername(Profile* profile) { |
+ // If sync is set up, return early if we aren't syncing passwords. |
+ if (ProfileSyncServiceFactory::HasProfileSyncService(profile)) { |
+ ProfileSyncService* sync_service = |
+ ProfileSyncServiceFactory::GetForProfile(profile); |
+ if (!sync_service->GetPreferredDataTypes().Has(syncer::PASSWORDS)) |
+ return std::string(); |
+ } |
+ |
SigninManagerBase* signin_manager = |
SigninManagerFactory::GetForProfile(profile); |
+ |
if (!signin_manager) |
- return ""; |
+ return std::string(); |
return signin_manager->GetAuthenticatedUsername(); |
} |