| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/arc/auth/arc_auth_service.h" | 5 #include "chrome/browser/chromeos/arc/auth/arc_auth_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 MAP_PROVISIONING_RESULT(CLOUD_PROVISION_FLOW_INTERNAL_ERROR); | 81 MAP_PROVISIONING_RESULT(CLOUD_PROVISION_FLOW_INTERNAL_ERROR); |
| 82 MAP_PROVISIONING_RESULT(NO_NETWORK_CONNECTION); | 82 MAP_PROVISIONING_RESULT(NO_NETWORK_CONNECTION); |
| 83 } | 83 } |
| 84 #undef MAP_PROVISIONING_RESULT | 84 #undef MAP_PROVISIONING_RESULT |
| 85 | 85 |
| 86 NOTREACHED() << "unknown reason: " << static_cast<int>(reason); | 86 NOTREACHED() << "unknown reason: " << static_cast<int>(reason); |
| 87 return ProvisioningResult::UNKNOWN_ERROR; | 87 return ProvisioningResult::UNKNOWN_ERROR; |
| 88 } | 88 } |
| 89 | 89 |
| 90 mojom::ChromeAccountType GetAccountType() { | 90 mojom::ChromeAccountType GetAccountType() { |
| 91 return IsArcKioskMode() ? mojom::ChromeAccountType::ROBOT_ACCOUNT | 91 return IsArcKioskMode() || IsPublicSessionMode() |
| 92 : mojom::ChromeAccountType::USER_ACCOUNT; | 92 ? mojom::ChromeAccountType::ROBOT_ACCOUNT |
| 93 : mojom::ChromeAccountType::USER_ACCOUNT; |
| 93 } | 94 } |
| 94 | 95 |
| 95 } // namespace | 96 } // namespace |
| 96 | 97 |
| 97 // static | 98 // static |
| 98 const char ArcAuthService::kArcServiceName[] = "arc::ArcAuthService"; | 99 const char ArcAuthService::kArcServiceName[] = "arc::ArcAuthService"; |
| 99 | 100 |
| 100 // static | 101 // static |
| 101 ArcAuthService* ArcAuthService::GetForBrowserContext( | 102 ArcAuthService* ArcAuthService::GetForBrowserContext( |
| 102 content::BrowserContext* context) { | 103 content::BrowserContext* context) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 void ArcAuthService::GetAuthCodeDeprecated0( | 249 void ArcAuthService::GetAuthCodeDeprecated0( |
| 249 const GetAuthCodeDeprecated0Callback& callback) { | 250 const GetAuthCodeDeprecated0Callback& callback) { |
| 250 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 251 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 251 NOTREACHED() << "GetAuthCodeDeprecated0() should no longer be callable"; | 252 NOTREACHED() << "GetAuthCodeDeprecated0() should no longer be callable"; |
| 252 } | 253 } |
| 253 | 254 |
| 254 void ArcAuthService::GetAuthCodeDeprecated( | 255 void ArcAuthService::GetAuthCodeDeprecated( |
| 255 const GetAuthCodeDeprecatedCallback& callback) { | 256 const GetAuthCodeDeprecatedCallback& callback) { |
| 256 // For robot account we must use RequestAccountInfo because it allows | 257 // For robot account we must use RequestAccountInfo because it allows |
| 257 // to specify account type. | 258 // to specify account type. |
| 258 DCHECK(!IsArcKioskMode()); | 259 DCHECK(!IsArcKioskMode() && !IsPublicSessionMode()); |
| 259 RequestAccountInfoInternal( | 260 RequestAccountInfoInternal( |
| 260 base::MakeUnique<ArcAuthService::AccountInfoNotifier>(callback)); | 261 base::MakeUnique<ArcAuthService::AccountInfoNotifier>(callback)); |
| 261 } | 262 } |
| 262 | 263 |
| 263 void ArcAuthService::GetAuthCodeAndAccountTypeDeprecated( | 264 void ArcAuthService::GetAuthCodeAndAccountTypeDeprecated( |
| 264 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) { | 265 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) { |
| 265 RequestAccountInfoInternal( | 266 RequestAccountInfoInternal( |
| 266 base::MakeUnique<ArcAuthService::AccountInfoNotifier>(callback)); | 267 base::MakeUnique<ArcAuthService::AccountInfoNotifier>(callback)); |
| 267 } | 268 } |
| 268 | 269 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 296 base::MakeUnique<ArcActiveDirectoryEnrollmentTokenFetcher>( | 297 base::MakeUnique<ArcActiveDirectoryEnrollmentTokenFetcher>( |
| 297 ArcSessionManager::Get()->support_host()); | 298 ArcSessionManager::Get()->support_host()); |
| 298 enrollment_token_fetcher->Fetch( | 299 enrollment_token_fetcher->Fetch( |
| 299 base::Bind(&ArcAuthService::OnEnrollmentTokenFetched, | 300 base::Bind(&ArcAuthService::OnEnrollmentTokenFetched, |
| 300 weak_ptr_factory_.GetWeakPtr())); | 301 weak_ptr_factory_.GetWeakPtr())); |
| 301 fetcher_ = std::move(enrollment_token_fetcher); | 302 fetcher_ = std::move(enrollment_token_fetcher); |
| 302 return; | 303 return; |
| 303 } | 304 } |
| 304 // For non-AD enrolled devices an auth code is fetched. | 305 // For non-AD enrolled devices an auth code is fetched. |
| 305 std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher; | 306 std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher; |
| 306 if (IsArcKioskMode()) { | 307 if (IsArcKioskMode() || IsPublicSessionMode()) { |
| 307 // In Kiosk mode, use Robot auth code fetching. | 308 // In Kiosk and public session mode, use Robot auth code fetching. |
| 308 auth_code_fetcher = base::MakeUnique<ArcRobotAuthCodeFetcher>(); | 309 auth_code_fetcher = base::MakeUnique<ArcRobotAuthCodeFetcher>(); |
| 309 } else { | 310 } else { |
| 310 // Optionally retrieve auth code in silent mode. | 311 // Optionally retrieve auth code in silent mode. |
| 311 auth_code_fetcher = base::MakeUnique<ArcBackgroundAuthCodeFetcher>( | 312 auth_code_fetcher = base::MakeUnique<ArcBackgroundAuthCodeFetcher>( |
| 312 profile_, ArcSessionManager::Get()->auth_context()); | 313 profile_, ArcSessionManager::Get()->auth_context()); |
| 313 } | 314 } |
| 314 auth_code_fetcher->Fetch(base::Bind(&ArcAuthService::OnAuthCodeFetched, | 315 auth_code_fetcher->Fetch(base::Bind(&ArcAuthService::OnAuthCodeFetched, |
| 315 weak_ptr_factory_.GetWeakPtr())); | 316 weak_ptr_factory_.GetWeakPtr())); |
| 316 fetcher_ = std::move(auth_code_fetcher); | 317 fetcher_ = std::move(auth_code_fetcher); |
| 317 } | 318 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 return; | 362 return; |
| 362 } | 363 } |
| 363 | 364 |
| 364 notifier_->Notify(!IsArcOptInVerificationDisabled(), auth_code, | 365 notifier_->Notify(!IsArcOptInVerificationDisabled(), auth_code, |
| 365 ArcSessionManager::Get()->auth_context()->full_account_id(), | 366 ArcSessionManager::Get()->auth_context()->full_account_id(), |
| 366 GetAccountType(), policy_util::IsAccountManaged(profile_)); | 367 GetAccountType(), policy_util::IsAccountManaged(profile_)); |
| 367 notifier_.reset(); | 368 notifier_.reset(); |
| 368 } | 369 } |
| 369 | 370 |
| 370 } // namespace arc | 371 } // namespace arc |
| OLD | NEW |