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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 // We don't expect ProvisioningResult::SUCCESS is reported twice or reported | 204 // We don't expect ProvisioningResult::SUCCESS is reported twice or reported |
| 205 // after an error. | 205 // after an error. |
| 206 DCHECK_NE(result, ProvisioningResult::SUCCESS); | 206 DCHECK_NE(result, ProvisioningResult::SUCCESS); |
| 207 // TODO(khmel): Consider changing LOG to NOTREACHED once we guaranty that | 207 // TODO(khmel): Consider changing LOG to NOTREACHED once we guaranty that |
| 208 // no double message can happen in production. | 208 // no double message can happen in production. |
| 209 LOG(WARNING) << "Provisioning result was already reported. Ignoring " | 209 LOG(WARNING) << "Provisioning result was already reported. Ignoring " |
| 210 << "additional result " << static_cast<int>(result) << "."; | 210 << "additional result " << static_cast<int>(result) << "."; |
| 211 return; | 211 return; |
| 212 } | 212 } |
| 213 provisioning_reported_ = true; | 213 provisioning_reported_ = true; |
| 214 optin_flow_error_detected_ |= (result != ProvisioningResult::SUCCESS); | |
| 214 | 215 |
| 215 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { | 216 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { |
| 216 if (IsArcKioskMode()) { | 217 if (IsArcKioskMode()) { |
| 217 VLOG(1) << "Robot account auth code fetching error"; | 218 VLOG(1) << "Robot account auth code fetching error"; |
| 218 // Log out the user. All the cleanup will be done in Shutdown() method. | 219 // Log out the user. All the cleanup will be done in Shutdown() method. |
| 219 // The callback is not called because auth code is empty. | 220 // The callback is not called because auth code is empty. |
| 220 attempt_user_exit_callback_.Run(); | 221 attempt_user_exit_callback_.Run(); |
| 221 return; | 222 return; |
| 222 } | 223 } |
| 223 | 224 |
| 224 // For backwards compatibility, use NETWORK_ERROR for | 225 // For backwards compatibility, use NETWORK_ERROR for |
| 225 // CHROME_SERVER_COMMUNICATION_ERROR case. | 226 // CHROME_SERVER_COMMUNICATION_ERROR case. |
| 226 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); | 227 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); |
| 227 } else if (!sign_in_start_time_.is_null()) { | 228 } else if (!sign_in_start_time_.is_null()) { |
| 228 arc_sign_in_timer_.Stop(); | 229 arc_sign_in_timer_.Stop(); |
| 229 | 230 |
| 230 UpdateProvisioningTiming(base::Time::Now() - sign_in_start_time_, | 231 UpdateProvisioningTiming(base::Time::Now() - sign_in_start_time_, |
| 231 result == ProvisioningResult::SUCCESS, | 232 result == ProvisioningResult::SUCCESS, |
| 232 policy_util::IsAccountManaged(profile_)); | 233 policy_util::IsAccountManaged(profile_)); |
| 233 UpdateProvisioningResultUMA(result, | 234 UpdateProvisioningResultUMA(result, |
| 234 policy_util::IsAccountManaged(profile_)); | 235 policy_util::IsAccountManaged(profile_)); |
| 235 if (result != ProvisioningResult::SUCCESS) | 236 if (result != ProvisioningResult::SUCCESS) |
| 236 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL); | 237 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL); |
| 237 } | 238 } |
| 238 | 239 |
| 239 if (result == ProvisioningResult::SUCCESS) { | 240 if (result == ProvisioningResult::SUCCESS) { |
| 240 if (support_host_) | 241 if (support_host_) |
| 241 support_host_->Close(); | 242 support_host_->Close(); |
| 242 | 243 |
| 244 StopOptInFlowTracking(true); | |
| 245 | |
| 243 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) | 246 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) |
| 244 return; | 247 return; |
| 245 | 248 |
| 246 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); | 249 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); |
| 247 | 250 |
| 248 // Launch Play Store app, except for the following cases: | 251 // Launch Play Store app, except for the following cases: |
| 249 // * When Opt-in verification is disabled (for tests); | 252 // * When Opt-in verification is disabled (for tests); |
| 250 // * In ARC Kiosk mode, because the only one UI in kiosk mode must be the | 253 // * In ARC Kiosk mode, because the only one UI in kiosk mode must be the |
| 251 // kiosk app and device is not needed for opt-in; | 254 // kiosk app and device is not needed for opt-in; |
| 252 // * When ARC is managed and all OptIn preferences are managed too, because | 255 // * When ARC is managed and all OptIn preferences are managed too, because |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 | 544 |
| 542 void ArcSessionManager::RequestDisable() { | 545 void ArcSessionManager::RequestDisable() { |
| 543 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 546 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 544 DCHECK(profile_); | 547 DCHECK(profile_); |
| 545 | 548 |
| 546 if (!enable_requested_) { | 549 if (!enable_requested_) { |
| 547 VLOG(1) << "ARC is already disabled. Do nothing."; | 550 VLOG(1) << "ARC is already disabled. Do nothing."; |
| 548 return; | 551 return; |
| 549 } | 552 } |
| 550 enable_requested_ = false; | 553 enable_requested_ = false; |
| 554 StopOptInFlowTracking(false); | |
| 551 | 555 |
| 552 // Reset any pending request to re-enable ARC. | 556 // Reset any pending request to re-enable ARC. |
| 553 reenable_arc_ = false; | 557 reenable_arc_ = false; |
| 554 StopArc(); | 558 StopArc(); |
| 555 VLOG(1) << "ARC opt-out. Removing user data."; | 559 VLOG(1) << "ARC opt-out. Removing user data."; |
| 556 RequestArcDataRemoval(); | 560 RequestArcDataRemoval(); |
| 557 } | 561 } |
| 558 | 562 |
| 559 void ArcSessionManager::RequestArcDataRemoval() { | 563 void ArcSessionManager::RequestArcDataRemoval() { |
| 560 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 564 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 | 599 |
| 596 // TODO(hidehiko): Remove this condition, when the state machine is fixed. | 600 // TODO(hidehiko): Remove this condition, when the state machine is fixed. |
| 597 if (!arc_session_runner_->IsStopped()) { | 601 if (!arc_session_runner_->IsStopped()) { |
| 598 // If the user attempts to re-enable ARC while the ARC instance is still | 602 // If the user attempts to re-enable ARC while the ARC instance is still |
| 599 // running the user should not be able to continue until the ARC instance | 603 // running the user should not be able to continue until the ARC instance |
| 600 // has stopped. | 604 // has stopped. |
| 601 if (support_host_) { | 605 if (support_host_) { |
| 602 support_host_->ShowError( | 606 support_host_->ShowError( |
| 603 ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false); | 607 ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false); |
| 604 } | 608 } |
| 609 UpdateOptInCancelUMA(OptInCancelReason::SESSION_BUSY); | |
|
khmel
2017/03/29 21:41:09
We never recorded this issue. It would be nice to
| |
| 605 return; | 610 return; |
| 606 } | 611 } |
| 607 | 612 |
| 608 // TODO(hidehiko): DCHECK if |state_| is STOPPED, when the state machine | 613 // TODO(hidehiko): DCHECK if |state_| is STOPPED, when the state machine |
| 609 // is fixed. | 614 // is fixed. |
| 610 SetState(State::NEGOTIATING_TERMS_OF_SERVICE); | 615 SetState(State::NEGOTIATING_TERMS_OF_SERVICE); |
| 611 | 616 |
| 617 StartOptInFlowTracking(); | |
| 618 | |
| 612 if (!IsArcTermsOfServiceNegotiationNeeded()) { | 619 if (!IsArcTermsOfServiceNegotiationNeeded()) { |
| 613 // Moves to next state, Android management check, immediately, as if | 620 // Moves to next state, Android management check, immediately, as if |
| 614 // Terms of Service negotiation is done successfully. | 621 // Terms of Service negotiation is done successfully. |
| 615 StartAndroidManagementCheck(); | 622 StartAndroidManagementCheck(); |
| 616 return; | 623 return; |
| 617 } | 624 } |
| 618 | 625 |
| 619 if (IsOobeOptInActive()) { | 626 if (IsOobeOptInActive()) { |
| 620 VLOG(1) << "Use OOBE negotiator."; | 627 VLOG(1) << "Use OOBE negotiator."; |
| 621 terms_of_service_negotiator_ = | 628 terms_of_service_negotiator_ = |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 949 arc_session_runner_ = std::move(arc_session_runner); | 956 arc_session_runner_ = std::move(arc_session_runner); |
| 950 arc_session_runner_->AddObserver(this); | 957 arc_session_runner_->AddObserver(this); |
| 951 } | 958 } |
| 952 | 959 |
| 953 void ArcSessionManager::SetAttemptUserExitCallbackForTesting( | 960 void ArcSessionManager::SetAttemptUserExitCallbackForTesting( |
| 954 const base::Closure& callback) { | 961 const base::Closure& callback) { |
| 955 DCHECK(!callback.is_null()); | 962 DCHECK(!callback.is_null()); |
| 956 attempt_user_exit_callback_ = callback; | 963 attempt_user_exit_callback_ = callback; |
| 957 } | 964 } |
| 958 | 965 |
| 966 void ArcSessionManager::StartOptInFlowTracking() { | |
| 967 // Test if we already started OptIn flow tracking. | |
| 968 if (optin_flow_tracked_) | |
| 969 return; | |
| 970 | |
| 971 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { | |
| 972 VLOG(1) << "Skip tracking opt-in flow for already signed ARC"; | |
| 973 return; | |
| 974 } | |
| 975 | |
| 976 UpdateOptInFlowResultUMA(OptInFlowResult::STARTED); | |
| 977 optin_flow_tracked_ = true; | |
| 978 optin_flow_error_detected_ = false; | |
| 979 } | |
| 980 | |
| 981 void ArcSessionManager::StopOptInFlowTracking(bool succeeded) { | |
| 982 if (!optin_flow_tracked_) | |
| 983 return; | |
| 984 | |
| 985 UpdateOptInFlowResultUMA(succeeded ? OptInFlowResult::SUCCEEDED | |
| 986 : OptInFlowResult::CANCELED); | |
| 987 if (optin_flow_error_detected_) { | |
| 988 UpdateOptInFlowResultUMA(succeeded ? OptInFlowResult::SUCCEEDED_AFTER_RETRY | |
| 989 : OptInFlowResult::CANCELED_AFTER_ERROR); | |
| 990 } | |
| 991 | |
| 992 optin_flow_tracked_ = false; | |
| 993 } | |
| 994 | |
| 959 std::ostream& operator<<(std::ostream& os, | 995 std::ostream& operator<<(std::ostream& os, |
| 960 const ArcSessionManager::State& state) { | 996 const ArcSessionManager::State& state) { |
| 961 #define MAP_STATE(name) \ | 997 #define MAP_STATE(name) \ |
| 962 case ArcSessionManager::State::name: \ | 998 case ArcSessionManager::State::name: \ |
| 963 return os << #name | 999 return os << #name |
| 964 | 1000 |
| 965 switch (state) { | 1001 switch (state) { |
| 966 MAP_STATE(NOT_INITIALIZED); | 1002 MAP_STATE(NOT_INITIALIZED); |
| 967 MAP_STATE(STOPPED); | 1003 MAP_STATE(STOPPED); |
| 968 MAP_STATE(NEGOTIATING_TERMS_OF_SERVICE); | 1004 MAP_STATE(NEGOTIATING_TERMS_OF_SERVICE); |
| 969 MAP_STATE(CHECKING_ANDROID_MANAGEMENT); | 1005 MAP_STATE(CHECKING_ANDROID_MANAGEMENT); |
| 970 MAP_STATE(REMOVING_DATA_DIR); | 1006 MAP_STATE(REMOVING_DATA_DIR); |
| 971 MAP_STATE(ACTIVE); | 1007 MAP_STATE(ACTIVE); |
| 972 } | 1008 } |
| 973 | 1009 |
| 974 #undef MAP_STATE | 1010 #undef MAP_STATE |
| 975 | 1011 |
| 976 // Some compilers report an error even if all values of an enum-class are | 1012 // Some compilers report an error even if all values of an enum-class are |
| 977 // covered exhaustively in a switch statement. | 1013 // covered exhaustively in a switch statement. |
| 978 NOTREACHED() << "Invalid value " << static_cast<int>(state); | 1014 NOTREACHED() << "Invalid value " << static_cast<int>(state); |
| 979 return os; | 1015 return os; |
| 980 } | 1016 } |
| 981 | 1017 |
| 982 } // namespace arc | 1018 } // namespace arc |
| OLD | NEW |