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

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

Issue 2446563002: Refactor ArcAndroidManagementChecker. (Closed)
Patch Set: 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_android_management_checker.h" 17 #include "chrome/browser/chromeos/arc/arc_android_management_checker.h"
18 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher.h" 18 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher.h"
19 #include "chrome/browser/chromeos/arc/arc_auth_context.h" 19 #include "chrome/browser/chromeos/arc/arc_auth_context.h"
20 #include "chrome/browser/chromeos/arc/arc_auth_notification.h" 20 #include "chrome/browser/chromeos/arc/arc_auth_notification.h"
21 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" 21 #include "chrome/browser/chromeos/arc/arc_optin_uma.h"
22 #include "chrome/browser/chromeos/arc/arc_support_host.h" 22 #include "chrome/browser/chromeos/arc/arc_support_host.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 12 matching lines...) Expand all
64 64
65 // The Android management check is disabled by default, it's used only for 65 // The Android management check is disabled by default, it's used only for
66 // testing. 66 // testing.
67 bool g_enable_check_android_management_for_testing = false; 67 bool g_enable_check_android_management_for_testing = false;
68 68
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";
Luis Héctor Chávez 2016/10/24 22:39:57 can you make these constexpr while you're at it?
hidehiko 2016/10/25 07:22:42 Addressed in https://codereview.chromium.org/24452
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() {
Luis Héctor Chávez 2016/10/24 22:39:57 Can we also move this to arc_policy_util.h?
hidehiko 2016/10/25 07:22:42 Addressed in https://codereview.chromium.org/24480
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());
94 return ash::WmShell::Get()->shelf_delegate(); 89 return ash::WmShell::Get()->shelf_delegate();
(...skipping 266 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 SetState(State::STOPPED); 482 SetState(State::STOPPED);
488 483
489 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( 484 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver(
490 prefs::kArcEnabled, this); 485 prefs::kArcEnabled, this);
491 486
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 563
569 OpenApplication(CreateAppLaunchParamsUserContainer( 564 OpenApplication(CreateAppLaunchParamsUserContainer(
570 profile_, extension, WindowOpenDisposition::NEW_WINDOW, 565 profile_, extension, WindowOpenDisposition::NEW_WINDOW,
571 extensions::SOURCE_CHROME_INTERNAL)); 566 extensions::SOURCE_CHROME_INTERNAL));
572 } 567 }
573 568
574 void ArcAuthService::OnContextReady() { 569 void ArcAuthService::OnContextReady() {
575 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 570 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
576 571
577 DCHECK(!initial_opt_in_); 572 DCHECK(!initial_opt_in_);
578 CheckAndroidManagement(false); 573
574 // TODO(hidehiko): The check is not necessary if this is a part of re-auth
575 // flow. Remove this.
576 android_management_checker_.reset(new ArcAndroidManagementChecker(
577 profile_, context_->token_service(), context_->account_id(),
578 false /* retry_on_error */));
579 android_management_checker_->StartCheck(
580 base::Bind(&ArcAuthService::OnAndroidManagementChecked,
581 weak_ptr_factory_.GetWeakPtr()));
579 } 582 }
580 583
581 void ArcAuthService::OnSyncedPrefChanged(const std::string& path, 584 void ArcAuthService::OnSyncedPrefChanged(const std::string& path,
582 bool from_sync) { 585 bool from_sync) {
583 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 586 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
584 587
585 // Update UMA only for local changes 588 // Update UMA only for local changes
586 if (!from_sync) { 589 if (!from_sync) {
587 const bool arc_enabled = 590 const bool arc_enabled =
588 profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); 591 profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 if (state_ == State::ACTIVE) 628 if (state_ == State::ACTIVE)
626 return; 629 return;
627 CloseUI(); 630 CloseUI();
628 auth_code_.clear(); 631 auth_code_.clear();
629 632
630 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { 633 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) {
631 // Need pre-fetch auth code and show OptIn UI if needed. 634 // Need pre-fetch auth code and show OptIn UI if needed.
632 initial_opt_in_ = true; 635 initial_opt_in_ = true;
633 StartUI(); 636 StartUI();
634 } else { 637 } else {
635 // Ready to start Arc, but check Android management first. 638 // Ready to start Arc, but check Android management in parallel.
639 StartArc();
Luis Héctor Chávez 2016/10/24 22:36:02 IIUC you are not calling FetchAuthCode(); in this
hidehiko 2016/10/25 07:22:42 FetchAuthCode was not called even in the original
Luis Héctor Chávez 2016/10/25 17:11:39 Oh, right (good thing we're cleaning up this code)
640 // Note: Because the callback may be called in synchronous way (i.e. called
641 // on the same stack), StartCheck() needs to be called *after* StartArc().
642 // Otherwise, DisableArc() which may be called in
643 // OnBackgroundAndroidManagementChecked() could be ignored.
636 if (!g_disable_ui_for_testing || 644 if (!g_disable_ui_for_testing ||
637 g_enable_check_android_management_for_testing) { 645 g_enable_check_android_management_for_testing) {
638 CheckAndroidManagement(true); 646 android_management_checker_.reset(new ArcAndroidManagementChecker(
639 } else { 647 profile_, context_->token_service(), context_->account_id(),
640 StartArc(); 648 true /* retry_on_error */));
649 android_management_checker_->StartCheck(
Luis Héctor Chávez 2016/10/24 22:36:02 Seems like you need some state to track whether th
hidehiko 2016/10/25 07:22:42 Inflight check is canceled by reset above and/or (
650 base::Bind(&ArcAuthService::OnBackgroundAndroidManagementChecked,
651 weak_ptr_factory_.GetWeakPtr()));
641 } 652 }
642 } 653 }
643 654
644 UpdateEnabledStateUMA(true); 655 UpdateEnabledStateUMA(true);
645 } 656 }
646 657
647 void ArcAuthService::ShutdownBridge() { 658 void ArcAuthService::ShutdownBridge() {
648 arc_sign_in_timer_.Stop(); 659 arc_sign_in_timer_.Stop();
649 playstore_launcher_.reset(); 660 playstore_launcher_.reset();
650 auth_callback_.Reset(); 661 auth_callback_.Reset();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 879
869 void ArcAuthService::OnAuthCodeFailed() { 880 void ArcAuthService::OnAuthCodeFailed() {
870 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 881 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
871 DCHECK_EQ(state_, State::FETCHING_CODE); 882 DCHECK_EQ(state_, State::FETCHING_CODE);
872 ShutdownBridgeAndShowUI( 883 ShutdownBridgeAndShowUI(
873 UIPage::ERROR, 884 UIPage::ERROR,
874 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); 885 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR));
875 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 886 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
876 } 887 }
877 888
878 void ArcAuthService::CheckAndroidManagement(bool background_mode) {
879 // Do not send requests for Chrome OS managed users.
880 if (IsAccountManaged(profile_)) {
881 OnAndroidManagementPassed();
882 return;
883 }
884
885 // Do not send requests for well-known consumer domains.
886 if (policy::BrowserPolicyConnector::IsNonEnterpriseUser(
887 profile_->GetProfileUserName())) {
888 OnAndroidManagementPassed();
889 return;
890 }
891
892 android_management_checker_.reset(
893 new ArcAndroidManagementChecker(this, context_->token_service(),
894 context_->account_id(), background_mode));
895 if (background_mode)
896 OnAndroidManagementPassed();
897 }
898
899 void ArcAuthService::OnAndroidManagementChecked( 889 void ArcAuthService::OnAndroidManagementChecked(
900 policy::AndroidManagementClient::Result result) { 890 policy::AndroidManagementClient::Result result) {
891 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
901 switch (result) { 892 switch (result) {
902 case policy::AndroidManagementClient::Result::RESULT_UNMANAGED: 893 case policy::AndroidManagementClient::Result::RESULT_UNMANAGED:
903 OnAndroidManagementPassed(); 894 OnAndroidManagementPassed();
904 break; 895 break;
905 case policy::AndroidManagementClient::Result::RESULT_MANAGED: 896 case policy::AndroidManagementClient::Result::RESULT_MANAGED:
906 if (android_management_checker_->background_mode()) {
907 DisableArc();
908 return;
909 }
910 ShutdownBridgeAndShowUI( 897 ShutdownBridgeAndShowUI(
911 UIPage::ERROR, 898 UIPage::ERROR,
912 l10n_util::GetStringUTF16(IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR)); 899 l10n_util::GetStringUTF16(IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR));
913 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED); 900 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED);
914 break; 901 break;
915 case policy::AndroidManagementClient::Result::RESULT_ERROR: 902 case policy::AndroidManagementClient::Result::RESULT_ERROR:
916 ShutdownBridgeAndShowUI( 903 ShutdownBridgeAndShowUI(
917 UIPage::ERROR, 904 UIPage::ERROR,
918 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); 905 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR));
919 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 906 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
920 break; 907 break;
921 default: 908 default:
922 NOTREACHED(); 909 NOTREACHED();
923 } 910 }
924 } 911 }
925 912
913 void ArcAuthService::OnBackgroundAndroidManagementChecked(
914 policy::AndroidManagementClient::Result result) {
915 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
916 switch (result) {
917 case policy::AndroidManagementClient::Result::RESULT_UNMANAGED:
918 // Do nothing. The ARC should be started already.
Luis Héctor Chávez 2016/10/24 22:36:02 nit: s/The ARC/ARC/.
hidehiko 2016/10/25 07:22:42 Done.
919 break;
920 case policy::AndroidManagementClient::Result::RESULT_MANAGED:
921 DisableArc();
Luis Héctor Chávez 2016/10/24 22:36:03 Is there a way to intentionally delay the receipt
hidehiko 2016/10/25 07:22:42 Maybe, I'm not understanding the goal to delay the
Luis Héctor Chávez 2016/10/25 17:11:39 The concern is about a malicious actor that wants
Luis Héctor Chávez 2016/10/25 17:47:58 As discussed offline, since this is *not* a regres
hidehiko 2016/10/26 12:46:05 Acknowledged. Let's discuss separately.
922 break;
923 case policy::AndroidManagementClient::Result::RESULT_ERROR:
924 // This code should not be reached. For background check,
925 // retry_on_error sould be set.
Luis Héctor Chávez 2016/10/24 22:36:03 nit: s/sould/should/
hidehiko 2016/10/25 07:22:42 Done.
926 NOTREACHED();
927 }
928 }
929
926 void ArcAuthService::FetchAuthCode() { 930 void ArcAuthService::FetchAuthCode() {
927 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 931 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
928 932
929 const base::CommandLine* command_line = 933 const base::CommandLine* command_line =
930 base::CommandLine::ForCurrentProcess(); 934 base::CommandLine::ForCurrentProcess();
931 std::string auth_endpoint; 935 std::string auth_endpoint;
932 if (command_line->HasSwitch(chromeos::switches::kArcUseAuthEndpoint)) { 936 if (command_line->HasSwitch(chromeos::switches::kArcUseAuthEndpoint)) {
933 auth_endpoint = command_line->GetSwitchValueASCII( 937 auth_endpoint = command_line->GetSwitchValueASCII(
934 chromeos::switches::kArcUseAuthEndpoint); 938 chromeos::switches::kArcUseAuthEndpoint);
935 } 939 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 return os << kStateFetchingCode; 973 return os << kStateFetchingCode;
970 case ArcAuthService::State::ACTIVE: 974 case ArcAuthService::State::ACTIVE:
971 return os << kStateActive; 975 return os << kStateActive;
972 default: 976 default:
973 NOTREACHED(); 977 NOTREACHED();
974 return os; 978 return os;
975 } 979 }
976 } 980 }
977 981
978 } // namespace arc 982 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698