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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 ash::ShelfDelegate* GetShelfDelegate() { | 71 ash::ShelfDelegate* GetShelfDelegate() { |
| 72 if (g_shelf_delegate_for_testing) | 72 if (g_shelf_delegate_for_testing) |
| 73 return g_shelf_delegate_for_testing; | 73 return g_shelf_delegate_for_testing; |
| 74 if (ash::WmShell::HasInstance()) { | 74 if (ash::WmShell::HasInstance()) { |
| 75 DCHECK(ash::WmShell::Get()->shelf_delegate()); | 75 DCHECK(ash::WmShell::Get()->shelf_delegate()); |
| 76 return ash::WmShell::Get()->shelf_delegate(); | 76 return ash::WmShell::Get()->shelf_delegate(); |
| 77 } | 77 } |
| 78 return nullptr; | 78 return nullptr; |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool IsFirstRunForUser() { | |
|
hidehiko
2016/12/09 06:59:57
The name looks not reflecting what this does, beca
khmel
2016/12/14 01:27:59
Nice name, thanks!
| |
| 82 // Arc OOBE OptIn is optional for now. Test if it exists and current user is | |
|
hidehiko
2016/12/09 06:59:57
s/Arc/ARC/ for all comments in the CL, including C
khmel
2016/12/14 01:27:59
Done.
| |
| 83 // first time user. | |
| 84 return user_manager::UserManager::Get()->IsCurrentUserNew() && | |
| 85 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 86 chromeos::switches::kEnableArcOOBEOptIn); | |
| 87 } | |
| 88 | |
| 81 } // namespace | 89 } // namespace |
| 82 | 90 |
| 83 ArcSessionManager::ArcSessionManager(ArcBridgeService* bridge_service) | 91 ArcSessionManager::ArcSessionManager(ArcBridgeService* bridge_service) |
| 84 : ArcService(bridge_service), weak_ptr_factory_(this) { | 92 : ArcService(bridge_service), weak_ptr_factory_(this) { |
| 85 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 93 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 86 DCHECK(!g_arc_session_manager); | 94 DCHECK(!g_arc_session_manager); |
| 87 g_arc_session_manager = this; | 95 g_arc_session_manager = this; |
| 88 | 96 |
| 89 arc_bridge_service()->AddObserver(this); | 97 arc_bridge_service()->AddObserver(this); |
| 90 } | 98 } |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 } | 604 } |
| 597 | 605 |
| 598 // If it is marked that the Terms of service is accepted already, | 606 // If it is marked that the Terms of service is accepted already, |
| 599 // just skip the negotiation with user, and start Android management | 607 // just skip the negotiation with user, and start Android management |
| 600 // check directly. | 608 // check directly. |
| 601 // This happens, e.g., when; | 609 // This happens, e.g., when; |
| 602 // 1) User accepted the Terms of service on OOBE flow. | 610 // 1) User accepted the Terms of service on OOBE flow. |
| 603 // 2) User accepted the Terms of service on Opt-in flow, but logged out | 611 // 2) User accepted the Terms of service on Opt-in flow, but logged out |
| 604 // before ARC sign in procedure was done. Then, logs in again. | 612 // before ARC sign in procedure was done. Then, logs in again. |
| 605 if (profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) { | 613 if (profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) { |
| 606 support_host_->ShowArcLoading(); | 614 // In case this is after OOBE, don't show the initial progress. |
| 615 if (!IsFirstRunForUser()) | |
|
xiyuan
2016/12/09 00:01:45
This changes the existing behavior.
For OOBE Opt
hidehiko
2016/12/09 06:59:57
I'm confused.
IIUC;
OnPrimaryUserProfilePrepared
khmel
2016/12/14 01:27:59
ARC OptIn OOBE is shown only for first time user.
khmel
2016/12/14 01:27:59
That is good point and in theory it is true :), ho
| |
| 616 support_host_->ShowArcLoading(); | |
| 607 StartArcAndroidManagementCheck(); | 617 StartArcAndroidManagementCheck(); |
| 608 return; | 618 return; |
| 609 } | 619 } |
| 610 | 620 |
| 611 // Need user's explicit Terms Of Service agreement. | 621 // Need user's explicit Terms Of Service agreement. In case Arc is managed and |
| 612 StartTermsOfServiceNegotiation(); | 622 // forced to on, check if this is first time run. First time run is covered by |
| 623 // OOBE OptIn. In last case observe terms accepted change in order to start | |
| 624 // Arc when required. | |
| 625 if (IsArcManaged() && IsFirstRunForUser()) { | |
|
hidehiko
2016/12/09 06:59:57
This condition looks very complicated to me.
Could
khmel
2016/12/14 01:27:59
I changed code to negotiator based solution. So th
| |
| 626 pref_change_registrar_.Add( | |
|
xiyuan
2016/12/09 00:01:45
nit: move into StartTermsOfServiceNegotiation() si
khmel
2016/12/14 01:27:59
That is right, Done.
| |
| 627 prefs::kArcTermsAccepted, | |
| 628 base::Bind(&ArcSessionManager::OnTermsAcceptedPreferenceChanged, | |
| 629 weak_ptr_factory_.GetWeakPtr())); | |
| 630 } else { | |
| 631 StartTermsOfServiceNegotiation(); | |
| 632 } | |
| 633 } | |
| 634 | |
| 635 void ArcSessionManager::OnTermsAcceptedPreferenceChanged() { | |
| 636 if (profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) | |
|
xiyuan
2016/12/09 00:01:45
Why do we need to bail and keep observing kArcTerm
khmel
2016/12/14 01:27:59
Agree, this is misprint. However it used to work i
| |
| 637 return; | |
| 638 pref_change_registrar_.Remove(prefs::kArcTermsAccepted); | |
| 639 | |
| 640 DCHECK(IsArcManaged() && IsArcEnabled()); | |
|
hidehiko
2016/12/09 06:59:57
nit: please split DCHECK().
DCHECK(IsArcManaged())
khmel
2016/12/14 01:27:59
This code is discarded.
| |
| 641 OnOptInPreferenceChanged(); | |
| 613 } | 642 } |
| 614 | 643 |
| 615 void ArcSessionManager::ShutdownBridge() { | 644 void ArcSessionManager::ShutdownBridge() { |
| 616 arc_sign_in_timer_.Stop(); | 645 arc_sign_in_timer_.Stop(); |
| 617 playstore_launcher_.reset(); | 646 playstore_launcher_.reset(); |
| 618 terms_of_service_negotiator_.reset(); | 647 terms_of_service_negotiator_.reset(); |
| 619 android_management_checker_.reset(); | 648 android_management_checker_.reset(); |
| 620 arc_bridge_service()->RequestStop(); | 649 arc_bridge_service()->RequestStop(); |
| 621 if (state_ != State::NOT_INITIALIZED && state_ != State::REMOVING_DATA_DIR) | 650 if (state_ != State::NOT_INITIALIZED && state_ != State::REMOVING_DATA_DIR) |
| 622 SetState(State::STOPPED); | 651 SetState(State::STOPPED); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 774 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); | 803 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); |
| 775 | 804 |
| 776 support_host_->ShowArcLoading(); | 805 support_host_->ShowArcLoading(); |
| 777 StartArcAndroidManagementCheck(); | 806 StartArcAndroidManagementCheck(); |
| 778 } | 807 } |
| 779 | 808 |
| 780 void ArcSessionManager::StartArcAndroidManagementCheck() { | 809 void ArcSessionManager::StartArcAndroidManagementCheck() { |
| 781 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 810 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 782 DCHECK(arc_bridge_service()->stopped()); | 811 DCHECK(arc_bridge_service()->stopped()); |
| 783 DCHECK(state_ == State::SHOWING_TERMS_OF_SERVICE || | 812 DCHECK(state_ == State::SHOWING_TERMS_OF_SERVICE || |
| 784 state_ == State::CHECKING_ANDROID_MANAGEMENT); | 813 state_ == State::CHECKING_ANDROID_MANAGEMENT || |
| 814 (state_ == State::STOPPED && | |
|
hidehiko
2016/12/09 06:59:57
Good catch! Thanks for fixing.
khmel
2016/12/14 01:27:59
Acknowledged.
| |
| 815 profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted))); | |
| 785 SetState(State::CHECKING_ANDROID_MANAGEMENT); | 816 SetState(State::CHECKING_ANDROID_MANAGEMENT); |
| 786 | 817 |
| 787 android_management_checker_.reset(new ArcAndroidManagementChecker( | 818 android_management_checker_.reset(new ArcAndroidManagementChecker( |
| 788 profile_, context_->token_service(), context_->account_id(), | 819 profile_, context_->token_service(), context_->account_id(), |
| 789 false /* retry_on_error */)); | 820 false /* retry_on_error */)); |
| 790 android_management_checker_->StartCheck( | 821 android_management_checker_->StartCheck( |
| 791 base::Bind(&ArcSessionManager::OnAndroidManagementChecked, | 822 base::Bind(&ArcSessionManager::OnAndroidManagementChecked, |
| 792 weak_ptr_factory_.GetWeakPtr())); | 823 weak_ptr_factory_.GetWeakPtr())); |
| 793 } | 824 } |
| 794 | 825 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 915 return os << "ACTIVE"; | 946 return os << "ACTIVE"; |
| 916 } | 947 } |
| 917 | 948 |
| 918 // Some compiler reports an error even if all values of an enum-class are | 949 // Some compiler reports an error even if all values of an enum-class are |
| 919 // covered indivisually in a switch statement. | 950 // covered indivisually in a switch statement. |
| 920 NOTREACHED(); | 951 NOTREACHED(); |
| 921 return os; | 952 return os; |
| 922 } | 953 } |
| 923 | 954 |
| 924 } // namespace arc | 955 } // namespace arc |
| OLD | NEW |