[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / signin / profile_identity_provider.cc
blob2a9299353b7b976c42d9211495f150aec0030eff
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.
5 #include "chrome/browser/signin/profile_identity_provider.h"
7 #include "components/signin/core/browser/profile_oauth2_token_service.h"
9 #if !defined(OS_ANDROID)
10 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
11 #endif
13 ProfileIdentityProvider::ProfileIdentityProvider(
14 SigninManagerBase* signin_manager,
15 ProfileOAuth2TokenService* token_service,
16 LoginUIService* login_ui_service)
17 : signin_manager_(signin_manager),
18 token_service_(token_service),
19 login_ui_service_(login_ui_service) {
20 signin_manager_->AddObserver(this);
23 ProfileIdentityProvider::~ProfileIdentityProvider() {
24 signin_manager_->RemoveObserver(this);
27 std::string ProfileIdentityProvider::GetActiveUsername() {
28 return signin_manager_->GetAuthenticatedUsername();
31 std::string ProfileIdentityProvider::GetActiveAccountId() {
32 return signin_manager_->GetAuthenticatedAccountId();
35 OAuth2TokenService* ProfileIdentityProvider::GetTokenService() {
36 return token_service_;
39 bool ProfileIdentityProvider::RequestLogin() {
40 #if defined(OS_ANDROID)
41 return false;
42 #else
43 login_ui_service_->ShowLoginPopup();
44 return true;
45 #endif
48 void ProfileIdentityProvider::GoogleSigninSucceeded(
49 const std::string& username,
50 const std::string& password) {
51 FireOnActiveAccountLogin();
54 void ProfileIdentityProvider::GoogleSignedOut(const std::string& username) {
55 FireOnActiveAccountLogout();