Chromium Code Reviews| 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/password_manager/sync_metrics.h" | 5 #include "chrome/browser/password_manager/sync_metrics.h" |
| 6 | 6 |
| 7 #include "chrome/browser/signin/signin_manager_factory.h" | 7 #include "chrome/browser/signin/signin_manager_factory.h" |
| 8 #include "chrome/browser/sync/profile_sync_service.h" | 8 #include "chrome/browser/sync/profile_sync_service.h" |
| 9 #include "chrome/browser/sync/profile_sync_service_factory.h" | 9 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 10 #include "components/signin/core/browser/signin_manager.h" | 10 #include "components/signin/core/browser/signin_manager.h" |
| 11 #include "google_apis/gaia/gaia_auth_util.h" | 11 #include "google_apis/gaia/gaia_auth_util.h" |
| 12 #include "google_apis/gaia/gaia_urls.h" | 12 #include "google_apis/gaia/gaia_urls.h" |
| 13 | 13 |
| 14 namespace password_manager_sync_metrics { | 14 namespace password_manager_sync_metrics { |
| 15 | 15 |
| 16 std::string GetSyncUsername(Profile* profile) { | 16 std::string GetSyncUsername(Profile* profile) { |
| 17 // If sync is setup, return early if we aren't syncing passwords. | |
|
Ilya Sherman
2014/08/12 02:17:33
nit: "setup" -> "set up"
Garrett Casto
2014/08/13 20:34:41
Done.
| |
| 18 if (ProfileSyncServiceFactory::HasProfileSyncService(profile)) { | |
| 19 ProfileSyncService* sync_service = | |
| 20 ProfileSyncServiceFactory::GetForProfile(profile); | |
| 21 if (!sync_service || | |
|
Ilya Sherman
2014/08/12 02:17:33
Why might the sync_service be null, if HasProfileS
Garrett Casto
2014/08/13 20:34:40
That's true. I just reverted the previous change t
| |
| 22 !sync_service->HasSyncSetupCompleted() || | |
|
Ilya Sherman
2014/08/12 02:17:33
Are we not syncing the sync password if sync setup
Garrett Casto
2014/08/13 20:34:40
The issue is that we can't tell if we are syncing
Ilya Sherman
2014/08/13 20:48:14
I guess it just seems like it would be better to b
Garrett Casto
2014/08/13 23:12:54
From a privacy standpoint I don't think that it re
Ilya Sherman
2014/08/14 07:38:14
Joel, ^^^
jww
2014/08/14 21:50:20
Whoops, sorry I missed it. I agree with Garrett. I
| |
| 23 !sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) | |
| 24 return ""; | |
|
Ilya Sherman
2014/08/12 02:17:33
nit: Prefer std::string() to "".
Garrett Casto
2014/08/13 20:34:41
Done.
| |
| 25 } | |
| 26 | |
| 17 SigninManagerBase* signin_manager = | 27 SigninManagerBase* signin_manager = |
| 18 SigninManagerFactory::GetForProfile(profile); | 28 SigninManagerFactory::GetForProfile(profile); |
| 29 | |
| 19 if (!signin_manager) | 30 if (!signin_manager) |
| 20 return ""; | 31 return ""; |
| 21 | 32 |
| 22 return signin_manager->GetAuthenticatedUsername(); | 33 return signin_manager->GetAuthenticatedUsername(); |
| 23 } | 34 } |
| 24 | 35 |
| 25 bool IsSyncAccountCredential(Profile* profile, | 36 bool IsSyncAccountCredential(Profile* profile, |
| 26 const std::string& username, | 37 const std::string& username, |
| 27 const std::string& origin) { | 38 const std::string& origin) { |
| 28 if (origin != GaiaUrls::GetInstance()->gaia_url().GetOrigin().spec()) | 39 if (origin != GaiaUrls::GetInstance()->gaia_url().GetOrigin().spec()) |
| 29 return false; | 40 return false; |
| 30 | 41 |
| 31 return gaia::AreEmailsSame(username, GetSyncUsername(profile)); | 42 return gaia::AreEmailsSame(username, GetSyncUsername(profile)); |
| 32 } | 43 } |
| 33 | 44 |
| 34 } // namespace password_manager_sync_metrics | 45 } // namespace password_manager_sync_metrics |
| OLD | NEW |