Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_service.cc

Issue 2926893002: arc: Start ARC for Public Session users.
Patch Set: Update unit tests. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/arc_auth_service.h" 5 #include "chrome/browser/chromeos/arc/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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 MAP_PROVISIONING_RESULT(CLOUD_PROVISION_FLOW_INTERNAL_ERROR); 56 MAP_PROVISIONING_RESULT(CLOUD_PROVISION_FLOW_INTERNAL_ERROR);
57 MAP_PROVISIONING_RESULT(NO_NETWORK_CONNECTION); 57 MAP_PROVISIONING_RESULT(NO_NETWORK_CONNECTION);
58 } 58 }
59 #undef MAP_PROVISIONING_RESULT 59 #undef MAP_PROVISIONING_RESULT
60 60
61 NOTREACHED() << "unknown reason: " << static_cast<int>(reason); 61 NOTREACHED() << "unknown reason: " << static_cast<int>(reason);
62 return ProvisioningResult::UNKNOWN_ERROR; 62 return ProvisioningResult::UNKNOWN_ERROR;
63 } 63 }
64 64
65 mojom::ChromeAccountType GetAccountType() { 65 mojom::ChromeAccountType GetAccountType() {
66 return IsArcKioskMode() ? mojom::ChromeAccountType::ROBOT_ACCOUNT 66 return IsArcKioskMode() || IsPublicSessionMode()
67 : mojom::ChromeAccountType::USER_ACCOUNT; 67 ? mojom::ChromeAccountType::ROBOT_ACCOUNT
68 : mojom::ChromeAccountType::USER_ACCOUNT;
68 } 69 }
69 70
70 } // namespace 71 } // namespace
71 72
72 // static 73 // static
73 const char ArcAuthService::kArcServiceName[] = "arc::ArcAuthService"; 74 const char ArcAuthService::kArcServiceName[] = "arc::ArcAuthService";
74 75
75 // TODO(lhchavez): Get rid of this class once we can safely remove all the 76 // TODO(lhchavez): Get rid of this class once we can safely remove all the
76 // deprecated interfaces and only need to care about one type of callback. 77 // deprecated interfaces and only need to care about one type of callback.
77 class ArcAuthService::AccountInfoNotifier { 78 class ArcAuthService::AccountInfoNotifier {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 void ArcAuthService::GetAuthCodeDeprecated0( 212 void ArcAuthService::GetAuthCodeDeprecated0(
212 const GetAuthCodeDeprecated0Callback& callback) { 213 const GetAuthCodeDeprecated0Callback& callback) {
213 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 214 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
214 NOTREACHED() << "GetAuthCodeDeprecated0() should no longer be callable"; 215 NOTREACHED() << "GetAuthCodeDeprecated0() should no longer be callable";
215 } 216 }
216 217
217 void ArcAuthService::GetAuthCodeDeprecated( 218 void ArcAuthService::GetAuthCodeDeprecated(
218 const GetAuthCodeDeprecatedCallback& callback) { 219 const GetAuthCodeDeprecatedCallback& callback) {
219 // For robot account we must use RequestAccountInfo because it allows 220 // For robot account we must use RequestAccountInfo because it allows
220 // to specify account type. 221 // to specify account type.
221 DCHECK(!IsArcKioskMode()); 222 DCHECK(!IsArcKioskMode() && !IsPublicSessionMode());
222 RequestAccountInfoInternal( 223 RequestAccountInfoInternal(
223 base::MakeUnique<ArcAuthService::AccountInfoNotifier>(callback)); 224 base::MakeUnique<ArcAuthService::AccountInfoNotifier>(callback));
224 } 225 }
225 226
226 void ArcAuthService::GetAuthCodeAndAccountTypeDeprecated( 227 void ArcAuthService::GetAuthCodeAndAccountTypeDeprecated(
227 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) { 228 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) {
228 RequestAccountInfoInternal( 229 RequestAccountInfoInternal(
229 base::MakeUnique<ArcAuthService::AccountInfoNotifier>(callback)); 230 base::MakeUnique<ArcAuthService::AccountInfoNotifier>(callback));
230 } 231 }
231 232
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 auto enrollment_token_fetcher = 266 auto enrollment_token_fetcher =
266 base::MakeUnique<ArcActiveDirectoryEnrollmentTokenFetcher>(); 267 base::MakeUnique<ArcActiveDirectoryEnrollmentTokenFetcher>();
267 enrollment_token_fetcher->Fetch( 268 enrollment_token_fetcher->Fetch(
268 base::Bind(&ArcAuthService::OnEnrollmentTokenFetched, 269 base::Bind(&ArcAuthService::OnEnrollmentTokenFetched,
269 weak_ptr_factory_.GetWeakPtr())); 270 weak_ptr_factory_.GetWeakPtr()));
270 fetcher_ = std::move(enrollment_token_fetcher); 271 fetcher_ = std::move(enrollment_token_fetcher);
271 return; 272 return;
272 } 273 }
273 // For non-AD enrolled devices an auth code is fetched. 274 // For non-AD enrolled devices an auth code is fetched.
274 std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher; 275 std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher;
275 if (IsArcKioskMode()) { 276 if (IsArcKioskMode() || IsPublicSessionMode()) {
276 // In Kiosk mode, use Robot auth code fetching. 277 // In Kiosk and public session mode, use Robot auth code fetching.
277 auth_code_fetcher = base::MakeUnique<ArcRobotAuthCodeFetcher>(); 278 auth_code_fetcher = base::MakeUnique<ArcRobotAuthCodeFetcher>();
278 } else if (base::FeatureList::IsEnabled(arc::kArcUseAuthEndpointFeature)) { 279 } else if (base::FeatureList::IsEnabled(arc::kArcUseAuthEndpointFeature)) {
279 // Optionally retrieve auth code in silent mode. 280 // Optionally retrieve auth code in silent mode.
280 DCHECK(profile); 281 DCHECK(profile);
281 auth_code_fetcher = base::MakeUnique<ArcBackgroundAuthCodeFetcher>( 282 auth_code_fetcher = base::MakeUnique<ArcBackgroundAuthCodeFetcher>(
282 profile, ArcSessionManager::Get()->auth_context()); 283 profile, ArcSessionManager::Get()->auth_context());
283 } else { 284 } else {
284 // Report that silent auth code is not activated. All other states are 285 // Report that silent auth code is not activated. All other states are
285 // reported in ArcBackgroundAuthCodeFetcher. 286 // reported in ArcBackgroundAuthCodeFetcher.
286 UpdateSilentAuthCodeUMA(OptInSilentAuthCode::DISABLED); 287 UpdateSilentAuthCodeUMA(OptInSilentAuthCode::DISABLED);
287 // Otherwise, show LSO page and let user click "Sign in" button. 288 // Otherwise, show LSO page and let user click "Sign in" button.
288 // Here, support_host should be available always. The case support_host is 289 // Here, support_host should be available always. The case support_host is
289 // not created is when 1) IsArcOptInVerificationDisabled() is true or 2) 290 // not created is when 1) IsArcOptInVerificationDisabled() is true or 2)
290 // IsArcKioskMode() is true. Both cases are handled above. 291 // IsArcKioskMode() or IsPublicSessionMode() is true.
292 // Both cases are handled above.
291 auth_code_fetcher = base::MakeUnique<ArcManualAuthCodeFetcher>( 293 auth_code_fetcher = base::MakeUnique<ArcManualAuthCodeFetcher>(
292 ArcSessionManager::Get()->auth_context(), 294 ArcSessionManager::Get()->auth_context(),
293 ArcSessionManager::Get()->support_host()); 295 ArcSessionManager::Get()->support_host());
294 } 296 }
295 auth_code_fetcher->Fetch(base::Bind(&ArcAuthService::OnAuthCodeFetched, 297 auth_code_fetcher->Fetch(base::Bind(&ArcAuthService::OnAuthCodeFetched,
296 weak_ptr_factory_.GetWeakPtr())); 298 weak_ptr_factory_.GetWeakPtr()));
297 fetcher_ = std::move(auth_code_fetcher); 299 fetcher_ = std::move(auth_code_fetcher);
298 } 300 }
299 301
300 void ArcAuthService::OnEnrollmentTokenFetched( 302 void ArcAuthService::OnEnrollmentTokenFetched(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 351
350 notifier_->Notify( 352 notifier_->Notify(
351 !IsArcOptInVerificationDisabled(), auth_code, 353 !IsArcOptInVerificationDisabled(), auth_code,
352 ArcSessionManager::Get()->auth_context()->full_account_id(), 354 ArcSessionManager::Get()->auth_context()->full_account_id(),
353 GetAccountType(), 355 GetAccountType(),
354 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile())); 356 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile()));
355 notifier_.reset(); 357 notifier_.reset();
356 } 358 }
357 359
358 } // namespace arc 360 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/arc_session_manager.cc » ('j') | chrome/browser/chromeos/arc/arc_session_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698