| 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
|
|
|