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