| 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 |
| 12 namespace password_manager_sync_metrics { |
| 13 |
| 14 void GetSyncUsernameAndState(Profile* profile, |
| 15 std::string* username, |
| 16 password_manager::SyncState* sync_state) { |
| 17 *sync_state = password_manager::NOT_SYNCING; |
| 18 |
| 19 ProfileSyncService* sync_service = |
| 20 ProfileSyncServiceFactory::GetForProfile(profile); |
| 21 if (!sync_service || !sync_service->HasSyncSetupCompleted()) |
| 22 return; |
| 23 |
| 24 if (sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) { |
| 25 *sync_state = password_manager::PASSWORD_SYNC_ENABLED; |
| 26 } else { |
| 27 *sync_state = password_manager::PASSWORD_SYNC_DISABLED; |
| 28 } |
| 29 |
| 30 SigninManagerBase* signin_manager = |
| 31 SigninManagerFactory::GetForProfile(profile); |
| 32 if (signin_manager) |
| 33 *username = signin_manager->GetAuthenticatedUsername(); |
| 34 } |
| 35 |
| 36 } // namespace password_manager_sync_metrics |
| OLD | NEW |