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 "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // no double message can happen in production. | 240 // no double message can happen in production. |
241 LOG(WARNING) << "Provisioning result was already reported. Ignoring " | 241 LOG(WARNING) << "Provisioning result was already reported. Ignoring " |
242 << "additional result " << static_cast<int>(result) << "."; | 242 << "additional result " << static_cast<int>(result) << "."; |
243 return; | 243 return; |
244 } | 244 } |
245 provisioning_reported_ = true; | 245 provisioning_reported_ = true; |
246 if (scoped_opt_in_tracker_ && result != ProvisioningResult::SUCCESS) | 246 if (scoped_opt_in_tracker_ && result != ProvisioningResult::SUCCESS) |
247 scoped_opt_in_tracker_->TrackError(); | 247 scoped_opt_in_tracker_->TrackError(); |
248 | 248 |
249 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { | 249 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { |
250 if (IsArcKioskMode()) { | 250 // TODO(poromov): Consider PublicSession offline mode. |
| 251 if (IsRobotAccountMode()) { |
251 VLOG(1) << "Robot account auth code fetching error"; | 252 VLOG(1) << "Robot account auth code fetching error"; |
252 // Log out the user. All the cleanup will be done in Shutdown() method. | 253 // Log out the user. All the cleanup will be done in Shutdown() method. |
253 // The callback is not called because auth code is empty. | 254 // The callback is not called because auth code is empty. |
254 attempt_user_exit_callback_.Run(); | 255 attempt_user_exit_callback_.Run(); |
255 return; | 256 return; |
256 } | 257 } |
257 | 258 |
258 // For backwards compatibility, use NETWORK_ERROR for | 259 // For backwards compatibility, use NETWORK_ERROR for |
259 // CHROME_SERVER_COMMUNICATION_ERROR case. | 260 // CHROME_SERVER_COMMUNICATION_ERROR case. |
260 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); | 261 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); |
(...skipping 21 matching lines...) Expand all Loading... |
282 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) | 283 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) |
283 return; | 284 return; |
284 | 285 |
285 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); | 286 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); |
286 | 287 |
287 // Launch Play Store app, except for the following cases: | 288 // Launch Play Store app, except for the following cases: |
288 // * When Opt-in verification is disabled (for tests); | 289 // * When Opt-in verification is disabled (for tests); |
289 // * In case ARC is enabled from OOBE. | 290 // * In case ARC is enabled from OOBE. |
290 // * In ARC Kiosk mode, because the only one UI in kiosk mode must be the | 291 // * In ARC Kiosk mode, because the only one UI in kiosk mode must be the |
291 // kiosk app and device is not needed for opt-in; | 292 // kiosk app and device is not needed for opt-in; |
| 293 // * In Public Session mode, because Play Store will be hidden from users |
| 294 // and only apps configured by policy should be installed. |
292 // * When ARC is managed and all OptIn preferences are managed/unused, too, | 295 // * When ARC is managed and all OptIn preferences are managed/unused, too, |
293 // because the whole OptIn flow should happen as seamless as possible for | 296 // because the whole OptIn flow should happen as seamless as possible for |
294 // the user. | 297 // the user. |
| 298 // For Active Directory users we always show a page notifying them that they |
| 299 // have to authenticate with their identity provider (through SAML) to make |
| 300 // it less weird that a browser window pops up. |
295 const bool suppress_play_store_app = | 301 const bool suppress_play_store_app = |
296 !IsPlayStoreAvailable() || IsArcOptInVerificationDisabled() || | 302 !IsPlayStoreAvailable() || IsArcOptInVerificationDisabled() || |
297 IsArcKioskMode() || oobe_start_ || | 303 IsRobotAccountMode() || oobe_start_ || |
298 (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_) && | 304 (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_) && |
299 AreArcAllOptInPreferencesIgnorableForProfile(profile_)); | 305 AreArcAllOptInPreferencesIgnorableForProfile(profile_)); |
300 if (!suppress_play_store_app) { | 306 if (!suppress_play_store_app) { |
301 playstore_launcher_ = base::MakeUnique<ArcAppLauncher>( | 307 playstore_launcher_ = base::MakeUnique<ArcAppLauncher>( |
302 profile_, kPlayStoreAppId, | 308 profile_, kPlayStoreAppId, |
303 GetLaunchIntent(kPlayStorePackage, kPlayStoreActivity, | 309 GetLaunchIntent(kPlayStorePackage, kPlayStoreActivity, |
304 {kInitialStartParam}), | 310 {kInitialStartParam}), |
305 false /* deferred_launch_allowed */); | 311 false /* deferred_launch_allowed */); |
306 } | 312 } |
307 | 313 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 // Create the support host at initialization. Note that, practically, | 403 // Create the support host at initialization. Note that, practically, |
398 // ARC support Chrome app is rarely used (only opt-in and re-auth flow). | 404 // ARC support Chrome app is rarely used (only opt-in and re-auth flow). |
399 // So, it may be better to initialize it lazily. | 405 // So, it may be better to initialize it lazily. |
400 // TODO(hidehiko): Revisit to think about lazy initialization. | 406 // TODO(hidehiko): Revisit to think about lazy initialization. |
401 // | 407 // |
402 // Don't show UI for ARC Kiosk because the only one UI in kiosk mode must | 408 // Don't show UI for ARC Kiosk because the only one UI in kiosk mode must |
403 // be the kiosk app. In case of error the UI will be useless as well, because | 409 // be the kiosk app. In case of error the UI will be useless as well, because |
404 // in typical use case there will be no one nearby the kiosk device, who can | 410 // in typical use case there will be no one nearby the kiosk device, who can |
405 // do some action to solve the problem be means of UI. | 411 // do some action to solve the problem be means of UI. |
406 if (!g_disable_ui_for_testing && !IsArcOptInVerificationDisabled() && | 412 if (!g_disable_ui_for_testing && !IsArcOptInVerificationDisabled() && |
407 !IsArcKioskMode()) { | 413 !IsRobotAccountMode()) { |
408 DCHECK(!support_host_); | 414 DCHECK(!support_host_); |
409 support_host_ = base::MakeUnique<ArcSupportHost>(profile_); | 415 support_host_ = base::MakeUnique<ArcSupportHost>(profile_); |
410 support_host_->SetErrorDelegate(this); | 416 support_host_->SetErrorDelegate(this); |
411 } | 417 } |
412 | 418 |
413 context_ = base::MakeUnique<ArcAuthContext>(profile_); | 419 context_ = base::MakeUnique<ArcAuthContext>(profile_); |
414 | 420 |
415 if (!g_disable_ui_for_testing || | 421 if (!g_disable_ui_for_testing || |
416 g_enable_check_android_management_for_testing) { | 422 g_enable_check_android_management_for_testing) { |
417 ArcAndroidManagementChecker::StartClient(); | 423 ArcAndroidManagementChecker::StartClient(); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 } | 603 } |
598 | 604 |
599 oobe_start_ = IsOobeOptInActive(); | 605 oobe_start_ = IsOobeOptInActive(); |
600 | 606 |
601 PrefService* const prefs = profile_->GetPrefs(); | 607 PrefService* const prefs = profile_->GetPrefs(); |
602 | 608 |
603 // If it is marked that sign in has been successfully done, if ARC has been | 609 // If it is marked that sign in has been successfully done, if ARC has been |
604 // set up to always start, then directly start ARC. | 610 // set up to always start, then directly start ARC. |
605 // For Kiosk mode, skip ToS because it is very likely that near the device | 611 // For Kiosk mode, skip ToS because it is very likely that near the device |
606 // there will be no one who is eligible to accept them. | 612 // there will be no one who is eligible to accept them. |
607 // If opt-in verification is disabled, skip negotiation, too. This is for | 613 // In Public Session mode ARC should be started silently without user |
608 // testing purpose. | 614 // interaction. If opt-in verification is disabled, skip negotiation, too. |
609 const bool start_arc_directly = prefs->GetBoolean(prefs::kArcSignedIn) || | 615 // This is for testing purpose. |
610 ShouldArcAlwaysStart() || IsArcKioskMode() || | 616 const bool start_arc_directly = |
611 IsArcOptInVerificationDisabled(); | 617 prefs->GetBoolean(prefs::kArcSignedIn) || ShouldArcAlwaysStart() || |
| 618 IsRobotAccountMode() || IsArcOptInVerificationDisabled(); |
612 | 619 |
613 // When ARC is blocked because of filesystem compatibility, do not proceed | 620 // When ARC is blocked because of filesystem compatibility, do not proceed |
614 // to starting ARC nor follow further state transitions. | 621 // to starting ARC nor follow further state transitions. |
615 if (IsArcBlockedDueToIncompatibleFileSystem(profile_)) { | 622 if (IsArcBlockedDueToIncompatibleFileSystem(profile_)) { |
616 // If the next step was the ToS negotiation, show a notification instead. | 623 // If the next step was the ToS negotiation, show a notification instead. |
617 // Otherwise, be silent now. Users are notified when clicking ARC app icons. | 624 // Otherwise, be silent now. Users are notified when clicking ARC app icons. |
618 if (!start_arc_directly && !g_disable_ui_for_testing) | 625 if (!start_arc_directly && !g_disable_ui_for_testing) |
619 arc::ShowArcMigrationGuideNotification(profile_); | 626 arc::ShowArcMigrationGuideNotification(profile_); |
620 return false; | 627 return false; |
621 } | 628 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 DCHECK(arc_session_runner_->IsStopped()); | 705 DCHECK(arc_session_runner_->IsStopped()); |
699 MaybeStartArcDataRemoval(); | 706 MaybeStartArcDataRemoval(); |
700 } | 707 } |
701 } | 708 } |
702 | 709 |
703 void ArcSessionManager::MaybeStartTermsOfServiceNegotiation() { | 710 void ArcSessionManager::MaybeStartTermsOfServiceNegotiation() { |
704 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 711 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
705 DCHECK(profile_); | 712 DCHECK(profile_); |
706 DCHECK(arc_session_runner_->IsStopped() || arc_session_runner_->IsStopping()); | 713 DCHECK(arc_session_runner_->IsStopped() || arc_session_runner_->IsStopping()); |
707 DCHECK(!terms_of_service_negotiator_); | 714 DCHECK(!terms_of_service_negotiator_); |
708 // In Kiosk-mode, Terms of Service negotiation should be skipped. | 715 // In Kiosk and Public Session mode, Terms of Service negotiation should be |
709 // See also RequestEnableImpl(). | 716 // skipped. See also RequestEnableImpl(). |
710 DCHECK(!IsArcKioskMode()); | 717 DCHECK(!IsRobotAccountMode()); |
711 // If opt-in verification is disabled, Terms of Service negotiation should | 718 // If opt-in verification is disabled, Terms of Service negotiation should |
712 // be skipped, too. See also RequestEnableImpl(). | 719 // be skipped, too. See also RequestEnableImpl(). |
713 DCHECK(!IsArcOptInVerificationDisabled()); | 720 DCHECK(!IsArcOptInVerificationDisabled()); |
714 | 721 |
715 DCHECK_EQ(state_, State::STOPPED); | 722 DCHECK_EQ(state_, State::STOPPED); |
716 state_ = State::NEGOTIATING_TERMS_OF_SERVICE; | 723 state_ = State::NEGOTIATING_TERMS_OF_SERVICE; |
717 | 724 |
718 // TODO(hidehiko): In kArcSignedIn = true case, this method should never | 725 // TODO(hidehiko): In kArcSignedIn = true case, this method should never |
719 // be called. Remove the check. | 726 // be called. Remove the check. |
720 // Conceptually, this is starting ToS negotiation, rather than opt-in flow. | 727 // Conceptually, this is starting ToS negotiation, rather than opt-in flow. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 break; | 870 break; |
864 } | 871 } |
865 } | 872 } |
866 | 873 |
867 void ArcSessionManager::StartBackgroundAndroidManagementCheck() { | 874 void ArcSessionManager::StartBackgroundAndroidManagementCheck() { |
868 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 875 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
869 DCHECK_EQ(state_, State::ACTIVE); | 876 DCHECK_EQ(state_, State::ACTIVE); |
870 DCHECK(!android_management_checker_); | 877 DCHECK(!android_management_checker_); |
871 | 878 |
872 // Skip Android management check for testing. | 879 // Skip Android management check for testing. |
873 // We also skip if Android management check for Kiosk mode, | 880 // We also skip if Android management check for Kiosk and Public Session mode, |
874 // because there are no managed human users for Kiosk exist. | 881 // because there are no managed human users for them exist. |
875 if (IsArcOptInVerificationDisabled() || IsArcKioskMode() || | 882 if (IsArcOptInVerificationDisabled() || IsRobotAccountMode() || |
876 (g_disable_ui_for_testing && | 883 (g_disable_ui_for_testing && |
877 !g_enable_check_android_management_for_testing)) { | 884 !g_enable_check_android_management_for_testing)) { |
878 return; | 885 return; |
879 } | 886 } |
880 | 887 |
881 android_management_checker_ = base::MakeUnique<ArcAndroidManagementChecker>( | 888 android_management_checker_ = base::MakeUnique<ArcAndroidManagementChecker>( |
882 profile_, context_->token_service(), context_->account_id(), | 889 profile_, context_->token_service(), context_->account_id(), |
883 true /* retry_on_error */); | 890 true /* retry_on_error */); |
884 android_management_checker_->StartCheck( | 891 android_management_checker_->StartCheck( |
885 base::Bind(&ArcSessionManager::OnBackgroundAndroidManagementChecked, | 892 base::Bind(&ArcSessionManager::OnBackgroundAndroidManagementChecked, |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 | 1101 |
1095 #undef MAP_STATE | 1102 #undef MAP_STATE |
1096 | 1103 |
1097 // Some compilers report an error even if all values of an enum-class are | 1104 // Some compilers report an error even if all values of an enum-class are |
1098 // covered exhaustively in a switch statement. | 1105 // covered exhaustively in a switch statement. |
1099 NOTREACHED() << "Invalid value " << static_cast<int>(state); | 1106 NOTREACHED() << "Invalid value " << static_cast<int>(state); |
1100 return os; | 1107 return os; |
1101 } | 1108 } |
1102 | 1109 |
1103 } // namespace arc | 1110 } // namespace arc |
OLD | NEW |