Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/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" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 | 57 |
| 58 // The Android management check is disabled by default, it's used only for | 58 // The Android management check is disabled by default, it's used only for |
| 59 // testing. | 59 // testing. |
| 60 bool g_enable_check_android_management_for_testing = false; | 60 bool g_enable_check_android_management_for_testing = false; |
| 61 | 61 |
| 62 // Maximum amount of time we'll wait for ARC to finish booting up. Once this | 62 // Maximum amount of time we'll wait for ARC to finish booting up. Once this |
| 63 // timeout expires, keep ARC running in case the user wants to file feedback, | 63 // timeout expires, keep ARC running in case the user wants to file feedback, |
| 64 // but present the UI to try again. | 64 // but present the UI to try again. |
| 65 constexpr base::TimeDelta kArcSignInTimeout = base::TimeDelta::FromMinutes(5); | 65 constexpr base::TimeDelta kArcSignInTimeout = base::TimeDelta::FromMinutes(5); |
| 66 | 66 |
| 67 // Update UMA with user cancel only if error is not currently shown. | |
|
Yusuke Sato
2017/03/06 20:52:16
Updates
hidehiko
2017/03/07 14:52:20
Done.
| |
| 68 void MaybeUpdateOptInCancelUMA(const ArcSupportHost* support_host) { | |
| 69 if (!support_host || | |
| 70 support_host->ui_page() == ArcSupportHost::UIPage::NO_PAGE || | |
| 71 support_host->ui_page() == ArcSupportHost::UIPage::ERROR) { | |
| 72 return; | |
| 73 } | |
| 74 | |
| 75 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL); | |
| 76 } | |
| 77 | |
| 67 } // namespace | 78 } // namespace |
| 68 | 79 |
| 69 ArcSessionManager::ArcSessionManager( | 80 ArcSessionManager::ArcSessionManager( |
| 70 std::unique_ptr<ArcSessionRunner> arc_session_runner) | 81 std::unique_ptr<ArcSessionRunner> arc_session_runner) |
| 71 : arc_session_runner_(std::move(arc_session_runner)), | 82 : arc_session_runner_(std::move(arc_session_runner)), |
| 72 attempt_user_exit_callback_(base::Bind(chrome::AttemptUserExit)), | 83 attempt_user_exit_callback_(base::Bind(chrome::AttemptUserExit)), |
| 73 weak_ptr_factory_(this) { | 84 weak_ptr_factory_(this) { |
| 74 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 85 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 75 DCHECK(!g_arc_session_manager); | 86 DCHECK(!g_arc_session_manager); |
| 76 g_arc_session_manager = this; | 87 g_arc_session_manager = this; |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 | 514 |
| 504 if (state_ == State::NOT_INITIALIZED) { | 515 if (state_ == State::NOT_INITIALIZED) { |
| 505 NOTREACHED(); | 516 NOTREACHED(); |
| 506 return; | 517 return; |
| 507 } | 518 } |
| 508 | 519 |
| 509 // If ARC failed to boot normally, stop ARC. Similarly, if the current page is | 520 // If ARC failed to boot normally, stop ARC. Similarly, if the current page is |
| 510 // LSO, closing the window should stop ARC since the user activity chooses to | 521 // LSO, closing the window should stop ARC since the user activity chooses to |
| 511 // not sign in. In any other case, ARC is booting normally and the instance | 522 // not sign in. In any other case, ARC is booting normally and the instance |
| 512 // should not be stopped. | 523 // should not be stopped. |
| 513 if ((state_ != State::SHOWING_TERMS_OF_SERVICE && | 524 if ((state_ != State::NEGOTIATING_TERMS_OF_SERVICE && |
| 514 state_ != State::CHECKING_ANDROID_MANAGEMENT) && | 525 state_ != State::CHECKING_ANDROID_MANAGEMENT) && |
| 515 (!support_host_ || | 526 (!support_host_ || |
| 516 (support_host_->ui_page() != ArcSupportHost::UIPage::ERROR && | 527 (support_host_->ui_page() != ArcSupportHost::UIPage::ERROR && |
| 517 support_host_->ui_page() != ArcSupportHost::UIPage::LSO))) { | 528 support_host_->ui_page() != ArcSupportHost::UIPage::LSO))) { |
| 518 return; | 529 return; |
| 519 } | 530 } |
| 520 | 531 |
| 521 // Update UMA with user cancel only if error is not currently shown. | 532 MaybeUpdateOptInCancelUMA(support_host_.get()); |
| 522 if (support_host_ && | |
| 523 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE && | |
| 524 support_host_->ui_page() != ArcSupportHost::UIPage::ERROR) { | |
| 525 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL); | |
| 526 } | |
| 527 | |
| 528 StopArc(); | 533 StopArc(); |
| 529 SetArcPlayStoreEnabledForProfile(profile_, false); | 534 SetArcPlayStoreEnabledForProfile(profile_, false); |
| 530 } | 535 } |
| 531 | 536 |
| 532 void ArcSessionManager::RecordArcState() { | 537 void ArcSessionManager::RecordArcState() { |
| 533 // Only record Enabled state if ARC is allowed in the first place, so we do | 538 // Only record Enabled state if ARC is allowed in the first place, so we do |
| 534 // not split the ARC population by devices that cannot run ARC. | 539 // not split the ARC population by devices that cannot run ARC. |
| 535 if (IsAllowed()) | 540 if (IsAllowed()) |
| 536 UpdateEnabledStateUMA(enable_requested_); | 541 UpdateEnabledStateUMA(enable_requested_); |
| 537 } | 542 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 561 | 566 |
| 562 if (state_ == State::REMOVING_DATA_DIR) { | 567 if (state_ == State::REMOVING_DATA_DIR) { |
| 563 // Data removal request is in progress. Set flag to re-enable ARC once it | 568 // Data removal request is in progress. Set flag to re-enable ARC once it |
| 564 // is finished. | 569 // is finished. |
| 565 reenable_arc_ = true; | 570 reenable_arc_ = true; |
| 566 return; | 571 return; |
| 567 } | 572 } |
| 568 | 573 |
| 569 PrefService* const prefs = profile_->GetPrefs(); | 574 PrefService* const prefs = profile_->GetPrefs(); |
| 570 | 575 |
| 571 // For ARC Kiosk we skip ToS because it is very likely that near the device | |
| 572 // there will be no one who is eligible to accept them. | |
| 573 // TODO(poromov): Move to more Kiosk dedicated set-up phase. | |
| 574 if (IsArcKioskMode()) | |
| 575 prefs->SetBoolean(prefs::kArcTermsAccepted, true); | |
| 576 | |
| 577 // Skip to show UI asking users to set up ARC OptIn preferences, if all of | |
| 578 // them are managed by the admin policy. Note that the ToS agreement is anyway | |
| 579 // not shown in the case of the managed ARC. | |
| 580 if (AreArcAllOptInPreferencesManaged()) | |
| 581 prefs->SetBoolean(prefs::kArcTermsAccepted, true); | |
| 582 | |
| 583 // If it is marked that sign in has been successfully done, then directly | 576 // If it is marked that sign in has been successfully done, then directly |
| 584 // start ARC. | 577 // start ARC. |
| 585 // For testing, and for Kiosk mode, we also skip ToS negotiation procedure. | 578 // For testing, and for Kiosk mode, we also skip ToS negotiation procedure. |
| 586 // For backward compatibility, this check needs to be prior to the | 579 // For backward compatibility, this check needs to be prior to the |
| 587 // kArcTermsAccepted check below. | 580 // kArcTermsAccepted check below. |
|
Yusuke Sato
2017/03/06 20:52:16
"below" is ambiguous now. Can you rephrase?
hidehiko
2017/03/07 14:52:20
The comment looks obsolete, so fully rewrote.
To f
| |
| 588 if (prefs->GetBoolean(prefs::kArcSignedIn) || | 581 if (prefs->GetBoolean(prefs::kArcSignedIn) || |
| 589 IsArcOptInVerificationDisabled() || IsArcKioskMode()) { | 582 IsArcOptInVerificationDisabled() || IsArcKioskMode()) { |
| 590 StartArc(); | 583 StartArc(); |
| 591 | 584 |
| 592 // Skip Android management check for testing. | 585 // Skip Android management check for testing. |
| 593 // We also skip if Android management check for Kiosk mode, | 586 // We also skip if Android management check for Kiosk mode, |
| 594 // because there are no managed human users for Kiosk exist. | 587 // because there are no managed human users for Kiosk exist. |
| 595 if (IsArcOptInVerificationDisabled() || IsArcKioskMode() || | 588 if (IsArcOptInVerificationDisabled() || IsArcKioskMode() || |
| 596 (g_disable_ui_for_testing && | 589 (g_disable_ui_for_testing && |
| 597 !g_enable_check_android_management_for_testing)) { | 590 !g_enable_check_android_management_for_testing)) { |
| 598 return; | 591 return; |
| 599 } | 592 } |
| 600 | 593 |
| 601 // Check Android management in parallel. | 594 // Check Android management in parallel. |
|
Yusuke Sato
2017/03/06 20:52:16
Can you factor out L594-604 too? Since you have Ar
Yusuke Sato
2017/03/06 22:04:56
Just noticed you're doing it in another CL already
hidehiko
2017/03/07 14:52:20
Yes, it's done. Thank you for review for the CL, t
| |
| 602 // Note: Because the callback may be called in synchronous way (i.e. called | 595 // Note: Because the callback may be called in synchronous way (i.e. called |
| 603 // on the same stack), StartCheck() needs to be called *after* StartArc(). | 596 // on the same stack), StartCheck() needs to be called *after* StartArc(). |
| 604 // Otherwise, SetArcPlayStoreEnabledForProfile() which may be called in | 597 // Otherwise, SetArcPlayStoreEnabledForProfile() which may be called in |
| 605 // OnBackgroundAndroidManagementChecked() could be ignored. | 598 // OnBackgroundAndroidManagementChecked() could be ignored. |
| 606 android_management_checker_ = base::MakeUnique<ArcAndroidManagementChecker>( | 599 android_management_checker_ = base::MakeUnique<ArcAndroidManagementChecker>( |
| 607 profile_, context_->token_service(), context_->account_id(), | 600 profile_, context_->token_service(), context_->account_id(), |
| 608 true /* retry_on_error */); | 601 true /* retry_on_error */); |
| 609 android_management_checker_->StartCheck( | 602 android_management_checker_->StartCheck( |
| 610 base::Bind(&ArcSessionManager::OnBackgroundAndroidManagementChecked, | 603 base::Bind(&ArcSessionManager::OnBackgroundAndroidManagementChecked, |
| 611 weak_ptr_factory_.GetWeakPtr())); | 604 weak_ptr_factory_.GetWeakPtr())); |
| 612 return; | 605 return; |
| 613 } | 606 } |
| 614 | 607 |
| 615 // If it is marked that the Terms of service is accepted already, | |
| 616 // just skip the negotiation with user, and start Android management | |
| 617 // check directly. | |
| 618 // This happens, e.g., when; | |
| 619 // 1) User accepted the Terms of service on OOBE flow. | |
| 620 // 2) User accepted the Terms of service on Opt-in flow, but logged out | |
| 621 // before ARC sign in procedure was done. Then, logs in again. | |
| 622 if (prefs->GetBoolean(prefs::kArcTermsAccepted)) { | |
| 623 // Don't show UI for this progress if it was not shown. | |
| 624 if (support_host_ && | |
| 625 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) { | |
| 626 support_host_->ShowArcLoading(); | |
| 627 } | |
| 628 StartArcAndroidManagementCheck(); | |
| 629 return; | |
| 630 } | |
| 631 | |
| 632 StartTermsOfServiceNegotiation(); | 608 StartTermsOfServiceNegotiation(); |
| 633 } | 609 } |
| 634 | 610 |
| 635 void ArcSessionManager::RequestDisable() { | 611 void ArcSessionManager::RequestDisable() { |
| 636 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 612 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 637 DCHECK(profile_); | 613 DCHECK(profile_); |
| 638 | 614 |
| 639 if (!enable_requested_) { | 615 if (!enable_requested_) { |
| 640 VLOG(1) << "ARC is already disabled. Do nothing."; | 616 VLOG(1) << "ARC is already disabled. Do nothing."; |
| 641 return; | 617 return; |
| 642 } | 618 } |
| 643 enable_requested_ = false; | 619 enable_requested_ = false; |
| 644 | 620 |
| 645 // Reset any pending request to re-enable ARC. | 621 // Reset any pending request to re-enable ARC. |
| 646 VLOG(1) << "ARC opt-out. Removing user data."; | 622 VLOG(1) << "ARC opt-out. Removing user data."; |
| 647 reenable_arc_ = false; | 623 reenable_arc_ = false; |
| 648 StopArc(); | 624 StopArc(); |
| 649 RemoveArcData(); | 625 RemoveArcData(); |
| 650 } | 626 } |
| 651 | 627 |
| 652 void ArcSessionManager::StartTermsOfServiceNegotiation() { | 628 void ArcSessionManager::StartTermsOfServiceNegotiation() { |
| 653 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 629 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 630 DCHECK(profile_); | |
| 654 DCHECK(!terms_of_service_negotiator_); | 631 DCHECK(!terms_of_service_negotiator_); |
| 655 | 632 |
| 633 // TODO(hidehiko): Remove this condition, when the state machine is fixed. | |
| 656 if (!arc_session_runner_->IsStopped()) { | 634 if (!arc_session_runner_->IsStopped()) { |
| 657 // If the user attempts to re-enable ARC while the ARC instance is still | 635 // If the user attempts to re-enable ARC while the ARC instance is still |
| 658 // running the user should not be able to continue until the ARC instance | 636 // running the user should not be able to continue until the ARC instance |
| 659 // has stopped. | 637 // has stopped. |
| 660 if (support_host_) { | 638 if (support_host_) { |
| 661 support_host_->ShowError( | 639 support_host_->ShowError( |
| 662 ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false); | 640 ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false); |
| 663 } | 641 } |
| 664 return; | 642 return; |
| 665 } | 643 } |
| 666 | 644 |
| 667 SetState(State::SHOWING_TERMS_OF_SERVICE); | 645 // TODO(hidehiko): DCHECK if |state_| is STOPPED, when the state machine |
| 646 // is fixed. | |
| 647 SetState(State::NEGOTIATING_TERMS_OF_SERVICE); | |
| 648 | |
| 649 if (!IsArcTermsOfServiceNegotiationNeeded()) { | |
| 650 // Moves to next state, Android management check, immediately, as if | |
| 651 // Terms of Service negotiation is done successfully. | |
| 652 StartArcAndroidManagementCheck(); | |
| 653 return; | |
| 654 } | |
| 655 | |
| 668 if (IsOobeOptInActive()) { | 656 if (IsOobeOptInActive()) { |
| 669 VLOG(1) << "Use OOBE negotiator."; | 657 VLOG(1) << "Use OOBE negotiator."; |
| 670 terms_of_service_negotiator_ = | 658 terms_of_service_negotiator_ = |
| 671 base::MakeUnique<ArcTermsOfServiceOobeNegotiator>(); | 659 base::MakeUnique<ArcTermsOfServiceOobeNegotiator>(); |
| 672 } else if (support_host_) { | 660 } else if (support_host_) { |
| 673 VLOG(1) << "Use default negotiator."; | 661 VLOG(1) << "Use default negotiator."; |
| 674 terms_of_service_negotiator_ = | 662 terms_of_service_negotiator_ = |
| 675 base::MakeUnique<ArcTermsOfServiceDefaultNegotiator>( | 663 base::MakeUnique<ArcTermsOfServiceDefaultNegotiator>( |
| 676 profile_->GetPrefs(), support_host_.get()); | 664 profile_->GetPrefs(), support_host_.get()); |
| 677 } | 665 } |
| 678 | 666 |
| 679 if (terms_of_service_negotiator_) { | 667 if (terms_of_service_negotiator_) { |
|
Yusuke Sato
2017/03/06 20:52:16
It was unclear to me when this variable can be a n
hidehiko
2017/03/07 14:52:20
Yes, it's testing purpose.
Added comment with DCHE
| |
| 680 terms_of_service_negotiator_->StartNegotiation( | 668 terms_of_service_negotiator_->StartNegotiation( |
| 681 base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated, | 669 base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated, |
| 682 weak_ptr_factory_.GetWeakPtr())); | 670 weak_ptr_factory_.GetWeakPtr())); |
| 683 } | 671 } |
| 684 } | 672 } |
| 685 | 673 |
| 686 void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) { | 674 void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) { |
| 675 DCHECK_EQ(state_, State::NEGOTIATING_TERMS_OF_SERVICE); | |
| 676 DCHECK(profile_); | |
| 687 DCHECK(terms_of_service_negotiator_); | 677 DCHECK(terms_of_service_negotiator_); |
| 688 terms_of_service_negotiator_.reset(); | 678 terms_of_service_negotiator_.reset(); |
| 689 | 679 |
| 690 if (!accepted) { | 680 if (!accepted) { |
| 691 // To cancel, user needs to close the window. Note that clicking "Cancel" | 681 // User does not accept the Terms of Service. Disable Google Play Store. |
| 692 // button effectively just closes the window. | 682 MaybeUpdateOptInCancelUMA(support_host_.get()); |
| 693 CancelAuthCode(); | 683 SetArcPlayStoreEnabledForProfile(profile_, false); |
| 694 return; | 684 return; |
| 695 } | 685 } |
| 696 | 686 |
| 697 // Terms were accepted. | 687 // Terms were accepted. |
| 698 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); | 688 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); |
| 689 StartArcAndroidManagementCheck(); | |
| 690 } | |
| 699 | 691 |
| 700 // Don't show UI for this progress if it was not shown. | 692 bool ArcSessionManager::IsArcTermsOfServiceNegotiationNeeded() const { |
| 701 if (support_host_ && | 693 DCHECK(profile_); |
| 702 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) | 694 |
| 703 support_host_->ShowArcLoading(); | 695 // For ARC Kiosk we skip ToS because it is very likely that near the device |
| 704 StartArcAndroidManagementCheck(); | 696 // there will be no one who is eligible to accept them. |
| 697 if (IsArcKioskMode()) { | |
|
Yusuke Sato
2017/03/06 20:52:16
When is this check necessary? Because of the IsArc
hidehiko
2017/03/07 14:52:20
Good catch!
So, I removed this from here, and adde
| |
| 698 VLOG(1) << "In Kiosk mode. Skip ARC Terms of Service negotiation."; | |
| 699 return false; | |
| 700 } | |
| 701 | |
| 702 // Skip to show UI asking users to set up ARC OptIn preferences, if all of | |
| 703 // them are managed by the admin policy. Note that the ToS agreement is anyway | |
| 704 // not shown in the case of the managed ARC. | |
| 705 if (AreArcAllOptInPreferencesManaged()) { | |
|
hidehiko
2017/03/06 13:38:39
Note: crrev.com/2731453003 moves the utility to c/
| |
| 706 VLOG(1) << "All opt-in preferences are under managed. " | |
| 707 << "Skip ARC Terms of Service negotiation."; | |
| 708 return false; | |
| 709 } | |
| 710 | |
| 711 // If it is marked that the Terms of service is accepted already, | |
| 712 // just skip the negotiation with user, and start Android management | |
| 713 // check directly. | |
| 714 // This happens, e.g., when a user accepted the Terms of service on Opt-in | |
|
hidehiko
2017/03/06 13:38:39
Note: 1) of the original comment is obsolete. khme
| |
| 715 // flow, but logged out before ARC sign in procedure was done. Then, logs | |
| 716 // in again. | |
| 717 if (profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) { | |
| 718 VLOG(1) << "The user already accepts ARC Terms of Service."; | |
| 719 return false; | |
| 720 } | |
| 721 | |
| 722 return true; | |
| 705 } | 723 } |
| 706 | 724 |
| 707 bool ArcSessionManager::AreArcAllOptInPreferencesManaged() const { | 725 bool ArcSessionManager::AreArcAllOptInPreferencesManaged() const { |
| 708 return IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_) && | 726 return IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_) && |
| 709 profile_->GetPrefs()->IsManagedPreference( | 727 profile_->GetPrefs()->IsManagedPreference( |
| 710 prefs::kArcBackupRestoreEnabled) && | 728 prefs::kArcBackupRestoreEnabled) && |
| 711 profile_->GetPrefs()->IsManagedPreference( | 729 profile_->GetPrefs()->IsManagedPreference( |
| 712 prefs::kArcLocationServiceEnabled); | 730 prefs::kArcLocationServiceEnabled); |
| 713 } | 731 } |
| 714 | 732 |
| 715 void ArcSessionManager::StartArcAndroidManagementCheck() { | 733 void ArcSessionManager::StartArcAndroidManagementCheck() { |
| 716 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 734 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 717 DCHECK(arc_session_runner_->IsStopped()); | 735 DCHECK(arc_session_runner_->IsStopped()); |
| 718 DCHECK(state_ == State::SHOWING_TERMS_OF_SERVICE || | 736 DCHECK(state_ == State::NEGOTIATING_TERMS_OF_SERVICE || |
| 719 state_ == State::CHECKING_ANDROID_MANAGEMENT || | 737 state_ == State::CHECKING_ANDROID_MANAGEMENT); |
| 720 (state_ == State::STOPPED && | |
| 721 profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted))); | |
| 722 SetState(State::CHECKING_ANDROID_MANAGEMENT); | 738 SetState(State::CHECKING_ANDROID_MANAGEMENT); |
| 723 | 739 |
| 740 // Don't show UI for this progress if it was not shown. | |
|
victorhsieh
2017/03/06 23:11:52
optional: I'm doing the same thing locally, and I
hidehiko
2017/03/07 14:52:20
Rephrased for positive case, with its background.
| |
| 741 if (support_host_ && | |
| 742 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) { | |
| 743 support_host_->ShowArcLoading(); | |
| 744 } | |
| 745 | |
| 724 android_management_checker_.reset(new ArcAndroidManagementChecker( | 746 android_management_checker_.reset(new ArcAndroidManagementChecker( |
|
Yusuke Sato
2017/03/06 20:52:16
MakeUnique? (L317 too)
hidehiko
2017/03/07 14:52:20
Done in another CL. As for L317, I'm making anothe
| |
| 725 profile_, context_->token_service(), context_->account_id(), | 747 profile_, context_->token_service(), context_->account_id(), |
| 726 false /* retry_on_error */)); | 748 false /* retry_on_error */)); |
| 727 android_management_checker_->StartCheck( | 749 android_management_checker_->StartCheck( |
| 728 base::Bind(&ArcSessionManager::OnAndroidManagementChecked, | 750 base::Bind(&ArcSessionManager::OnAndroidManagementChecked, |
| 729 weak_ptr_factory_.GetWeakPtr())); | 751 weak_ptr_factory_.GetWeakPtr())); |
| 730 } | 752 } |
| 731 | 753 |
| 732 void ArcSessionManager::OnAndroidManagementChecked( | 754 void ArcSessionManager::OnAndroidManagementChecked( |
| 733 policy::AndroidManagementClient::Result result) { | 755 policy::AndroidManagementClient::Result result) { |
| 734 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 756 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 842 support_host_->ShowArcLoading(); | 864 support_host_->ShowArcLoading(); |
| 843 ShutdownSession(); | 865 ShutdownSession(); |
| 844 reenable_arc_ = true; | 866 reenable_arc_ = true; |
| 845 } else if (state_ == State::ACTIVE) { | 867 } else if (state_ == State::ACTIVE) { |
| 846 // This case is handled in ArcAuthService. | 868 // This case is handled in ArcAuthService. |
| 847 // Do nothing. | 869 // Do nothing. |
| 848 } else { | 870 } else { |
| 849 // Otherwise, we restart ARC. Note: this is the first boot case. | 871 // Otherwise, we restart ARC. Note: this is the first boot case. |
| 850 // For second or later boot, either ERROR_WITH_FEEDBACK case or ACTIVE | 872 // For second or later boot, either ERROR_WITH_FEEDBACK case or ACTIVE |
| 851 // case must hit. | 873 // case must hit. |
| 852 support_host_->ShowArcLoading(); | |
| 853 StartArcAndroidManagementCheck(); | 874 StartArcAndroidManagementCheck(); |
| 854 } | 875 } |
| 855 } | 876 } |
| 856 | 877 |
| 857 void ArcSessionManager::OnSendFeedbackClicked() { | 878 void ArcSessionManager::OnSendFeedbackClicked() { |
| 858 DCHECK(support_host_); | 879 DCHECK(support_host_); |
| 859 chrome::OpenFeedbackDialog(nullptr); | 880 chrome::OpenFeedbackDialog(nullptr); |
| 860 } | 881 } |
| 861 | 882 |
| 862 void ArcSessionManager::SetArcSessionRunnerForTesting( | 883 void ArcSessionManager::SetArcSessionRunnerForTesting( |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 877 | 898 |
| 878 std::ostream& operator<<(std::ostream& os, | 899 std::ostream& operator<<(std::ostream& os, |
| 879 const ArcSessionManager::State& state) { | 900 const ArcSessionManager::State& state) { |
| 880 #define MAP_STATE(name) \ | 901 #define MAP_STATE(name) \ |
| 881 case ArcSessionManager::State::name: \ | 902 case ArcSessionManager::State::name: \ |
| 882 return os << #name | 903 return os << #name |
| 883 | 904 |
| 884 switch (state) { | 905 switch (state) { |
| 885 MAP_STATE(NOT_INITIALIZED); | 906 MAP_STATE(NOT_INITIALIZED); |
| 886 MAP_STATE(STOPPED); | 907 MAP_STATE(STOPPED); |
| 887 MAP_STATE(SHOWING_TERMS_OF_SERVICE); | 908 MAP_STATE(NEGOTIATING_TERMS_OF_SERVICE); |
| 888 MAP_STATE(CHECKING_ANDROID_MANAGEMENT); | 909 MAP_STATE(CHECKING_ANDROID_MANAGEMENT); |
| 889 MAP_STATE(REMOVING_DATA_DIR); | 910 MAP_STATE(REMOVING_DATA_DIR); |
| 890 MAP_STATE(ACTIVE); | 911 MAP_STATE(ACTIVE); |
| 891 } | 912 } |
| 892 | 913 |
| 893 #undef MAP_STATE | 914 #undef MAP_STATE |
| 894 | 915 |
| 895 // Some compilers report an error even if all values of an enum-class are | 916 // Some compilers report an error even if all values of an enum-class are |
| 896 // covered exhaustively in a switch statement. | 917 // covered exhaustively in a switch statement. |
| 897 NOTREACHED() << "Invalid value " << static_cast<int>(state); | 918 NOTREACHED() << "Invalid value " << static_cast<int>(state); |
| 898 return os; | 919 return os; |
| 899 } | 920 } |
| 900 | 921 |
| 901 } // namespace arc | 922 } // namespace arc |
| OLD | NEW |