Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3338)

Unified Diff: chrome/browser/password_manager/sync_metrics.cc

Issue 355143006: [Password Manager] Add UMA stats to track interaction with synced accounts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Typo Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..43520536e3beba225f80f37151a74a8b22b1e95b
--- /dev/null
+++ b/chrome/browser/password_manager/sync_metrics.cc
@@ -0,0 +1,41 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/password_manager/sync_metrics.h"
+
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "components/signin/core/browser/signin_manager.h"
+#include "google_apis/gaia/gaia_auth_util.h"
+#include "google_apis/gaia/gaia_urls.h"
+
+namespace password_manager_sync_metrics {
+
+std::string GetPasswordSyncUsername(Profile* profile) {
+ ProfileSyncService* sync_service =
+ ProfileSyncServiceFactory::GetForProfile(profile);
+ if (!sync_service ||
+ !sync_service->HasSyncSetupCompleted() ||
+ !sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS))
+ return "";
+
+ SigninManagerBase* signin_manager =
+ SigninManagerFactory::GetForProfile(profile);
+ if (!signin_manager)
+ return "";
+
+ return signin_manager->GetAuthenticatedUsername();
+}
+
+bool IsPasswordSyncAccountCredential(Profile* profile,
+ const std::string& username,
+ const std::string& origin) {
+ if (origin != GaiaUrls::GetInstance()->gaia_url().GetOrigin().spec())
+ return false;
+
+ return gaia::AreEmailsSame(username, GetPasswordSyncUsername(profile));
+}
+
+} // namespace password_manager_sync_metrics
« no previous file with comments | « chrome/browser/password_manager/sync_metrics.h ('k') | chrome/browser/password_manager/test_password_store_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698