| 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..5723620dd4ed0954ef6a50f86efe30846dfbf914
|
| --- /dev/null
|
| +++ b/chrome/browser/password_manager/sync_metrics.cc
|
| @@ -0,0 +1,36 @@
|
| +// 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"
|
| +
|
| +namespace password_manager_sync_metrics {
|
| +
|
| +void GetSyncUsernameAndState(Profile* profile,
|
| + std::string* username,
|
| + password_manager::SyncState* sync_state) {
|
| + *sync_state = password_manager::NOT_SYNCING;
|
| +
|
| + ProfileSyncService* sync_service =
|
| + ProfileSyncServiceFactory::GetForProfile(profile);
|
| + if (!sync_service || !sync_service->HasSyncSetupCompleted())
|
| + return;
|
| +
|
| + if (sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) {
|
| + *sync_state = password_manager::PASSWORD_SYNC_ENABLED;
|
| + } else {
|
| + *sync_state = password_manager::PASSWORD_SYNC_DISABLED;
|
| + }
|
| +
|
| + SigninManagerBase* signin_manager =
|
| + SigninManagerFactory::GetForProfile(profile);
|
| + if (signin_manager)
|
| + *username = signin_manager->GetAuthenticatedUsername();
|
| +}
|
| +
|
| +} // namespace password_manager_sync_metrics
|
|
|