Chromium Code Reviews| Index: chrome/browser/chromeos/arc/arc_auth_service.cc |
| diff --git a/chrome/browser/chromeos/arc/arc_auth_service.cc b/chrome/browser/chromeos/arc/arc_auth_service.cc |
| index fa411b4d0c88bb02e3d88754c257cca16d1ac221..8cd452b101146fc1d88b275dc209fac272226197 100644 |
| --- a/chrome/browser/chromeos/arc/arc_auth_service.cc |
| +++ b/chrome/browser/chromeos/arc/arc_auth_service.cc |
| @@ -452,6 +452,14 @@ void ArcAuthService::OnSyncedPrefChanged(const std::string& path, |
| } |
| } |
| +void ArcAuthService::StopArc() { |
| + if (state_ != State::STOPPED) { |
| + UpdateEnabledStateUMA(false); |
| + profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); |
| + } |
| + ShutdownBridgeAndCloseUI(); |
| +} |
| + |
| void ArcAuthService::OnOptInPreferenceChanged() { |
| DCHECK(thread_checker.Get().CalledOnValidThread()); |
| DCHECK(profile_); |
| @@ -460,11 +468,7 @@ void ArcAuthService::OnOptInPreferenceChanged() { |
| FOR_EACH_OBSERVER(Observer, observer_list_, OnOptInEnabled(arc_enabled)); |
| if (!arc_enabled) { |
| - if (state_ != State::STOPPED) { |
| - UpdateEnabledStateUMA(false); |
| - profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); |
| - } |
| - ShutdownBridgeAndCloseUI(); |
| + StopArc(); |
| return; |
| } |
| @@ -585,19 +589,20 @@ void ArcAuthService::StartLso() { |
| void ArcAuthService::CancelAuthCode() { |
| DCHECK(thread_checker.Get().CalledOnValidThread()); |
| - if (ui_page_ == UIPage::ERROR_WITH_FEEDBACK) { |
| - ShutdownBridge(); |
|
khmel
2016/06/29 23:53:55
This is handled in StopArc and by adding check on
|
| - if (profile_->GetPrefs()->HasPrefPath(prefs::kArcSignedIn)) |
| - profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); |
| - } |
| - |
| if (state_ != State::FETCHING_CODE && ui_page_ != UIPage::ERROR && |
|
Luis Héctor Chávez
2016/06/30 17:04:13
Given that silent opt-in is now off the table, can
khmel
2016/06/30 17:41:50
I added State::NOT_INITIALIZED handling and commen
Luis Héctor Chávez
2016/06/30 20:46:46
Discussed this with mitsuji@. He was also of the i
|
| ui_page_ != UIPage::ERROR_WITH_FEEDBACK) |
| return; |
| // Update UMA with user cancel only if error is not currently shown. |
| - if (ui_page_ != UIPage::ERROR && ui_page_ != UIPage::NO_PAGE) |
| + if (ui_page_ != UIPage::ERROR && ui_page_ == UIPage::ERROR_WITH_FEEDBACK && |
| + ui_page_ != UIPage::NO_PAGE) { |
| UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL); |
| + } |
| + |
| + StopArc(); |
| + |
| + if (IsArcManaged()) |
| + return; |
| base::AutoReset<bool> auto_reset(&disable_arc_from_ui_, true); |
| DisableArc(); |
| @@ -618,7 +623,14 @@ bool ArcAuthService::IsArcEnabled() const { |
| void ArcAuthService::EnableArc() { |
| DCHECK(thread_checker.Get().CalledOnValidThread()); |
| DCHECK(profile_); |
| - profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); |
| + |
| + if (!IsArcEnabled()) { |
| + if (IsArcManaged()) |
| + return; |
| + profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); |
| + } else { |
| + OnOptInPreferenceChanged(); |
| + } |
| } |
| void ArcAuthService::DisableArc() { |