Commit bb012abf authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

[s13n] Convert arc_auth_service.cc to use IdentityManager

CL also partially needed to touch bits on signin_ui_util.cc|h
and people_handler.cc, both files properly listed on the BUG=
line below.

BUG=907486,898810,890796

Change-Id: Ic0d39cb14e100ae10375f66ca51fd526f3b2d64a
Reviewed-on: https://chromium-review.googlesource.com/c/1348674Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#610979}
parent 7d072473
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_tracker_service_factory.h" #include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_ui_util.h" #include "chrome/browser/signin/signin_ui_util.h"
#include "chrome/browser/ui/app_list/arc/arc_data_removal_dialog.h" #include "chrome/browser/ui/app_list/arc/arc_data_removal_dialog.h"
#include "chromeos/account_manager/account_manager_factory.h" #include "chromeos/account_manager/account_manager_factory.h"
...@@ -37,11 +37,11 @@ ...@@ -37,11 +37,11 @@
#include "components/arc/arc_util.h" #include "components/arc/arc_util.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/core/browser/account_tracker_service.h" #include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
namespace arc { namespace arc {
...@@ -436,10 +436,10 @@ void ArcAuthService::FetchPrimaryAccountInfo( ...@@ -436,10 +436,10 @@ void ArcAuthService::FetchPrimaryAccountInfo(
} }
} else { } else {
// Optionally retrieve auth code in silent mode. // Optionally retrieve auth code in silent mode.
const SigninManagerBase* const signin_manager = const auto* const identity_manager =
SigninManagerFactory::GetForProfile(profile_); IdentityManagerFactory::GetForProfile(profile_);
auth_code_fetcher = CreateArcBackgroundAuthCodeFetcher( auth_code_fetcher = CreateArcBackgroundAuthCodeFetcher(
signin_manager->GetAuthenticatedAccountId(), initial_signin); identity_manager->GetPrimaryAccountId(), initial_signin);
} }
// Add the request to |pending_token_requests_| first, before starting a token // Add the request to |pending_token_requests_| first, before starting a token
...@@ -554,10 +554,10 @@ void ArcAuthService::OnPrimaryAccountAuthCodeFetched( ...@@ -554,10 +554,10 @@ void ArcAuthService::OnPrimaryAccountAuthCodeFetched(
DeletePendingTokenRequest(fetcher); DeletePendingTokenRequest(fetcher);
if (success) { if (success) {
const SigninManagerBase* const signin_manager = const auto* const identity_manager =
SigninManagerFactory::GetForProfile(profile_); IdentityManagerFactory::GetForProfile(profile_);
const std::string& full_account_id = base::UTF16ToUTF8( const std::string& full_account_id = base::UTF16ToUTF8(
signin_ui_util::GetAuthenticatedUsername(signin_manager)); signin_ui_util::GetAuthenticatedUsername(identity_manager));
std::move(callback).Run( std::move(callback).Run(
mojom::ArcSignInStatus::SUCCESS, mojom::ArcSignInStatus::SUCCESS,
CreateAccountInfo(!IsArcOptInVerificationDisabled(), auth_code, CreateAccountInfo(!IsArcOptInVerificationDisabled(), auth_code,
......
...@@ -64,11 +64,12 @@ void CreateDiceTurnSyncOnHelper( ...@@ -64,11 +64,12 @@ void CreateDiceTurnSyncOnHelper(
namespace signin_ui_util { namespace signin_ui_util {
base::string16 GetAuthenticatedUsername(const SigninManagerBase* signin) { base::string16 GetAuthenticatedUsername(
const identity::IdentityManager* identity_manager) {
std::string user_display_name; std::string user_display_name;
if (signin->IsAuthenticated()) { if (identity_manager->HasPrimaryAccount()) {
user_display_name = signin->GetAuthenticatedAccountInfo().email; user_display_name = identity_manager->GetPrimaryAccountInfo().email;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (user_manager::UserManager::IsInitialized()) { if (user_manager::UserManager::IsInitialized()) {
......
...@@ -18,7 +18,10 @@ ...@@ -18,7 +18,10 @@
class Profile; class Profile;
class Browser; class Browser;
class SigninManagerBase;
namespace identity {
class IdentityManager;
}
// Utility functions to gather status information from the various signed in // Utility functions to gather status information from the various signed in
// services and construct messages suitable for showing in UI. // services and construct messages suitable for showing in UI.
...@@ -29,7 +32,8 @@ const int kUpgradeWelcomeTutorialShowMax = 1; ...@@ -29,7 +32,8 @@ const int kUpgradeWelcomeTutorialShowMax = 1;
// Returns the username of the authenticated user or an empty string if there is // Returns the username of the authenticated user or an empty string if there is
// no authenticated user. // no authenticated user.
base::string16 GetAuthenticatedUsername(const SigninManagerBase* signin); base::string16 GetAuthenticatedUsername(
const identity::IdentityManager* identity_manager);
// Initializes signin-related preferences. // Initializes signin-related preferences.
void InitializePrefsForProfile(Profile* profile); void InitializePrefsForProfile(Profile* profile);
......
...@@ -951,6 +951,10 @@ PeopleHandler::GetSyncStatusDictionary() { ...@@ -951,6 +951,10 @@ PeopleHandler::GetSyncStatusDictionary() {
SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_); SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_);
DCHECK(signin); DCHECK(signin);
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile_);
DCHECK(identity_manager);
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
// Signout is not allowed if the user has policy (crbug.com/172204). // Signout is not allowed if the user has policy (crbug.com/172204).
if (!signin_util::IsUserSignoutAllowedForProfile(profile_)) { if (!signin_util::IsUserSignoutAllowedForProfile(profile_)) {
...@@ -995,8 +999,9 @@ PeopleHandler::GetSyncStatusDictionary() { ...@@ -995,8 +999,9 @@ PeopleHandler::GetSyncStatusDictionary() {
"disabled", !service || disallowed_by_policy || "disabled", !service || disallowed_by_policy ||
!service->GetUserSettings()->IsSyncAllowedByPlatform()); !service->GetUserSettings()->IsSyncAllowedByPlatform());
sync_status->SetBoolean("signedIn", signin->IsAuthenticated()); sync_status->SetBoolean("signedIn", signin->IsAuthenticated());
sync_status->SetString("signedInUsername", sync_status->SetString(
signin_ui_util::GetAuthenticatedUsername(signin)); "signedInUsername",
signin_ui_util::GetAuthenticatedUsername(identity_manager));
sync_status->SetBoolean("hasUnrecoverableError", sync_status->SetBoolean("hasUnrecoverableError",
service && service->HasUnrecoverableError()); service && service->HasUnrecoverableError());
return sync_status; return sync_status;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment