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

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

Issue 2745533005: Show notification during ARC managed provision (Closed)
Patch Set: Update message Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_session_manager.h" 5 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/shelf/shelf_delegate.h" 9 #include "ash/shelf/shelf_delegate.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 default: 366 default:
367 error = ArcSupportHost::Error::SIGN_IN_UNKNOWN_ERROR; 367 error = ArcSupportHost::Error::SIGN_IN_UNKNOWN_ERROR;
368 break; 368 break;
369 } 369 }
370 370
371 if (result == ProvisioningResult::ARC_STOPPED || 371 if (result == ProvisioningResult::ARC_STOPPED ||
372 result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { 372 result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) {
373 if (profile_->GetPrefs()->HasPrefPath(prefs::kArcSignedIn)) 373 if (profile_->GetPrefs()->HasPrefPath(prefs::kArcSignedIn))
374 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); 374 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false);
375 ShutdownSession(); 375 ShutdownSession();
376 if (support_host_) 376 ShowArcSupportHostError(error, true);
377 support_host_->ShowError(error, true);
378 return; 377 return;
379 } 378 }
380 379
381 if (result == ProvisioningResult::CLOUD_PROVISION_FLOW_FAILED || 380 if (result == ProvisioningResult::CLOUD_PROVISION_FLOW_FAILED ||
382 result == ProvisioningResult::CLOUD_PROVISION_FLOW_TIMEOUT || 381 result == ProvisioningResult::CLOUD_PROVISION_FLOW_TIMEOUT ||
383 result == ProvisioningResult::CLOUD_PROVISION_FLOW_INTERNAL_ERROR || 382 result == ProvisioningResult::CLOUD_PROVISION_FLOW_INTERNAL_ERROR ||
384 // OVERALL_SIGN_IN_TIMEOUT might be an indication that ARC believes it is 383 // OVERALL_SIGN_IN_TIMEOUT might be an indication that ARC believes it is
385 // fully setup, but Chrome does not. 384 // fully setup, but Chrome does not.
386 result == ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT || 385 result == ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT ||
387 // Just to be safe, remove data if we don't know the cause. 386 // Just to be safe, remove data if we don't know the cause.
388 result == ProvisioningResult::UNKNOWN_ERROR) { 387 result == ProvisioningResult::UNKNOWN_ERROR) {
389 VLOG(1) << "ARC provisioning failed permanently. Removing user data"; 388 VLOG(1) << "ARC provisioning failed permanently. Removing user data";
390 RequestArcDataRemoval(); 389 RequestArcDataRemoval();
391 } 390 }
392 391
393 // We'll delay shutting down the ARC instance in this case to allow people 392 // We'll delay shutting down the ARC instance in this case to allow people
394 // to send feedback. 393 // to send feedback.
395 if (support_host_) 394 ShowArcSupportHostError(error, true /* = show send feedback button */);
396 support_host_->ShowError(error, true /* = show send feedback button */);
397 } 395 }
398 396
399 void ArcSessionManager::SetState(State state) { 397 void ArcSessionManager::SetState(State state) {
400 state_ = state; 398 state_ = state;
401 } 399 }
402 400
403 bool ArcSessionManager::IsAllowed() const { 401 bool ArcSessionManager::IsAllowed() const {
404 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 402 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
405 return profile_ != nullptr; 403 return profile_ != nullptr;
406 } 404 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 // For Kiosk mode, skip ToS because it is very likely that near the device 585 // For Kiosk mode, skip ToS because it is very likely that near the device
588 // there will be no one who is eligible to accept them. 586 // there will be no one who is eligible to accept them.
589 // If opt-in verification is disabled, skip negotiation, too. This is for 587 // If opt-in verification is disabled, skip negotiation, too. This is for
590 // testing purpose. 588 // testing purpose.
591 if (prefs->GetBoolean(prefs::kArcSignedIn) || ShouldArcAlwaysStart() || 589 if (prefs->GetBoolean(prefs::kArcSignedIn) || ShouldArcAlwaysStart() ||
592 IsArcKioskMode() || IsArcOptInVerificationDisabled()) { 590 IsArcKioskMode() || IsArcOptInVerificationDisabled()) {
593 StartArc(); 591 StartArc();
594 // Check Android management in parallel. 592 // Check Android management in parallel.
595 // Note: StartBackgroundAndroidManagementCheck() may call 593 // Note: StartBackgroundAndroidManagementCheck() may call
596 // OnBackgroundAndroidManagementChecked() synchronously (or 594 // OnBackgroundAndroidManagementChecked() synchronously (or
597 // asynchornously). In the callback, Google Play Store enabled preference 595 // asynchronously). In the callback, Google Play Store enabled preference
598 // can be set to false if managed, and it triggers RequestDisable() via 596 // can be set to false if managed, and it triggers RequestDisable() via
599 // ArcPlayStoreEnabledPreferenceHandler. 597 // ArcPlayStoreEnabledPreferenceHandler.
600 // Thus, StartArc() should be called so that disabling should work even 598 // Thus, StartArc() should be called so that disabling should work even
601 // if synchronous call case. 599 // if synchronous call case.
602 StartBackgroundAndroidManagementCheck(); 600 StartBackgroundAndroidManagementCheck();
603 return; 601 return;
604 } 602 }
605 603
606 MaybeStartTermsOfServiceNegotiation(); 604 MaybeStartTermsOfServiceNegotiation();
607 } 605 }
(...skipping 12 matching lines...) Expand all
620 // Reset any pending request to re-enable ARC. 618 // Reset any pending request to re-enable ARC.
621 reenable_arc_ = false; 619 reenable_arc_ = false;
622 StopArc(); 620 StopArc();
623 VLOG(1) << "ARC opt-out. Removing user data."; 621 VLOG(1) << "ARC opt-out. Removing user data.";
624 RequestArcDataRemoval(); 622 RequestArcDataRemoval();
625 } 623 }
626 624
627 void ArcSessionManager::RequestArcDataRemoval() { 625 void ArcSessionManager::RequestArcDataRemoval() {
628 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 626 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
629 DCHECK(profile_); 627 DCHECK(profile_);
630 // TODO(hidehiko): DCHECK the previous state. This is called for three cases; 628 // TODO(hidehiko): DCHECK the previous state. This is called for four cases;
631 // 1) Supporting managed user initial disabled case (Please see also 629 // 1) Supporting managed user initial disabled case (Please see also
632 // ArcPlayStoreEnabledPreferenceHandler::Start() for details). 630 // ArcPlayStoreEnabledPreferenceHandler::Start() for details).
633 // 2) Supporting enterprise triggered data removal. 631 // 2) Supporting enterprise triggered data removal.
634 // 3) One called in OnProvisioningFinished(). 632 // 3) One called in OnProvisioningFinished().
635 // 4) On request disabling. 633 // 4) On request disabling.
636 // After the state machine is fixed, 2) should be replaced by 634 // After the state machine is fixed, 2) should be replaced by
637 // RequestDisable() immediately followed by RequestEnable(). 635 // RequestDisable() immediately followed by RequestEnable().
638 // 3) and 4) are internal state transition. So, as for public interface, 1) 636 // 3) and 4) are internal state transition. So, as for public interface, 1)
639 // should be the only use case, and the |state_| should be limited to 637 // should be the only use case, and the |state_| should be limited to
640 // STOPPED, then. 638 // STOPPED, then.
(...skipping 18 matching lines...) Expand all
659 DCHECK(!IsArcKioskMode()); 657 DCHECK(!IsArcKioskMode());
660 // If opt-in verification is disabled, Terms of Service negotiation should 658 // If opt-in verification is disabled, Terms of Service negotiation should
661 // be skipped, too. See also RequestEnableImpl(). 659 // be skipped, too. See also RequestEnableImpl().
662 DCHECK(!IsArcOptInVerificationDisabled()); 660 DCHECK(!IsArcOptInVerificationDisabled());
663 661
664 // TODO(hidehiko): Remove this condition, when the state machine is fixed. 662 // TODO(hidehiko): Remove this condition, when the state machine is fixed.
665 if (!arc_session_runner_->IsStopped()) { 663 if (!arc_session_runner_->IsStopped()) {
666 // If the user attempts to re-enable ARC while the ARC instance is still 664 // If the user attempts to re-enable ARC while the ARC instance is still
667 // running the user should not be able to continue until the ARC instance 665 // running the user should not be able to continue until the ARC instance
668 // has stopped. 666 // has stopped.
669 if (support_host_) { 667 ShowArcSupportHostError(
670 support_host_->ShowError( 668 ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false);
671 ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false);
672 }
673 UpdateOptInCancelUMA(OptInCancelReason::SESSION_BUSY); 669 UpdateOptInCancelUMA(OptInCancelReason::SESSION_BUSY);
674 return; 670 return;
675 } 671 }
676 672
677 // TODO(hidehiko): DCHECK if |state_| is STOPPED, when the state machine 673 // TODO(hidehiko): DCHECK if |state_| is STOPPED, when the state machine
678 // is fixed. 674 // is fixed.
679 SetState(State::NEGOTIATING_TERMS_OF_SERVICE); 675 SetState(State::NEGOTIATING_TERMS_OF_SERVICE);
680 676
681 if (!scoped_opt_in_tracker_ && 677 if (!scoped_opt_in_tracker_ &&
682 !profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { 678 !profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 762
767 // Show loading UI only if ARC support app's window is already shown. 763 // Show loading UI only if ARC support app's window is already shown.
768 // User may not see any ARC support UI if everything needed is done in 764 // User may not see any ARC support UI if everything needed is done in
769 // background. In such a case, showing loading UI here (then closed sometime 765 // background. In such a case, showing loading UI here (then closed sometime
770 // soon later) would look just noisy. 766 // soon later) would look just noisy.
771 if (support_host_ && 767 if (support_host_ &&
772 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) { 768 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) {
773 support_host_->ShowArcLoading(); 769 support_host_->ShowArcLoading();
774 } 770 }
775 771
772 for (auto& observer : observer_list_)
773 observer.OnArcOptInManagementCheckStarted();
774
776 android_management_checker_ = base::MakeUnique<ArcAndroidManagementChecker>( 775 android_management_checker_ = base::MakeUnique<ArcAndroidManagementChecker>(
777 profile_, context_->token_service(), context_->account_id(), 776 profile_, context_->token_service(), context_->account_id(),
778 false /* retry_on_error */); 777 false /* retry_on_error */);
779 android_management_checker_->StartCheck( 778 android_management_checker_->StartCheck(
780 base::Bind(&ArcSessionManager::OnAndroidManagementChecked, 779 base::Bind(&ArcSessionManager::OnAndroidManagementChecked,
781 weak_ptr_factory_.GetWeakPtr())); 780 weak_ptr_factory_.GetWeakPtr()));
782 } 781 }
783 782
784 void ArcSessionManager::OnAndroidManagementChecked( 783 void ArcSessionManager::OnAndroidManagementChecked(
785 policy::AndroidManagementClient::Result result) { 784 policy::AndroidManagementClient::Result result) {
786 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 785 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
787 DCHECK_EQ(state_, State::CHECKING_ANDROID_MANAGEMENT); 786 DCHECK_EQ(state_, State::CHECKING_ANDROID_MANAGEMENT);
788 DCHECK(android_management_checker_); 787 DCHECK(android_management_checker_);
789 android_management_checker_.reset(); 788 android_management_checker_.reset();
790 789
791 switch (result) { 790 switch (result) {
792 case policy::AndroidManagementClient::Result::UNMANAGED: 791 case policy::AndroidManagementClient::Result::UNMANAGED:
793 VLOG(1) << "Starting ARC for first sign in."; 792 VLOG(1) << "Starting ARC for first sign in.";
794 sign_in_start_time_ = base::Time::Now(); 793 sign_in_start_time_ = base::Time::Now();
795 arc_sign_in_timer_.Start( 794 arc_sign_in_timer_.Start(
796 FROM_HERE, kArcSignInTimeout, 795 FROM_HERE, kArcSignInTimeout,
797 base::Bind(&ArcSessionManager::OnArcSignInTimeout, 796 base::Bind(&ArcSessionManager::OnArcSignInTimeout,
798 weak_ptr_factory_.GetWeakPtr())); 797 weak_ptr_factory_.GetWeakPtr()));
799 StartArc(); 798 StartArc();
800 break; 799 break;
801 case policy::AndroidManagementClient::Result::MANAGED: 800 case policy::AndroidManagementClient::Result::MANAGED:
802 if (support_host_) { 801 ShowArcSupportHostError(
803 support_host_->ShowError( 802 ArcSupportHost::Error::ANDROID_MANAGEMENT_REQUIRED_ERROR, false);
804 ArcSupportHost::Error::ANDROID_MANAGEMENT_REQUIRED_ERROR, false);
805 }
806 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED); 803 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED);
807 break; 804 break;
808 case policy::AndroidManagementClient::Result::ERROR: 805 case policy::AndroidManagementClient::Result::ERROR:
809 if (support_host_) { 806 ShowArcSupportHostError(ArcSupportHost::Error::SERVER_COMMUNICATION_ERROR,
810 support_host_->ShowError( 807 true);
811 ArcSupportHost::Error::SERVER_COMMUNICATION_ERROR, true);
812 }
813 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 808 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
814 break; 809 break;
815 } 810 }
816 } 811 }
817 812
818 void ArcSessionManager::StartBackgroundAndroidManagementCheck() { 813 void ArcSessionManager::StartBackgroundAndroidManagementCheck() {
819 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 814 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
820 DCHECK_EQ(state_, State::ACTIVE); 815 DCHECK_EQ(state_, State::ACTIVE);
821 DCHECK(!android_management_checker_); 816 DCHECK(!android_management_checker_);
822 817
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 arc_session_runner_ = std::move(arc_session_runner); 1018 arc_session_runner_ = std::move(arc_session_runner);
1024 arc_session_runner_->AddObserver(this); 1019 arc_session_runner_->AddObserver(this);
1025 } 1020 }
1026 1021
1027 void ArcSessionManager::SetAttemptUserExitCallbackForTesting( 1022 void ArcSessionManager::SetAttemptUserExitCallbackForTesting(
1028 const base::Closure& callback) { 1023 const base::Closure& callback) {
1029 DCHECK(!callback.is_null()); 1024 DCHECK(!callback.is_null());
1030 attempt_user_exit_callback_ = callback; 1025 attempt_user_exit_callback_ = callback;
1031 } 1026 }
1032 1027
1028 void ArcSessionManager::ShowArcSupportHostError(
1029 ArcSupportHost::Error error,
1030 bool should_show_send_feedback) {
1031 if (support_host_)
1032 support_host_->ShowError(error, should_show_send_feedback);
1033 for (auto& observer : observer_list_)
1034 observer.OnArcErrorShowRequested(error);
1035 }
1036
1033 std::ostream& operator<<(std::ostream& os, 1037 std::ostream& operator<<(std::ostream& os,
1034 const ArcSessionManager::State& state) { 1038 const ArcSessionManager::State& state) {
1035 #define MAP_STATE(name) \ 1039 #define MAP_STATE(name) \
1036 case ArcSessionManager::State::name: \ 1040 case ArcSessionManager::State::name: \
1037 return os << #name 1041 return os << #name
1038 1042
1039 switch (state) { 1043 switch (state) {
1040 MAP_STATE(NOT_INITIALIZED); 1044 MAP_STATE(NOT_INITIALIZED);
1041 MAP_STATE(STOPPED); 1045 MAP_STATE(STOPPED);
1042 MAP_STATE(NEGOTIATING_TERMS_OF_SERVICE); 1046 MAP_STATE(NEGOTIATING_TERMS_OF_SERVICE);
1043 MAP_STATE(CHECKING_ANDROID_MANAGEMENT); 1047 MAP_STATE(CHECKING_ANDROID_MANAGEMENT);
1044 MAP_STATE(REMOVING_DATA_DIR); 1048 MAP_STATE(REMOVING_DATA_DIR);
1045 MAP_STATE(ACTIVE); 1049 MAP_STATE(ACTIVE);
1046 } 1050 }
1047 1051
1048 #undef MAP_STATE 1052 #undef MAP_STATE
1049 1053
1050 // Some compilers report an error even if all values of an enum-class are 1054 // Some compilers report an error even if all values of an enum-class are
1051 // covered exhaustively in a switch statement. 1055 // covered exhaustively in a switch statement.
1052 NOTREACHED() << "Invalid value " << static_cast<int>(state); 1056 NOTREACHED() << "Invalid value " << static_cast<int>(state);
1053 return os; 1057 return os;
1054 } 1058 }
1055 1059
1056 } // namespace arc 1060 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698