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

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

Issue 2446563002: Refactor ArcAndroidManagementChecker. (Closed)
Patch Set: Address comments. Created 4 years, 1 month 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 "ash/common/shelf/shelf_delegate.h" 9 #include "ash/common/shelf/shelf_delegate.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher.h" 17 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher.h"
18 #include "chrome/browser/chromeos/arc/arc_auth_context.h" 18 #include "chrome/browser/chromeos/arc/arc_auth_context.h"
19 #include "chrome/browser/chromeos/arc/arc_auth_notification.h" 19 #include "chrome/browser/chromeos/arc/arc_auth_notification.h"
20 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" 20 #include "chrome/browser/chromeos/arc/arc_optin_uma.h"
21 #include "chrome/browser/chromeos/arc/arc_support_host.h" 21 #include "chrome/browser/chromeos/arc/arc_support_host.h"
22 #include "chrome/browser/chromeos/arc/policy/arc_android_management_checker.h" 22 #include "chrome/browser/chromeos/arc/policy/arc_android_management_checker.h"
23 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h"
23 #include "chrome/browser/chromeos/profiles/profile_helper.h" 24 #include "chrome/browser/chromeos/profiles/profile_helper.h"
24 #include "chrome/browser/extensions/extension_util.h" 25 #include "chrome/browser/extensions/extension_util.h"
25 #include "chrome/browser/policy/profile_policy_connector.h" 26 #include "chrome/browser/policy/profile_policy_connector.h"
26 #include "chrome/browser/policy/profile_policy_connector_factory.h" 27 #include "chrome/browser/policy/profile_policy_connector_factory.h"
27 #include "chrome/browser/prefs/pref_service_syncable_util.h" 28 #include "chrome/browser/prefs/pref_service_syncable_util.h"
28 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/ui/app_list/arc/arc_app_launcher.h" 30 #include "chrome/browser/ui/app_list/arc/arc_app_launcher.h"
30 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 31 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
31 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 32 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
32 #include "chrome/browser/ui/extensions/app_launch_params.h" 33 #include "chrome/browser/ui/extensions/app_launch_params.h"
33 #include "chrome/browser/ui/extensions/application_launch.h" 34 #include "chrome/browser/ui/extensions/application_launch.h"
34 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
35 #include "chrome/grit/generated_resources.h" 36 #include "chrome/grit/generated_resources.h"
36 #include "chromeos/chromeos_switches.h" 37 #include "chromeos/chromeos_switches.h"
37 #include "chromeos/cryptohome/cryptohome_parameters.h" 38 #include "chromeos/cryptohome/cryptohome_parameters.h"
38 #include "chromeos/dbus/dbus_thread_manager.h" 39 #include "chromeos/dbus/dbus_thread_manager.h"
39 #include "chromeos/dbus/session_manager_client.h" 40 #include "chromeos/dbus/session_manager_client.h"
40 #include "components/arc/arc_bridge_service.h" 41 #include "components/arc/arc_bridge_service.h"
41 #include "components/policy/core/browser/browser_policy_connector.h"
42 #include "components/pref_registry/pref_registry_syncable.h" 42 #include "components/pref_registry/pref_registry_syncable.h"
43 #include "components/prefs/pref_service.h" 43 #include "components/prefs/pref_service.h"
44 #include "components/syncable_prefs/pref_service_syncable.h" 44 #include "components/syncable_prefs/pref_service_syncable.h"
45 #include "components/user_manager/user.h" 45 #include "components/user_manager/user.h"
46 #include "content/public/browser/browser_thread.h" 46 #include "content/public/browser/browser_thread.h"
47 #include "extensions/browser/app_window/app_window_registry.h" 47 #include "extensions/browser/app_window/app_window_registry.h"
48 #include "extensions/browser/extension_prefs.h" 48 #include "extensions/browser/extension_prefs.h"
49 #include "extensions/browser/extension_registry.h" 49 #include "extensions/browser/extension_registry.h"
50 #include "ui/base/l10n/l10n_util.h" 50 #include "ui/base/l10n/l10n_util.h"
51 51
(...skipping 17 matching lines...) Expand all
69 // Maximum amount of time we'll wait for ARC to finish booting up. Once this 69 // Maximum amount of time we'll wait for ARC to finish booting up. Once this
70 // timeout expires, keep ARC running in case the user wants to file feedback, 70 // timeout expires, keep ARC running in case the user wants to file feedback,
71 // but present the UI to try again. 71 // but present the UI to try again.
72 constexpr base::TimeDelta kArcSignInTimeout = base::TimeDelta::FromMinutes(5); 72 constexpr base::TimeDelta kArcSignInTimeout = base::TimeDelta::FromMinutes(5);
73 73
74 const char kStateNotInitialized[] = "NOT_INITIALIZED"; 74 const char kStateNotInitialized[] = "NOT_INITIALIZED";
75 const char kStateStopped[] = "STOPPED"; 75 const char kStateStopped[] = "STOPPED";
76 const char kStateFetchingCode[] = "FETCHING_CODE"; 76 const char kStateFetchingCode[] = "FETCHING_CODE";
77 const char kStateActive[] = "ACTIVE"; 77 const char kStateActive[] = "ACTIVE";
78 78
79 bool IsAccountManaged(Profile* profile) {
80 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile)
81 ->IsManaged();
82 }
83
84 bool IsArcDisabledForEnterprise() { 79 bool IsArcDisabledForEnterprise() {
85 return base::CommandLine::ForCurrentProcess()->HasSwitch( 80 return base::CommandLine::ForCurrentProcess()->HasSwitch(
86 chromeos::switches::kEnterpriseDisableArc); 81 chromeos::switches::kEnterpriseDisableArc);
87 } 82 }
88 83
89 ash::ShelfDelegate* GetShelfDelegate() { 84 ash::ShelfDelegate* GetShelfDelegate() {
90 if (g_shelf_delegate_for_testing) 85 if (g_shelf_delegate_for_testing)
91 return g_shelf_delegate_for_testing; 86 return g_shelf_delegate_for_testing;
92 if (ash::WmShell::HasInstance()) { 87 if (ash::WmShell::HasInstance()) {
93 DCHECK(ash::WmShell::Get()->shelf_delegate()); 88 DCHECK(ash::WmShell::Get()->shelf_delegate());
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 356
362 if (!IsOptInVerificationDisabled() && 357 if (!IsOptInVerificationDisabled() &&
363 !profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { 358 !profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) {
364 playstore_launcher_.reset( 359 playstore_launcher_.reset(
365 new ArcAppLauncher(profile_, kPlayStoreAppId, true)); 360 new ArcAppLauncher(profile_, kPlayStoreAppId, true));
366 } 361 }
367 362
368 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); 363 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true);
369 CloseUI(); 364 CloseUI();
370 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, 365 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true,
371 IsAccountManaged(profile_)); 366 policy_util::IsAccountManaged(profile_));
372 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS, 367 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS,
373 IsAccountManaged(profile_)); 368 policy_util::IsAccountManaged(profile_));
374 369
375 for (auto& observer : observer_list_) 370 for (auto& observer : observer_list_)
376 observer.OnInitialStart(); 371 observer.OnInitialStart();
377 } 372 }
378 373
379 void ArcAuthService::OnSignInFailed(mojom::ArcSignInFailureReason reason) { 374 void ArcAuthService::OnSignInFailed(mojom::ArcSignInFailureReason reason) {
380 OnSignInFailedInternal( 375 OnSignInFailedInternal(
381 ConvertArcSignInFailureReasonToProvisioningResult(reason)); 376 ConvertArcSignInFailureReasonToProvisioningResult(reason));
382 } 377 }
383 378
384 void ArcAuthService::OnSignInFailedInternal(ProvisioningResult result) { 379 void ArcAuthService::OnSignInFailedInternal(ProvisioningResult result) {
385 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 380 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
386 DCHECK_EQ(state_, State::ACTIVE); 381 DCHECK_EQ(state_, State::ACTIVE);
387 DCHECK(!sign_in_time_.is_null()); 382 DCHECK(!sign_in_time_.is_null());
388 383
389 arc_sign_in_timer_.Stop(); 384 arc_sign_in_timer_.Stop();
390 385
391 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, false, 386 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, false,
392 IsAccountManaged(profile_)); 387 policy_util::IsAccountManaged(profile_));
393 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL); 388 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL);
394 UpdateProvisioningResultUMA(result, IsAccountManaged(profile_)); 389 UpdateProvisioningResultUMA(result, policy_util::IsAccountManaged(profile_));
395 390
396 int error_message_id; 391 int error_message_id;
397 switch (result) { 392 switch (result) {
398 case ProvisioningResult::GMS_NETWORK_ERROR: 393 case ProvisioningResult::GMS_NETWORK_ERROR:
399 error_message_id = IDS_ARC_SIGN_IN_NETWORK_ERROR; 394 error_message_id = IDS_ARC_SIGN_IN_NETWORK_ERROR;
400 break; 395 break;
401 case ProvisioningResult::GMS_SERVICE_UNAVAILABLE: 396 case ProvisioningResult::GMS_SERVICE_UNAVAILABLE:
402 case ProvisioningResult::GMS_SIGN_IN_FAILED: 397 case ProvisioningResult::GMS_SIGN_IN_FAILED:
403 case ProvisioningResult::GMS_SIGN_IN_TIMEOUT: 398 case ProvisioningResult::GMS_SIGN_IN_TIMEOUT:
404 case ProvisioningResult::GMS_SIGN_IN_INTERNAL_ERROR: 399 case ProvisioningResult::GMS_SIGN_IN_INTERNAL_ERROR:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // We'll delay shutting down the bridge in this case to allow people to send 439 // We'll delay shutting down the bridge in this case to allow people to send
445 // feedback. 440 // feedback.
446 ShowUI(UIPage::ERROR_WITH_FEEDBACK, 441 ShowUI(UIPage::ERROR_WITH_FEEDBACK,
447 l10n_util::GetStringUTF16(error_message_id)); 442 l10n_util::GetStringUTF16(error_message_id));
448 } 443 }
449 444
450 void ArcAuthService::GetIsAccountManaged( 445 void ArcAuthService::GetIsAccountManaged(
451 const GetIsAccountManagedCallback& callback) { 446 const GetIsAccountManagedCallback& callback) {
452 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 447 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
453 448
454 callback.Run(IsAccountManaged(profile_)); 449 callback.Run(policy_util::IsAccountManaged(profile_));
455 } 450 }
456 451
457 void ArcAuthService::SetState(State state) { 452 void ArcAuthService::SetState(State state) {
458 if (state_ == state) 453 if (state_ == state)
459 return; 454 return;
460 455
461 state_ = state; 456 state_ = state;
462 for (auto& observer : observer_list_) 457 for (auto& observer : observer_list_)
463 observer.OnOptInChanged(state_); 458 observer.OnOptInChanged(state_);
464 } 459 }
465 460
466 bool ArcAuthService::IsAllowed() const { 461 bool ArcAuthService::IsAllowed() const {
467 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 462 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
468 return profile_ != nullptr; 463 return profile_ != nullptr;
469 } 464 }
470 465
471 void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) { 466 void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) {
472 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 467 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
473 DCHECK(profile && profile != profile_); 468 DCHECK(profile && profile != profile_);
474 469
475 Shutdown(); 470 Shutdown();
476 471
477 if (!IsAllowedForProfile(profile)) 472 if (!IsAllowedForProfile(profile))
478 return; 473 return;
479 474
480 // TODO(khmel): Move this to IsAllowedForProfile. 475 // TODO(khmel): Move this to IsAllowedForProfile.
481 if (IsArcDisabledForEnterprise() && IsAccountManaged(profile)) { 476 if (IsArcDisabledForEnterprise() && policy_util::IsAccountManaged(profile)) {
482 VLOG(2) << "Enterprise users are not supported in ARC."; 477 VLOG(2) << "Enterprise users are not supported in ARC.";
483 return; 478 return;
484 } 479 }
485 480
486 profile_ = profile; 481 profile_ = profile;
487 // Create the support host at initialization. Note that, practically, 482 // Create the support host at initialization. Note that, practically,
488 // ARC support Chrome app is rarely used (only opt-in and re-auth flow). 483 // ARC support Chrome app is rarely used (only opt-in and re-auth flow).
489 // So, it may be better to initialize it lazily. 484 // So, it may be better to initialize it lazily.
490 // TODO(hidehiko): Revisit to think about lazy initialization. 485 // TODO(hidehiko): Revisit to think about lazy initialization.
491 support_host_.reset(new ArcSupportHost()); 486 support_host_.reset(new ArcSupportHost());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 ArcSupportHost::kHostAppId, profile_)); 567 ArcSupportHost::kHostAppId, profile_));
573 OpenApplication(CreateAppLaunchParamsUserContainer( 568 OpenApplication(CreateAppLaunchParamsUserContainer(
574 profile_, extension, WindowOpenDisposition::NEW_WINDOW, 569 profile_, extension, WindowOpenDisposition::NEW_WINDOW,
575 extensions::SOURCE_CHROME_INTERNAL)); 570 extensions::SOURCE_CHROME_INTERNAL));
576 } 571 }
577 572
578 void ArcAuthService::OnContextReady() { 573 void ArcAuthService::OnContextReady() {
579 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 574 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
580 575
581 DCHECK(!initial_opt_in_); 576 DCHECK(!initial_opt_in_);
582 CheckAndroidManagement(false); 577
578 // TODO(hidehiko): The check is not necessary if this is a part of re-auth
579 // flow. Remove this.
580 android_management_checker_.reset(new ArcAndroidManagementChecker(
581 profile_, context_->token_service(), context_->account_id(),
582 false /* retry_on_error */));
583 android_management_checker_->StartCheck(
584 base::Bind(&ArcAuthService::OnAndroidManagementChecked,
585 weak_ptr_factory_.GetWeakPtr()));
583 } 586 }
584 587
585 void ArcAuthService::OnSyncedPrefChanged(const std::string& path, 588 void ArcAuthService::OnSyncedPrefChanged(const std::string& path,
586 bool from_sync) { 589 bool from_sync) {
587 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 590 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
588 591
589 // Update UMA only for local changes 592 // Update UMA only for local changes
590 if (!from_sync) { 593 if (!from_sync) {
591 const bool arc_enabled = 594 const bool arc_enabled =
592 profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); 595 profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 if (state_ == State::ACTIVE) 632 if (state_ == State::ACTIVE)
630 return; 633 return;
631 CloseUI(); 634 CloseUI();
632 auth_code_.clear(); 635 auth_code_.clear();
633 636
634 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { 637 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) {
635 // Need pre-fetch auth code and show OptIn UI if needed. 638 // Need pre-fetch auth code and show OptIn UI if needed.
636 initial_opt_in_ = true; 639 initial_opt_in_ = true;
637 StartUI(); 640 StartUI();
638 } else { 641 } else {
639 // Ready to start Arc, but check Android management first. 642 // Ready to start Arc, but check Android management in parallel.
643 StartArc();
644 // Note: Because the callback may be called in synchronous way (i.e. called
645 // on the same stack), StartCheck() needs to be called *after* StartArc().
646 // Otherwise, DisableArc() which may be called in
647 // OnBackgroundAndroidManagementChecked() could be ignored.
640 if (!g_disable_ui_for_testing || 648 if (!g_disable_ui_for_testing ||
641 g_enable_check_android_management_for_testing) { 649 g_enable_check_android_management_for_testing) {
642 CheckAndroidManagement(true); 650 android_management_checker_.reset(new ArcAndroidManagementChecker(
643 } else { 651 profile_, context_->token_service(), context_->account_id(),
644 StartArc(); 652 true /* retry_on_error */));
653 android_management_checker_->StartCheck(
654 base::Bind(&ArcAuthService::OnBackgroundAndroidManagementChecked,
655 weak_ptr_factory_.GetWeakPtr()));
645 } 656 }
646 } 657 }
647 658
648 UpdateEnabledStateUMA(true); 659 UpdateEnabledStateUMA(true);
649 } 660 }
650 661
651 void ArcAuthService::ShutdownBridge() { 662 void ArcAuthService::ShutdownBridge() {
652 arc_sign_in_timer_.Stop(); 663 arc_sign_in_timer_.Stop();
653 playstore_launcher_.reset(); 664 playstore_launcher_.reset();
654 auth_callback_.Reset(); 665 auth_callback_.Reset();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 883
873 void ArcAuthService::OnAuthCodeFailed() { 884 void ArcAuthService::OnAuthCodeFailed() {
874 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 885 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
875 DCHECK_EQ(state_, State::FETCHING_CODE); 886 DCHECK_EQ(state_, State::FETCHING_CODE);
876 ShutdownBridgeAndShowUI( 887 ShutdownBridgeAndShowUI(
877 UIPage::ERROR, 888 UIPage::ERROR,
878 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); 889 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR));
879 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 890 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
880 } 891 }
881 892
882 void ArcAuthService::CheckAndroidManagement(bool background_mode) {
883 // Do not send requests for Chrome OS managed users.
884 if (IsAccountManaged(profile_)) {
885 OnAndroidManagementPassed();
886 return;
887 }
888
889 // Do not send requests for well-known consumer domains.
890 if (policy::BrowserPolicyConnector::IsNonEnterpriseUser(
891 profile_->GetProfileUserName())) {
892 OnAndroidManagementPassed();
893 return;
894 }
895
896 android_management_checker_.reset(
897 new ArcAndroidManagementChecker(this, context_->token_service(),
898 context_->account_id(), background_mode));
899 if (background_mode)
900 OnAndroidManagementPassed();
901 }
902
903 void ArcAuthService::OnAndroidManagementChecked( 893 void ArcAuthService::OnAndroidManagementChecked(
904 policy::AndroidManagementClient::Result result) { 894 policy::AndroidManagementClient::Result result) {
895 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
905 switch (result) { 896 switch (result) {
906 case policy::AndroidManagementClient::Result::RESULT_UNMANAGED: 897 case policy::AndroidManagementClient::Result::RESULT_UNMANAGED:
907 OnAndroidManagementPassed(); 898 OnAndroidManagementPassed();
908 break; 899 break;
909 case policy::AndroidManagementClient::Result::RESULT_MANAGED: 900 case policy::AndroidManagementClient::Result::RESULT_MANAGED:
910 if (android_management_checker_->background_mode()) {
911 DisableArc();
912 return;
913 }
914 ShutdownBridgeAndShowUI( 901 ShutdownBridgeAndShowUI(
915 UIPage::ERROR, 902 UIPage::ERROR,
916 l10n_util::GetStringUTF16(IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR)); 903 l10n_util::GetStringUTF16(IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR));
917 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED); 904 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED);
918 break; 905 break;
919 case policy::AndroidManagementClient::Result::RESULT_ERROR: 906 case policy::AndroidManagementClient::Result::RESULT_ERROR:
920 ShutdownBridgeAndShowUI( 907 ShutdownBridgeAndShowUI(
921 UIPage::ERROR, 908 UIPage::ERROR,
922 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); 909 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR));
923 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 910 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
924 break; 911 break;
925 default: 912 default:
926 NOTREACHED(); 913 NOTREACHED();
Luis Héctor Chávez 2016/10/25 17:47:58 I wish policy::AndroidManagementClient::Result wer
hidehiko 2016/10/26 12:46:05 I can give it a try to do it separately. Let me wo
927 } 914 }
928 } 915 }
929 916
917 void ArcAuthService::OnBackgroundAndroidManagementChecked(
918 policy::AndroidManagementClient::Result result) {
919 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
920 switch (result) {
921 case policy::AndroidManagementClient::Result::RESULT_UNMANAGED:
922 // Do nothing. ARC should be started already.
923 break;
924 case policy::AndroidManagementClient::Result::RESULT_MANAGED:
925 DisableArc();
926 break;
927 case policy::AndroidManagementClient::Result::RESULT_ERROR:
928 // This code should not be reached. For background check,
929 // retry_on_error should be set.
930 NOTREACHED();
931 }
932 }
933
930 void ArcAuthService::FetchAuthCode() { 934 void ArcAuthService::FetchAuthCode() {
931 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 935 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
932 936
933 const base::CommandLine* command_line = 937 const base::CommandLine* command_line =
934 base::CommandLine::ForCurrentProcess(); 938 base::CommandLine::ForCurrentProcess();
935 std::string auth_endpoint; 939 std::string auth_endpoint;
936 if (command_line->HasSwitch(chromeos::switches::kArcUseAuthEndpoint)) { 940 if (command_line->HasSwitch(chromeos::switches::kArcUseAuthEndpoint)) {
937 auth_endpoint = command_line->GetSwitchValueASCII( 941 auth_endpoint = command_line->GetSwitchValueASCII(
938 chromeos::switches::kArcUseAuthEndpoint); 942 chromeos::switches::kArcUseAuthEndpoint);
939 } 943 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 return os << kStateFetchingCode; 977 return os << kStateFetchingCode;
974 case ArcAuthService::State::ACTIVE: 978 case ArcAuthService::State::ACTIVE:
975 return os << kStateActive; 979 return os << kStateActive;
976 default: 980 default:
977 NOTREACHED(); 981 NOTREACHED();
978 return os; 982 return os;
979 } 983 }
980 } 984 }
981 985
982 } // namespace arc 986 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698