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

Side by Side Diff: chrome/browser/password_manager/sync_metrics.cc

Issue 383083009: [Password Manager] Fix crash in reporting sync stats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 GetPasswordSyncUsername(Profile* profile) { 16 std::string GetSyncUsername(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 "";
Ilya Sherman 2014/07/15 01:09:11 Is this the code that you're saying causes Sync to
Garrett Casto 2014/07/15 05:39:03 ProfileSyncServiceFactory::GetForProfile() will cr
Ilya Sherman 2014/07/15 05:48:13 Can you use ProfileSyncServiceFactory::HasProfileS
Garrett Casto 2014/07/15 06:05:55 I could. It just wasn't clearly useful to me, as I
23
24 SigninManagerBase* signin_manager = 17 SigninManagerBase* signin_manager =
25 SigninManagerFactory::GetForProfile(profile); 18 SigninManagerFactory::GetForProfile(profile);
26 if (!signin_manager) 19 if (!signin_manager)
27 return ""; 20 return "";
28 21
29 return signin_manager->GetAuthenticatedUsername(); 22 return signin_manager->GetAuthenticatedUsername();
30 } 23 }
31 24
32 bool IsPasswordSyncAccountCredential(Profile* profile, 25 bool IsSyncAccountCredential(Profile* profile,
33 const std::string& username, 26 const std::string& username,
34 const std::string& origin) { 27 const std::string& origin) {
35 if (origin != GaiaUrls::GetInstance()->gaia_url().GetOrigin().spec()) 28 if (origin != GaiaUrls::GetInstance()->gaia_url().GetOrigin().spec())
36 return false; 29 return false;
37 30
38 return gaia::AreEmailsSame(username, GetPasswordSyncUsername(profile)); 31 return gaia::AreEmailsSame(username, GetSyncUsername(profile));
39 } 32 }
40 33
41 } // namespace password_manager_sync_metrics 34 } // namespace password_manager_sync_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698