OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/password_manager/sync_metrics.h" |
| 6 |
| 7 #include "chrome/browser/signin/signin_manager_factory.h" |
| 8 #include "chrome/browser/sync/profile_sync_service.h" |
| 9 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 10 #include "components/signin/core/browser/signin_manager.h" |
| 11 #include "google_apis/gaia/gaia_auth_util.h" |
| 12 #include "google_apis/gaia/gaia_urls.h" |
| 13 |
| 14 namespace password_manager_sync_metrics { |
| 15 |
| 16 std::string GetPasswordSyncUsername(Profile* profile) { |
| 17 ProfileSyncService* sync_service = |
| 18 ProfileSyncServiceFactory::GetForProfile(profile); |
| 19 if (!sync_service || |
| 20 !sync_service->HasSyncSetupCompleted() || |
| 21 !sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) |
| 22 return ""; |
| 23 |
| 24 SigninManagerBase* signin_manager = |
| 25 SigninManagerFactory::GetForProfile(profile); |
| 26 if (!signin_manager) |
| 27 return ""; |
| 28 |
| 29 return signin_manager->GetAuthenticatedUsername(); |
| 30 } |
| 31 |
| 32 bool IsPasswordSyncAccountCredential(Profile* profile, |
| 33 const std::string& username, |
| 34 const std::string& origin) { |
| 35 if (origin != GaiaUrls::GetInstance()->gaia_url().GetOrigin().spec()) |
| 36 return false; |
| 37 |
| 38 return gaia::AreEmailsSame(username, GetPasswordSyncUsername(profile)); |
| 39 } |
| 40 |
| 41 } // namespace password_manager_sync_metrics |
OLD | NEW |