Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: chrome/browser/chromeos/arc/arc_session_manager.cc

Issue 2926893002: arc: Start ARC for Public Session users.
Patch Set: Update unit tests. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // no double message can happen in production. 253 // no double message can happen in production.
254 LOG(WARNING) << "Provisioning result was already reported. Ignoring " 254 LOG(WARNING) << "Provisioning result was already reported. Ignoring "
255 << "additional result " << static_cast<int>(result) << "."; 255 << "additional result " << static_cast<int>(result) << ".";
256 return; 256 return;
257 } 257 }
258 provisioning_reported_ = true; 258 provisioning_reported_ = true;
259 if (scoped_opt_in_tracker_ && result != ProvisioningResult::SUCCESS) 259 if (scoped_opt_in_tracker_ && result != ProvisioningResult::SUCCESS)
260 scoped_opt_in_tracker_->TrackError(); 260 scoped_opt_in_tracker_->TrackError();
261 261
262 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { 262 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) {
263 if (IsArcKioskMode()) { 263 if (IsArcKioskMode()) {
hidehiko 2017/06/08 12:02:27 Need to check here, too?
Sergey Poromov 2017/06/08 13:56:18 Done.
264 VLOG(1) << "Robot account auth code fetching error"; 264 VLOG(1) << "Robot account auth code fetching error";
265 // Log out the user. All the cleanup will be done in Shutdown() method. 265 // Log out the user. All the cleanup will be done in Shutdown() method.
266 // The callback is not called because auth code is empty. 266 // The callback is not called because auth code is empty.
267 attempt_user_exit_callback_.Run(); 267 attempt_user_exit_callback_.Run();
268 return; 268 return;
269 } 269 }
270 270
271 // For backwards compatibility, use NETWORK_ERROR for 271 // For backwards compatibility, use NETWORK_ERROR for
272 // CHROME_SERVER_COMMUNICATION_ERROR case. 272 // CHROME_SERVER_COMMUNICATION_ERROR case.
273 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 273 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
(...skipping 26 matching lines...) Expand all
300 // Launch Play Store app, except for the following cases: 300 // Launch Play Store app, except for the following cases:
301 // * When Opt-in verification is disabled (for tests); 301 // * When Opt-in verification is disabled (for tests);
302 // * In ARC Kiosk mode, because the only one UI in kiosk mode must be the 302 // * In ARC Kiosk mode, because the only one UI in kiosk mode must be the
303 // kiosk app and device is not needed for opt-in; 303 // kiosk app and device is not needed for opt-in;
304 // * When ARC is managed and all OptIn preferences are managed too, because 304 // * When ARC is managed and all OptIn preferences are managed too, because
305 // the whole OptIn flow should happen as seamless as possible for the 305 // the whole OptIn flow should happen as seamless as possible for the
306 // user. 306 // user.
307 const bool suppress_play_store_app = 307 const bool suppress_play_store_app =
308 IsArcOptInVerificationDisabled() || IsArcKioskMode() || 308 IsArcOptInVerificationDisabled() || IsArcKioskMode() ||
309 (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_) && 309 (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_) &&
310 AreArcAllOptInPreferencesManagedForProfile(profile_)); 310 AreArcAllOptInPreferencesManagedForProfile(profile_));
Sergey Poromov 2017/06/08 13:56:18 While OptIn preferences should be managed for Publ
311 if (!suppress_play_store_app) { 311 if (!suppress_play_store_app) {
312 playstore_launcher_.reset( 312 playstore_launcher_.reset(
313 new ArcAppLauncher(profile_, kPlayStoreAppId, true, false)); 313 new ArcAppLauncher(profile_, kPlayStoreAppId, true, false));
314 } 314 }
315 315
316 for (auto& observer : observer_list_) 316 for (auto& observer : observer_list_)
317 observer.OnArcInitialStart(); 317 observer.OnArcInitialStart();
318 return; 318 return;
319 } 319 }
320 320
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // Create the support host at initialization. Note that, practically, 407 // Create the support host at initialization. Note that, practically,
408 // ARC support Chrome app is rarely used (only opt-in and re-auth flow). 408 // ARC support Chrome app is rarely used (only opt-in and re-auth flow).
409 // So, it may be better to initialize it lazily. 409 // So, it may be better to initialize it lazily.
410 // TODO(hidehiko): Revisit to think about lazy initialization. 410 // TODO(hidehiko): Revisit to think about lazy initialization.
411 // 411 //
412 // Don't show UI for ARC Kiosk because the only one UI in kiosk mode must 412 // Don't show UI for ARC Kiosk because the only one UI in kiosk mode must
413 // be the kiosk app. In case of error the UI will be useless as well, because 413 // be the kiosk app. In case of error the UI will be useless as well, because
414 // in typical use case there will be no one nearby the kiosk device, who can 414 // in typical use case there will be no one nearby the kiosk device, who can
415 // do some action to solve the problem be means of UI. 415 // do some action to solve the problem be means of UI.
416 if (!g_disable_ui_for_testing && !IsArcOptInVerificationDisabled() && 416 if (!g_disable_ui_for_testing && !IsArcOptInVerificationDisabled() &&
417 !IsArcKioskMode()) { 417 !IsArcKioskMode()) {
hidehiko 2017/06/08 12:02:26 Clarification: Do we want to show error for Public
Sergey Poromov 2017/06/08 13:56:18 I think not. In case of an error there is nothing
418 DCHECK(!support_host_); 418 DCHECK(!support_host_);
419 support_host_ = base::MakeUnique<ArcSupportHost>(profile_); 419 support_host_ = base::MakeUnique<ArcSupportHost>(profile_);
420 support_host_->SetErrorDelegate(this); 420 support_host_->SetErrorDelegate(this);
421 } 421 }
422 422
423 DCHECK_EQ(State::NOT_INITIALIZED, state_); 423 DCHECK_EQ(State::NOT_INITIALIZED, state_);
424 SetState(State::STOPPED); 424 SetState(State::STOPPED);
425 425
426 context_ = base::MakeUnique<ArcAuthContext>(profile_); 426 context_ = base::MakeUnique<ArcAuthContext>(profile_);
427 427
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 reenable_arc_ = true; 566 reenable_arc_ = true;
567 return; 567 return;
568 } 568 }
569 569
570 PrefService* const prefs = profile_->GetPrefs(); 570 PrefService* const prefs = profile_->GetPrefs();
571 571
572 // If it is marked that sign in has been successfully done, if ARC has been 572 // If it is marked that sign in has been successfully done, if ARC has been
573 // set up to always start, then directly start ARC. 573 // set up to always start, then directly start ARC.
574 // For Kiosk mode, skip ToS because it is very likely that near the device 574 // For Kiosk mode, skip ToS because it is very likely that near the device
575 // there will be no one who is eligible to accept them. 575 // there will be no one who is eligible to accept them.
576 // If opt-in verification is disabled, skip negotiation, too. This is for 576 // In Public Session mode ARC should be started silently without user
577 // testing purpose. 577 // interaction. If opt-in verification is disabled, skip negotiation, too.
578 // This is for testing purpose.
578 const bool start_arc_directly = prefs->GetBoolean(prefs::kArcSignedIn) || 579 const bool start_arc_directly = prefs->GetBoolean(prefs::kArcSignedIn) ||
579 ShouldArcAlwaysStart() || IsArcKioskMode() || 580 ShouldArcAlwaysStart() || IsArcKioskMode() ||
581 IsPublicSessionMode() ||
580 IsArcOptInVerificationDisabled(); 582 IsArcOptInVerificationDisabled();
581 583
582 // When ARC is blocked because of filesystem compatibility, do not proceed 584 // When ARC is blocked because of filesystem compatibility, do not proceed
583 // to starting ARC nor follow further state transitions. 585 // to starting ARC nor follow further state transitions.
584 if (IsArcBlockedDueToIncompatibleFileSystem(profile_)) { 586 if (IsArcBlockedDueToIncompatibleFileSystem(profile_)) {
585 // If the next step was the ToS negotiation, show a notification instead. 587 // If the next step was the ToS negotiation, show a notification instead.
586 // Otherwise, be silent now. Users are notified when clicking ARC app icons. 588 // Otherwise, be silent now. Users are notified when clicking ARC app icons.
587 if (!start_arc_directly && !g_disable_ui_for_testing) 589 if (!start_arc_directly && !g_disable_ui_for_testing)
588 arc::ShowArcMigrationGuideNotification(profile_); 590 arc::ShowArcMigrationGuideNotification(profile_);
589 return; 591 return;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 if (state_ == State::STOPPED && arc_session_runner_->IsStopped()) 651 if (state_ == State::STOPPED && arc_session_runner_->IsStopped())
650 MaybeStartArcDataRemoval(); 652 MaybeStartArcDataRemoval();
651 } 653 }
652 654
653 void ArcSessionManager::MaybeStartTermsOfServiceNegotiation() { 655 void ArcSessionManager::MaybeStartTermsOfServiceNegotiation() {
654 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 656 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
655 DCHECK(profile_); 657 DCHECK(profile_);
656 DCHECK(!terms_of_service_negotiator_); 658 DCHECK(!terms_of_service_negotiator_);
657 // In Kiosk-mode, Terms of Service negotiation should be skipped. 659 // In Kiosk-mode, Terms of Service negotiation should be skipped.
658 // See also RequestEnableImpl(). 660 // See also RequestEnableImpl().
659 DCHECK(!IsArcKioskMode()); 661 DCHECK(!IsArcKioskMode());
hidehiko 2017/06/08 12:02:26 DCHECK(!IsPublicSession()); too.
Sergey Poromov 2017/06/08 13:56:18 Done.
660 // If opt-in verification is disabled, Terms of Service negotiation should 662 // If opt-in verification is disabled, Terms of Service negotiation should
661 // be skipped, too. See also RequestEnableImpl(). 663 // be skipped, too. See also RequestEnableImpl().
662 DCHECK(!IsArcOptInVerificationDisabled()); 664 DCHECK(!IsArcOptInVerificationDisabled());
663 665
664 // TODO(hidehiko): Remove this condition, when the state machine is fixed. 666 // TODO(hidehiko): Remove this condition, when the state machine is fixed.
665 if (!arc_session_runner_->IsStopped()) { 667 if (!arc_session_runner_->IsStopped()) {
666 // If the user attempts to re-enable ARC while the ARC instance is still 668 // If the user attempts to re-enable ARC while the ARC instance is still
667 // running the user should not be able to continue until the ARC instance 669 // running the user should not be able to continue until the ARC instance
668 // has stopped. 670 // has stopped.
669 ShowArcSupportHostError( 671 ShowArcSupportHostError(
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 } 815 }
814 816
815 void ArcSessionManager::StartBackgroundAndroidManagementCheck() { 817 void ArcSessionManager::StartBackgroundAndroidManagementCheck() {
816 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 818 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
817 DCHECK_EQ(state_, State::ACTIVE); 819 DCHECK_EQ(state_, State::ACTIVE);
818 DCHECK(!android_management_checker_); 820 DCHECK(!android_management_checker_);
819 821
820 // Skip Android management check for testing. 822 // Skip Android management check for testing.
821 // We also skip if Android management check for Kiosk mode, 823 // We also skip if Android management check for Kiosk mode,
822 // because there are no managed human users for Kiosk exist. 824 // because there are no managed human users for Kiosk exist.
823 if (IsArcOptInVerificationDisabled() || IsArcKioskMode() || 825 if (IsArcOptInVerificationDisabled() || IsArcKioskMode() ||
hidehiko 2017/06/08 12:02:27 Is it ok to run the check for the Public session?
Sergey Poromov 2017/06/08 13:56:18 Public Session is always Chrome OS managed user, s
824 (g_disable_ui_for_testing && 826 (g_disable_ui_for_testing &&
825 !g_enable_check_android_management_for_testing)) { 827 !g_enable_check_android_management_for_testing)) {
826 return; 828 return;
827 } 829 }
828 830
829 android_management_checker_ = base::MakeUnique<ArcAndroidManagementChecker>( 831 android_management_checker_ = base::MakeUnique<ArcAndroidManagementChecker>(
830 profile_, context_->token_service(), context_->account_id(), 832 profile_, context_->token_service(), context_->account_id(),
831 true /* retry_on_error */); 833 true /* retry_on_error */);
832 android_management_checker_->StartCheck( 834 android_management_checker_->StartCheck(
833 base::Bind(&ArcSessionManager::OnBackgroundAndroidManagementChecked, 835 base::Bind(&ArcSessionManager::OnBackgroundAndroidManagementChecked,
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 1039
1038 #undef MAP_STATE 1040 #undef MAP_STATE
1039 1041
1040 // Some compilers report an error even if all values of an enum-class are 1042 // Some compilers report an error even if all values of an enum-class are
1041 // covered exhaustively in a switch statement. 1043 // covered exhaustively in a switch statement.
1042 NOTREACHED() << "Invalid value " << static_cast<int>(state); 1044 NOTREACHED() << "Invalid value " << static_cast<int>(state);
1043 return os; 1045 return os;
1044 } 1046 }
1045 1047
1046 } // namespace arc 1048 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698