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

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

Issue 1892873002: Add CheckAndroidManagement to ARC sign-in flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@check_android_management
Patch Set: Added CheckAndroidManagement when OptIn is disabled. Created 4 years, 7 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/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 10 #include "base/command_line.h"
12 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/logging.h"
13 #include "base/strings/string16.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/browser_process_platform_part.h"
15 #include "chrome/browser/chromeos/arc/arc_auth_notification.h" 18 #include "chrome/browser/chromeos/arc/arc_auth_notification.h"
16 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" 19 #include "chrome/browser/chromeos/arc/arc_optin_uma.h"
20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
17 #include "chrome/browser/chromeos/profiles/profile_helper.h" 21 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #include "chrome/browser/extensions/extension_util.h" 22 #include "chrome/browser/extensions/extension_util.h"
19 #include "chrome/browser/policy/profile_policy_connector.h" 23 #include "chrome/browser/policy/profile_policy_connector.h"
20 #include "chrome/browser/policy/profile_policy_connector_factory.h" 24 #include "chrome/browser/policy/profile_policy_connector_factory.h"
21 #include "chrome/browser/prefs/pref_service_syncable_util.h" 25 #include "chrome/browser/prefs/pref_service_syncable_util.h"
22 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
24 #include "chrome/browser/signin/signin_manager_factory.h" 28 #include "chrome/browser/signin/signin_manager_factory.h"
25 #include "chrome/browser/ui/app_list/arc/arc_app_launcher.h" 29 #include "chrome/browser/ui/app_list/arc/arc_app_launcher.h"
26 #include "chrome/browser/ui/extensions/app_launch_params.h" 30 #include "chrome/browser/ui/extensions/app_launch_params.h"
27 #include "chrome/browser/ui/extensions/application_launch.h" 31 #include "chrome/browser/ui/extensions/application_launch.h"
28 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
29 #include "chrome/grit/generated_resources.h" 33 #include "chrome/grit/generated_resources.h"
30 #include "chromeos/chromeos_switches.h" 34 #include "chromeos/chromeos_switches.h"
31 #include "components/arc/arc_bridge_service.h" 35 #include "components/arc/arc_bridge_service.h"
36 #include "components/policy/core/browser/browser_policy_connector.h"
37 #include "components/policy/core/common/cloud/device_management_service.h"
32 #include "components/pref_registry/pref_registry_syncable.h" 38 #include "components/pref_registry/pref_registry_syncable.h"
33 #include "components/prefs/pref_service.h" 39 #include "components/prefs/pref_service.h"
34 #include "components/signin/core/browser/profile_oauth2_token_service.h" 40 #include "components/signin/core/browser/profile_oauth2_token_service.h"
35 #include "components/signin/core/browser/signin_manager_base.h" 41 #include "components/signin/core/browser/signin_manager_base.h"
36 #include "components/syncable_prefs/pref_service_syncable.h" 42 #include "components/syncable_prefs/pref_service_syncable.h"
37 #include "components/user_manager/user.h" 43 #include "components/user_manager/user.h"
38 #include "content/public/browser/storage_partition.h" 44 #include "content/public/browser/storage_partition.h"
39 #include "content/public/common/url_constants.h" 45 #include "content/public/common/url_constants.h"
40 #include "extensions/browser/app_window/app_window_registry.h" 46 #include "extensions/browser/app_window/app_window_registry.h"
41 #include "extensions/browser/extension_prefs.h" 47 #include "extensions/browser/extension_prefs.h"
(...skipping 11 matching lines...) Expand all
53 base::LazyInstance<base::ThreadChecker> thread_checker = 59 base::LazyInstance<base::ThreadChecker> thread_checker =
54 LAZY_INSTANCE_INITIALIZER; 60 LAZY_INSTANCE_INITIALIZER;
55 61
56 const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa"; 62 const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa";
57 const char kArcSupportExtensionId[] = "cnbgggchhmkkdmeppjobngjoejnihlei"; 63 const char kArcSupportExtensionId[] = "cnbgggchhmkkdmeppjobngjoejnihlei";
58 const char kArcSupportStorageId[] = "arc_support"; 64 const char kArcSupportStorageId[] = "arc_support";
59 65
60 // Skip creating UI in unit tests 66 // Skip creating UI in unit tests
61 bool disable_ui_for_testing = false; 67 bool disable_ui_for_testing = false;
62 68
69 // The Android management check is disabled by default, it's used only for
70 // testing.
71 bool enable_check_android_management_for_testing = false;
72
63 const char kStateStopped[] = "STOPPED"; 73 const char kStateStopped[] = "STOPPED";
64 const char kStateFetchingCode[] = "FETCHING_CODE"; 74 const char kStateFetchingCode[] = "FETCHING_CODE";
65 const char kStateActive[] = "ACTIVE"; 75 const char kStateActive[] = "ACTIVE";
76
66 } // namespace 77 } // namespace
67 78
68 ArcAuthService::ArcAuthService(ArcBridgeService* bridge_service) 79 ArcAuthService::ArcAuthService(ArcBridgeService* bridge_service)
69 : ArcService(bridge_service), binding_(this) { 80 : ArcService(bridge_service), binding_(this), weak_ptr_factory_(this) {
70 DCHECK(!arc_auth_service); 81 DCHECK(!arc_auth_service);
71 DCHECK(thread_checker.Get().CalledOnValidThread()); 82 DCHECK(thread_checker.Get().CalledOnValidThread());
72 83
73 arc_auth_service = this; 84 arc_auth_service = this;
74 85
75 arc_bridge_service()->AddObserver(this); 86 arc_bridge_service()->AddObserver(this);
76 } 87 }
77 88
78 ArcAuthService::~ArcAuthService() { 89 ArcAuthService::~ArcAuthService() {
79 DCHECK(thread_checker.Get().CalledOnValidThread()); 90 DCHECK(thread_checker.Get().CalledOnValidThread());
(...skipping 24 matching lines...) Expand all
104 void ArcAuthService::DisableUIForTesting() { 115 void ArcAuthService::DisableUIForTesting() {
105 disable_ui_for_testing = true; 116 disable_ui_for_testing = true;
106 } 117 }
107 118
108 // static 119 // static
109 bool ArcAuthService::IsOptInVerificationDisabled() { 120 bool ArcAuthService::IsOptInVerificationDisabled() {
110 return base::CommandLine::ForCurrentProcess()->HasSwitch( 121 return base::CommandLine::ForCurrentProcess()->HasSwitch(
111 chromeos::switches::kDisableArcOptInVerification); 122 chromeos::switches::kDisableArcOptInVerification);
112 } 123 }
113 124
125 // static
126 void ArcAuthService::EnableCheckAndroidManagementForTesting() {
127 enable_check_android_management_for_testing = true;
128 }
129
114 void ArcAuthService::OnAuthInstanceReady() { 130 void ArcAuthService::OnAuthInstanceReady() {
115 arc_bridge_service()->auth_instance()->Init( 131 arc_bridge_service()->auth_instance()->Init(
116 binding_.CreateInterfacePtrAndBind()); 132 binding_.CreateInterfacePtrAndBind());
117 } 133 }
118 134
119 std::string ArcAuthService::GetAndResetAuthCode() { 135 std::string ArcAuthService::GetAndResetAuthCode() {
120 DCHECK(thread_checker.Get().CalledOnValidThread()); 136 DCHECK(thread_checker.Get().CalledOnValidThread());
121 std::string auth_code; 137 std::string auth_code;
122 auth_code_.swap(auth_code); 138 auth_code_.swap(auth_code);
123 return auth_code; 139 return auth_code;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 prefs::kArcEnabled, this); 251 prefs::kArcEnabled, this);
236 252
237 // Reuse storage used in ARC OptIn platform app. 253 // Reuse storage used in ARC OptIn platform app.
238 const std::string site_url = 254 const std::string site_url =
239 base::StringPrintf("%s://%s/persist?%s", content::kGuestScheme, 255 base::StringPrintf("%s://%s/persist?%s", content::kGuestScheme,
240 kArcSupportExtensionId, kArcSupportStorageId); 256 kArcSupportExtensionId, kArcSupportStorageId);
241 storage_partition_ = content::BrowserContext::GetStoragePartitionForSite( 257 storage_partition_ = content::BrowserContext::GetStoragePartitionForSite(
242 profile_, GURL(site_url)); 258 profile_, GURL(site_url));
243 CHECK(storage_partition_); 259 CHECK(storage_partition_);
244 260
261 // Get token service and account ID to fetch auth tokens.
262 token_service_ = ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
263 const SigninManagerBase* const signin_manager =
264 SigninManagerFactory::GetForProfile(profile_);
265 CHECK(token_service_ && signin_manager);
266 account_id_ = signin_manager->GetAuthenticatedAccountId();
267
245 // In case UI is disabled we assume that ARC is opted-in. 268 // In case UI is disabled we assume that ARC is opted-in.
246 if (!IsOptInVerificationDisabled()) { 269 if (!IsOptInVerificationDisabled()) {
270 if (!disable_ui_for_testing || enable_check_android_management_for_testing)
271 StartAndroidManagementClient();
272
247 pref_change_registrar_.Init(profile_->GetPrefs()); 273 pref_change_registrar_.Init(profile_->GetPrefs());
248 pref_change_registrar_.Add( 274 pref_change_registrar_.Add(
249 prefs::kArcEnabled, 275 prefs::kArcEnabled,
250 base::Bind(&ArcAuthService::OnOptInPreferenceChanged, 276 base::Bind(&ArcAuthService::OnOptInPreferenceChanged,
251 base::Unretained(this))); 277 weak_ptr_factory_.GetWeakPtr()));
252 if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) { 278 if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) {
253 OnOptInPreferenceChanged(); 279 OnOptInPreferenceChanged();
254 } else { 280 } else {
255 UpdateEnabledStateUMA(false); 281 UpdateEnabledStateUMA(false);
256 PrefServiceSyncableFromProfile(profile_)->AddObserver(this); 282 PrefServiceSyncableFromProfile(profile_)->AddObserver(this);
257 OnIsSyncingChanged(); 283 OnIsSyncingChanged();
258 } 284 }
259 } else { 285 } else {
260 auth_code_.clear(); 286 auth_code_.clear();
261 StartArc(); 287 CheckAndroidManagement();
262 } 288 }
263 } 289 }
264 290
265 void ArcAuthService::OnIsSyncingChanged() { 291 void ArcAuthService::OnIsSyncingChanged() {
266 syncable_prefs::PrefServiceSyncable* const pref_service_syncable = 292 syncable_prefs::PrefServiceSyncable* const pref_service_syncable =
267 PrefServiceSyncableFromProfile(profile_); 293 PrefServiceSyncableFromProfile(profile_);
268 if (!pref_service_syncable->IsSyncing()) 294 if (!pref_service_syncable->IsSyncing())
269 return; 295 return;
270 296
271 pref_service_syncable->RemoveObserver(this); 297 pref_service_syncable->RemoveObserver(this);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 336
311 OpenApplication(CreateAppLaunchParamsUserContainer( 337 OpenApplication(CreateAppLaunchParamsUserContainer(
312 profile_, extension, NEW_WINDOW, extensions::SOURCE_CHROME_INTERNAL)); 338 profile_, extension, NEW_WINDOW, extensions::SOURCE_CHROME_INTERNAL));
313 } 339 }
314 340
315 void ArcAuthService::OnMergeSessionSuccess(const std::string& data) { 341 void ArcAuthService::OnMergeSessionSuccess(const std::string& data) {
316 DCHECK(thread_checker.Get().CalledOnValidThread()); 342 DCHECK(thread_checker.Get().CalledOnValidThread());
317 343
318 DCHECK(!initial_opt_in_); 344 DCHECK(!initial_opt_in_);
319 context_prepared_ = true; 345 context_prepared_ = true;
320 ShowUI(UIPage::LSO_PROGRESS, base::string16()); 346 CheckAndroidManagement();
321 } 347 }
322 348
323 void ArcAuthService::OnMergeSessionFailure( 349 void ArcAuthService::OnMergeSessionFailure(
324 const GoogleServiceAuthError& error) { 350 const GoogleServiceAuthError& error) {
325 DCHECK(thread_checker.Get().CalledOnValidThread()); 351 DCHECK(thread_checker.Get().CalledOnValidThread());
326 VLOG(2) << "Failed to merge gaia session " << error.ToString() << "."; 352 VLOG(2) << "Failed to merge gaia session " << error.ToString() << ".";
327 OnPrepareContextFailed(); 353 OnPrepareContextFailed();
328 } 354 }
329 355
330 void ArcAuthService::OnUbertokenSuccess(const std::string& token) { 356 void ArcAuthService::OnUbertokenSuccess(const std::string& token) {
(...skipping 29 matching lines...) Expand all
360 if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) { 386 if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) {
361 if (state_ != State::ACTIVE) { 387 if (state_ != State::ACTIVE) {
362 CloseUI(); 388 CloseUI();
363 auth_code_.clear(); 389 auth_code_.clear();
364 390
365 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { 391 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) {
366 // Need pre-fetch auth code and show OptIn UI if needed. 392 // Need pre-fetch auth code and show OptIn UI if needed.
367 initial_opt_in_ = true; 393 initial_opt_in_ = true;
368 StartUI(); 394 StartUI();
369 } else { 395 } else {
370 // Ready to start Arc. 396 // Ready to start Arc, but check android management first.
371 StartArc(); 397 if (!disable_ui_for_testing ||
398 enable_check_android_management_for_testing) {
399 CheckAndroidManagement();
400 } else {
401 StartArc();
402 }
372 } 403 }
373 404
374 UpdateEnabledStateUMA(true); 405 UpdateEnabledStateUMA(true);
375 } 406 }
376 } else { 407 } else {
377 if (state_ != State::STOPPED) 408 if (state_ != State::STOPPED)
378 UpdateEnabledStateUMA(false); 409 UpdateEnabledStateUMA(false);
379 ShutdownBridgeAndCloseUI(); 410 ShutdownBridgeAndCloseUI();
380 } 411 }
381 } 412 }
382 413
383 void ArcAuthService::ShutdownBridge() { 414 void ArcAuthService::ShutdownBridge() {
415 FOR_EACH_OBSERVER(Observer, observer_list_, OnShutdownBridge());
xiyuan 2016/05/03 16:57:23 nit: move this to the end of the function?
Polina Bondarenko 2016/05/04 10:38:11 Done.
384 playstore_launcher_.reset(); 416 playstore_launcher_.reset();
385 auth_callback_.reset(); 417 auth_callback_.reset();
386 ubertoken_fethcher_.reset(); 418 ubertoken_fethcher_.reset();
387 merger_fetcher_.reset(); 419 merger_fetcher_.reset();
420 token_service_ = nullptr;
421 account_id_ = "";
388 arc_bridge_service()->Shutdown(); 422 arc_bridge_service()->Shutdown();
389 SetState(State::STOPPED); 423 SetState(State::STOPPED);
390 } 424 }
391 425
392 void ArcAuthService::ShutdownBridgeAndCloseUI() { 426 void ArcAuthService::ShutdownBridgeAndCloseUI() {
393 ShutdownBridge(); 427 ShutdownBridge();
394 CloseUI(); 428 CloseUI();
395 } 429 }
396 430
397 void ArcAuthService::ShutdownBridgeAndShowUI(UIPage page, 431 void ArcAuthService::ShutdownBridgeAndShowUI(UIPage page,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 if (ui_page_ == UIPage::ERROR) 495 if (ui_page_ == UIPage::ERROR)
462 UpdateOptInActionUMA(OptInActionType::RETRY); 496 UpdateOptInActionUMA(OptInActionType::RETRY);
463 497
464 initial_opt_in_ = false; 498 initial_opt_in_ = false;
465 StartUI(); 499 StartUI();
466 } 500 }
467 501
468 void ArcAuthService::CancelAuthCode() { 502 void ArcAuthService::CancelAuthCode() {
469 DCHECK(thread_checker.Get().CalledOnValidThread()); 503 DCHECK(thread_checker.Get().CalledOnValidThread());
470 504
471 if (state_ != State::FETCHING_CODE) 505 if (state_ != State::FETCHING_CODE && ui_page_ != UIPage::ERROR)
472 return; 506 return;
473 507
474 // Update UMA with user cancel only if error is not currently shown. 508 // Update UMA with user cancel only if error is not currently shown.
475 if (ui_page_ != UIPage::ERROR && ui_page_ != UIPage::NO_PAGE) 509 if (ui_page_ != UIPage::ERROR && ui_page_ != UIPage::NO_PAGE)
476 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL); 510 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL);
477 511
478 DisableArc(); 512 DisableArc();
479 } 513 }
480 514
481 void ArcAuthService::EnableArc() { 515 void ArcAuthService::EnableArc() {
482 DCHECK(thread_checker.Get().CalledOnValidThread()); 516 DCHECK(thread_checker.Get().CalledOnValidThread());
483 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); 517 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, true);
484 } 518 }
485 519
486 void ArcAuthService::DisableArc() { 520 void ArcAuthService::DisableArc() {
487 DCHECK(thread_checker.Get().CalledOnValidThread()); 521 DCHECK(thread_checker.Get().CalledOnValidThread());
488 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, false); 522 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, false);
489 } 523 }
490 524
491 void ArcAuthService::PrepareContext() { 525 void ArcAuthService::PrepareContext() {
492 DCHECK(thread_checker.Get().CalledOnValidThread()); 526 DCHECK(thread_checker.Get().CalledOnValidThread());
493 527
494 // Get auth token to continue.
495 ProfileOAuth2TokenService* token_service =
496 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
497 SigninManagerBase* signin_manager =
498 SigninManagerFactory::GetForProfile(profile_);
499 CHECK(token_service && signin_manager);
500 const std::string& account_id = signin_manager->GetAuthenticatedAccountId();
501 ubertoken_fethcher_.reset( 528 ubertoken_fethcher_.reset(
502 new UbertokenFetcher(token_service, this, GaiaConstants::kChromeOSSource, 529 new UbertokenFetcher(token_service_, this, GaiaConstants::kChromeOSSource,
503 storage_partition_->GetURLRequestContext())); 530 storage_partition_->GetURLRequestContext()));
504 ubertoken_fethcher_->StartFetchingToken(account_id); 531 ubertoken_fethcher_->StartFetchingToken(account_id_);
505 } 532 }
506 533
507 void ArcAuthService::StartUI() { 534 void ArcAuthService::StartUI() {
508 DCHECK(thread_checker.Get().CalledOnValidThread()); 535 DCHECK(thread_checker.Get().CalledOnValidThread());
509 536
510 SetState(State::FETCHING_CODE); 537 SetState(State::FETCHING_CODE);
511 538
512 if (initial_opt_in_) { 539 if (initial_opt_in_) {
513 initial_opt_in_ = false; 540 initial_opt_in_ = false;
514 ShowUI(UIPage::START, base::string16()); 541 ShowUI(UIPage::START, base::string16());
515 } else if (context_prepared_) { 542 } else if (context_prepared_) {
516 ShowUI(UIPage::LSO_PROGRESS, base::string16()); 543 CheckAndroidManagement();
517 } else { 544 } else {
518 PrepareContext(); 545 PrepareContext();
519 } 546 }
520 } 547 }
521 548
522 void ArcAuthService::OnPrepareContextFailed() { 549 void ArcAuthService::OnPrepareContextFailed() {
523 DCHECK_EQ(state_, State::FETCHING_CODE); 550 DCHECK_EQ(state_, State::FETCHING_CODE);
524 551
525 ShutdownBridgeAndShowUI( 552 ShutdownBridgeAndShowUI(
526 UIPage::ERROR, 553 UIPage::ERROR,
527 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); 554 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR));
528 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 555 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
529 } 556 }
530 557
558 void ArcAuthService::StartAndroidManagementClient() {
559 policy::BrowserPolicyConnectorChromeOS* const connector =
560 g_browser_process->platform_part()->browser_policy_connector_chromeos();
561 policy::DeviceManagementService* const service =
562 connector->device_management_service();
563 service->ScheduleInitialization(0);
564 android_management_client_.reset(new policy::AndroidManagementClient(
565 service, g_browser_process->system_request_context(), account_id_,
566 token_service_));
567 }
568
569 void ArcAuthService::CheckAndroidManagement() {
570 // Do not send requests for Chrome OS managed users.
571 if (policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile_)
572 ->IsManaged()) {
573 StartArcIfSignedIn();
574 return;
575 }
576
577 // Do not send requests for well-known consumer domains.
578 if (policy::BrowserPolicyConnector::IsNonEnterpriseUser(
579 profile_->GetProfileUserName())) {
580 StartArcIfSignedIn();
581 return;
582 }
583
584 android_management_client_->StartCheckAndroidManagement(
585 base::Bind(&ArcAuthService::OnAndroidManagementChecked,
586 weak_ptr_factory_.GetWeakPtr()));
587 }
588
589 void ArcAuthService::OnAndroidManagementChecked(
590 policy::AndroidManagementClient::Result result) {
591 switch (result) {
592 case policy::AndroidManagementClient::Result::RESULT_UNMANAGED:
593 StartArcIfSignedIn();
594 break;
595 case policy::AndroidManagementClient::Result::RESULT_MANAGED:
596 ShutdownBridgeAndShowUI(
597 UIPage::ERROR,
598 l10n_util::GetStringUTF16(IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR));
599 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED);
600 break;
601 case policy::AndroidManagementClient::Result::RESULT_ERROR:
602 ShutdownBridgeAndShowUI(
603 UIPage::ERROR,
604 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR));
605 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
606 break;
607 default:
608 NOTREACHED();
609 }
610 }
611
612 void ArcAuthService::StartArcIfSignedIn() {
613 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn) ||
bartfab (slow) 2016/05/03 16:53:44 Nit: Multi-line conditionals require curly braces.
Polina Bondarenko 2016/05/04 10:38:10 Done.
614 IsOptInVerificationDisabled())
615 StartArc();
616 else
617 ShowUI(UIPage::LSO_PROGRESS, base::string16());
618 }
619
531 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state) { 620 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state) {
532 switch (state) { 621 switch (state) {
533 case ArcAuthService::State::STOPPED: 622 case ArcAuthService::State::STOPPED:
534 return os << kStateStopped; 623 return os << kStateStopped;
535 case ArcAuthService::State::FETCHING_CODE: 624 case ArcAuthService::State::FETCHING_CODE:
536 return os << kStateFetchingCode; 625 return os << kStateFetchingCode;
537 case ArcAuthService::State::ACTIVE: 626 case ArcAuthService::State::ACTIVE:
538 return os << kStateActive; 627 return os << kStateActive;
539 default: 628 default:
540 NOTREACHED(); 629 NOTREACHED();
541 return os; 630 return os;
542 } 631 }
543 } 632 }
544 633
545 } // namespace arc 634 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698