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

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

Issue 2561023002: arc: ARC loading progress should not be shown when started from OOBE. (Closed)
Patch Set: small fix Created 4 years 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 "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"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/chromeos/arc/arc_auth_context.h" 17 #include "chrome/browser/chromeos/arc/arc_auth_context.h"
18 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" 18 #include "chrome/browser/chromeos/arc/arc_optin_uma.h"
19 #include "chrome/browser/chromeos/arc/arc_support_host.h" 19 #include "chrome/browser/chromeos/arc/arc_support_host.h"
20 #include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_negotiator.h" 20 #include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_default_negotia tor.h"
21 #include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator _for_managed_user.h"
21 #include "chrome/browser/chromeos/arc/policy/arc_android_management_checker.h" 22 #include "chrome/browser/chromeos/arc/policy/arc_android_management_checker.h"
22 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h" 23 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h"
23 #include "chrome/browser/chromeos/login/user_flow.h" 24 #include "chrome/browser/chromeos/login/user_flow.h"
24 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 25 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
25 #include "chrome/browser/chromeos/profiles/profile_helper.h" 26 #include "chrome/browser/chromeos/profiles/profile_helper.h"
26 #include "chrome/browser/lifetime/application_lifetime.h" 27 #include "chrome/browser/lifetime/application_lifetime.h"
27 #include "chrome/browser/policy/profile_policy_connector.h" 28 #include "chrome/browser/policy/profile_policy_connector.h"
28 #include "chrome/browser/policy/profile_policy_connector_factory.h" 29 #include "chrome/browser/policy/profile_policy_connector_factory.h"
29 #include "chrome/browser/prefs/pref_service_syncable_util.h" 30 #include "chrome/browser/prefs/pref_service_syncable_util.h"
30 #include "chrome/browser/profiles/profile.h" 31 #include "chrome/browser/profiles/profile.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ash::ShelfDelegate* GetShelfDelegate() { 72 ash::ShelfDelegate* GetShelfDelegate() {
72 if (g_shelf_delegate_for_testing) 73 if (g_shelf_delegate_for_testing)
73 return g_shelf_delegate_for_testing; 74 return g_shelf_delegate_for_testing;
74 if (ash::WmShell::HasInstance()) { 75 if (ash::WmShell::HasInstance()) {
75 DCHECK(ash::WmShell::Get()->shelf_delegate()); 76 DCHECK(ash::WmShell::Get()->shelf_delegate());
76 return ash::WmShell::Get()->shelf_delegate(); 77 return ash::WmShell::Get()->shelf_delegate();
77 } 78 }
78 return nullptr; 79 return nullptr;
79 } 80 }
80 81
82 // Returns true if this is the first user's login session and Arc OOBE is
83 // enabled.
84 bool IsFirstRunForOobeEnabledUser() {
85 return user_manager::UserManager::Get()->IsCurrentUserNew() &&
86 base::CommandLine::ForCurrentProcess()->HasSwitch(
87 chromeos::switches::kEnableArcOOBEOptIn);
88 }
89
81 } // namespace 90 } // namespace
82 91
83 ArcSessionManager::ArcSessionManager(ArcBridgeService* bridge_service) 92 ArcSessionManager::ArcSessionManager(ArcBridgeService* bridge_service)
84 : ArcService(bridge_service), 93 : ArcService(bridge_service),
85 attempt_user_exit_callback_(base::Bind(chrome::AttemptUserExit)), 94 attempt_user_exit_callback_(base::Bind(chrome::AttemptUserExit)),
86 weak_ptr_factory_(this) { 95 weak_ptr_factory_(this) {
87 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 96 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
88 DCHECK(!g_arc_session_manager); 97 DCHECK(!g_arc_session_manager);
89 g_arc_session_manager = this; 98 g_arc_session_manager = this;
90 99
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // Restart ARC anyway. Let the enterprise reporting instance decide whether 273 // Restart ARC anyway. Let the enterprise reporting instance decide whether
265 // the ARC user data wipe is still required or not. 274 // the ARC user data wipe is still required or not.
266 reenable_arc_ = false; 275 reenable_arc_ = false;
267 VLOG(1) << "Reenable ARC"; 276 VLOG(1) << "Reenable ARC";
268 EnableArc(); 277 EnableArc();
269 } 278 }
270 279
271 void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) { 280 void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) {
272 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 281 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
273 282
274 // Due asynchronous nature of stopping Arc bridge, OnProvisioningFinished may 283 // Due asynchronous nature of stopping ARC bridge, OnProvisioningFinished may
275 // arrive after setting the |State::STOPPED| state and |State::Active| is not 284 // arrive after setting the |State::STOPPED| state and |State::Active| is not
276 // guaranty set here. prefs::kArcDataRemoveRequested is also can be active 285 // guaranty set here. prefs::kArcDataRemoveRequested is also can be active
277 // for now. 286 // for now.
278 287
279 if (provisioning_reported_) { 288 if (provisioning_reported_) {
280 // We don't expect ProvisioningResult::SUCCESS is reported twice or reported 289 // We don't expect ProvisioningResult::SUCCESS is reported twice or reported
281 // after an error. 290 // after an error.
282 DCHECK_NE(result, ProvisioningResult::SUCCESS); 291 DCHECK_NE(result, ProvisioningResult::SUCCESS);
283 // TODO (khmel): Consider changing LOG to NOTREACHED once we guaranty that 292 // TODO (khmel): Consider changing LOG to NOTREACHED once we guaranty that
284 // no double message can happen in production. 293 // no double message can happen in production.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 448
440 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( 449 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver(
441 prefs::kArcEnabled, this); 450 prefs::kArcEnabled, this);
442 451
443 context_.reset(new ArcAuthContext(profile_)); 452 context_.reset(new ArcAuthContext(profile_));
444 453
445 if (!g_disable_ui_for_testing || 454 if (!g_disable_ui_for_testing ||
446 g_enable_check_android_management_for_testing) { 455 g_enable_check_android_management_for_testing) {
447 ArcAndroidManagementChecker::StartClient(); 456 ArcAndroidManagementChecker::StartClient();
448 } 457 }
458
449 pref_change_registrar_.Init(profile_->GetPrefs()); 459 pref_change_registrar_.Init(profile_->GetPrefs());
450 pref_change_registrar_.Add( 460 pref_change_registrar_.Add(
451 prefs::kArcEnabled, 461 prefs::kArcEnabled,
452 base::Bind(&ArcSessionManager::OnOptInPreferenceChanged, 462 base::Bind(&ArcSessionManager::OnOptInPreferenceChanged,
453 weak_ptr_factory_.GetWeakPtr())); 463 weak_ptr_factory_.GetWeakPtr(), false /* initial_run */));
454 if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) { 464 if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) {
455 // Don't start ARC if there is a pending request to remove the data. Restart 465 // Don't start ARC if there is a pending request to remove the data. Restart
456 // ARC once data removal finishes. 466 // ARC once data removal finishes.
457 if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) { 467 if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) {
458 reenable_arc_ = true; 468 reenable_arc_ = true;
459 RemoveArcData(); 469 RemoveArcData();
460 } else { 470 } else {
461 OnOptInPreferenceChanged(); 471 OnOptInPreferenceChanged(true /* initial_run */);
462 } 472 }
463 } else { 473 } else {
464 RemoveArcData(); 474 RemoveArcData();
465 PrefServiceSyncableFromProfile(profile_)->AddObserver(this); 475 PrefServiceSyncableFromProfile(profile_)->AddObserver(this);
466 OnIsSyncingChanged(); 476 OnIsSyncingChanged();
467 } 477 }
468 } 478 }
469 479
470 void ArcSessionManager::OnIsSyncingChanged() { 480 void ArcSessionManager::OnIsSyncingChanged() {
471 sync_preferences::PrefServiceSyncable* const pref_service_syncable = 481 sync_preferences::PrefServiceSyncable* const pref_service_syncable =
472 PrefServiceSyncableFromProfile(profile_); 482 PrefServiceSyncableFromProfile(profile_);
473 if (!pref_service_syncable->IsSyncing()) 483 if (!pref_service_syncable->IsSyncing())
474 return; 484 return;
475 485
476 pref_service_syncable->RemoveObserver(this); 486 pref_service_syncable->RemoveObserver(this);
477 487
478 if (IsArcEnabled()) 488 if (IsArcEnabled())
479 OnOptInPreferenceChanged(); 489 OnOptInPreferenceChanged(false);
480 } 490 }
481 491
482 void ArcSessionManager::Shutdown() { 492 void ArcSessionManager::Shutdown() {
483 ShutdownBridge(); 493 ShutdownBridge();
484 if (support_host_) { 494 if (support_host_) {
485 support_host_->Close(); 495 support_host_->Close();
486 support_host_->RemoveObserver(this); 496 support_host_->RemoveObserver(this);
487 support_host_.reset(); 497 support_host_.reset();
488 } 498 }
489 if (profile_) { 499 if (profile_) {
(...skipping 30 matching lines...) Expand all
520 void ArcSessionManager::StopArc() { 530 void ArcSessionManager::StopArc() {
521 if (state_ != State::STOPPED) { 531 if (state_ != State::STOPPED) {
522 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); 532 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false);
523 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, false); 533 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, false);
524 } 534 }
525 ShutdownBridge(); 535 ShutdownBridge();
526 if (support_host_) 536 if (support_host_)
527 support_host_->Close(); 537 support_host_->Close();
528 } 538 }
529 539
530 void ArcSessionManager::OnOptInPreferenceChanged() { 540 void ArcSessionManager::OnOptInPreferenceChanged(bool initial_run) {
531 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 541 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
532 DCHECK(profile_); 542 DCHECK(profile_);
533 543
534 // TODO(dspaid): Move code from OnSyncedPrefChanged into this method. 544 // TODO(dspaid): Move code from OnSyncedPrefChanged into this method.
535 OnSyncedPrefChanged(prefs::kArcEnabled, IsArcManaged()); 545 OnSyncedPrefChanged(prefs::kArcEnabled, IsArcManaged());
536 546
537 const bool arc_enabled = IsArcEnabled(); 547 const bool arc_enabled = IsArcEnabled();
538 for (auto& observer : observer_list_) 548 for (auto& observer : observer_list_)
539 observer.OnOptInEnabled(arc_enabled); 549 observer.OnOptInEnabled(arc_enabled);
540 550
541 if (!arc_enabled) { 551 if (!arc_enabled) {
542 // Reset any pending request to re-enable Arc. 552 // Reset any pending request to re-enable Arc.
543 reenable_arc_ = false; 553 reenable_arc_ = false;
544 StopArc(); 554 StopArc();
545 RemoveArcData(); 555 RemoveArcData();
546 return; 556 return;
547 } 557 }
548 558
549 if (state_ == State::ACTIVE) 559 if (state_ == State::ACTIVE)
550 return; 560 return;
551 561
552 if (state_ == State::REMOVING_DATA_DIR) { 562 if (state_ == State::REMOVING_DATA_DIR) {
553 // Data removal request is in progress. Set flag to re-enable Arc once it is 563 // Data removal request is in progress. Set flag to re-enable ARC once it is
554 // finished. 564 // finished.
555 reenable_arc_ = true; 565 reenable_arc_ = true;
556 return; 566 return;
557 } 567 }
558 568
559 if (support_host_) 569 if (support_host_)
560 support_host_->SetArcManaged(IsArcManaged()); 570 support_host_->SetArcManaged(IsArcManaged());
561 571
562 // For ARC Kiosk we skip ToS because it is very likely that near the device 572 // For ARC Kiosk we skip ToS because it is very likely that near the device
563 // there will be no one who is eligible to accept them. 573 // there will be no one who is eligible to accept them.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 608 }
599 609
600 // If it is marked that the Terms of service is accepted already, 610 // If it is marked that the Terms of service is accepted already,
601 // just skip the negotiation with user, and start Android management 611 // just skip the negotiation with user, and start Android management
602 // check directly. 612 // check directly.
603 // This happens, e.g., when; 613 // This happens, e.g., when;
604 // 1) User accepted the Terms of service on OOBE flow. 614 // 1) User accepted the Terms of service on OOBE flow.
605 // 2) User accepted the Terms of service on Opt-in flow, but logged out 615 // 2) User accepted the Terms of service on Opt-in flow, but logged out
606 // before ARC sign in procedure was done. Then, logs in again. 616 // before ARC sign in procedure was done. Then, logs in again.
607 if (profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) { 617 if (profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) {
608 support_host_->ShowArcLoading();
609 StartArcAndroidManagementCheck(); 618 StartArcAndroidManagementCheck();
610 return; 619 return;
611 } 620 }
612 621
613 // Need user's explicit Terms Of Service agreement. 622 // Need user's explicit Terms Of Service agreement.
614 StartTermsOfServiceNegotiation(); 623 StartTermsOfServiceNegotiation(initial_run);
615 } 624 }
616 625
617 void ArcSessionManager::ShutdownBridge() { 626 void ArcSessionManager::ShutdownBridge() {
618 arc_sign_in_timer_.Stop(); 627 arc_sign_in_timer_.Stop();
619 playstore_launcher_.reset(); 628 playstore_launcher_.reset();
620 terms_of_service_negotiator_.reset(); 629 terms_of_service_negotiator_.reset();
621 android_management_checker_.reset(); 630 android_management_checker_.reset();
622 arc_bridge_service()->RequestStop(); 631 arc_bridge_service()->RequestStop();
623 if (state_ != State::NOT_INITIALIZED && state_ != State::REMOVING_DATA_DIR) 632 if (state_ != State::NOT_INITIALIZED && state_ != State::REMOVING_DATA_DIR)
624 SetState(State::STOPPED); 633 SetState(State::STOPPED);
(...skipping 16 matching lines...) Expand all
641 void ArcSessionManager::StopAndEnableArc() { 650 void ArcSessionManager::StopAndEnableArc() {
642 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 651 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
643 DCHECK(!arc_bridge_service()->stopped()); 652 DCHECK(!arc_bridge_service()->stopped());
644 reenable_arc_ = true; 653 reenable_arc_ = true;
645 StopArc(); 654 StopArc();
646 } 655 }
647 656
648 void ArcSessionManager::StartArc() { 657 void ArcSessionManager::StartArc() {
649 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 658 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
650 659
651 // Arc must be started only if no pending data removal request exists. 660 // ARC must be started only if no pending data removal request exists.
652 DCHECK(!profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); 661 DCHECK(!profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested));
653 662
654 provisioning_reported_ = false; 663 provisioning_reported_ = false;
655 664
656 arc_bridge_service()->RequestStart(); 665 arc_bridge_service()->RequestStart();
657 SetState(State::ACTIVE); 666 SetState(State::ACTIVE);
658 } 667 }
659 668
660 void ArcSessionManager::OnArcSignInTimeout() { 669 void ArcSessionManager::OnArcSignInTimeout() {
661 LOG(ERROR) << "Timed out waiting for first sign in."; 670 LOG(ERROR) << "Timed out waiting for first sign in.";
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 717
709 DCHECK(profile_); 718 DCHECK(profile_);
710 return profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); 719 return profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled);
711 } 720 }
712 721
713 void ArcSessionManager::EnableArc() { 722 void ArcSessionManager::EnableArc() {
714 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 723 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
715 DCHECK(profile_); 724 DCHECK(profile_);
716 725
717 if (IsArcEnabled()) { 726 if (IsArcEnabled()) {
718 OnOptInPreferenceChanged(); 727 OnOptInPreferenceChanged(false);
719 return; 728 return;
720 } 729 }
721 730
722 if (!IsArcManaged()) 731 if (!IsArcManaged())
723 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); 732 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, true);
724 } 733 }
725 734
726 void ArcSessionManager::DisableArc() { 735 void ArcSessionManager::DisableArc() {
727 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 736 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
728 DCHECK(profile_); 737 DCHECK(profile_);
729 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, false); 738 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, false);
730 } 739 }
731 740
732 void ArcSessionManager::RecordArcState() { 741 void ArcSessionManager::RecordArcState() {
733 // Only record Enabled state if ARC is allowed in the first place, so we do 742 // Only record Enabled state if ARC is allowed in the first place, so we do
734 // not split the ARC population by devices that cannot run ARC. 743 // not split the ARC population by devices that cannot run ARC.
735 if (IsAllowed()) 744 if (IsAllowed())
736 UpdateEnabledStateUMA(IsArcEnabled()); 745 UpdateEnabledStateUMA(IsArcEnabled());
737 } 746 }
738 747
739 void ArcSessionManager::StartTermsOfServiceNegotiation() { 748 void ArcSessionManager::StartTermsOfServiceNegotiation(bool initial_run) {
740 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 749 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
741 DCHECK(!terms_of_service_negotiator_); 750 DCHECK(!terms_of_service_negotiator_);
742 751
743 if (!arc_bridge_service()->stopped()) { 752 if (!arc_bridge_service()->stopped()) {
744 // If the user attempts to re-enable ARC while the bridge is still running 753 // If the user attempts to re-enable ARC while the bridge is still running
745 // the user should not be able to continue until the bridge has stopped. 754 // the user should not be able to continue until the bridge has stopped.
746 if (support_host_) { 755 if (support_host_) {
747 support_host_->ShowError( 756 support_host_->ShowError(
748 ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false); 757 ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false);
749 } 758 }
750 return; 759 return;
751 } 760 }
752 761
753 SetState(State::SHOWING_TERMS_OF_SERVICE); 762 SetState(State::SHOWING_TERMS_OF_SERVICE);
754 if (support_host_) { 763 if (initial_run && IsFirstRunForOobeEnabledUser() && IsArcManaged()) {
764 terms_of_service_negotiator_ = base::MakeUnique<
765 ArcTermsOfServiceInitialOobeNegotiatorForManagedUser>();
766 } else if (support_host_) {
755 terms_of_service_negotiator_ = 767 terms_of_service_negotiator_ =
756 base::MakeUnique<ArcTermsOfServiceNegotiator>(profile_->GetPrefs(), 768 base::MakeUnique<ArcTermsOfServiceDefaultNegotiator>(
757 support_host_.get()); 769 profile_->GetPrefs(), support_host_.get());
758 terms_of_service_negotiator_->StartNegotiation( 770 } else {
759 base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated, 771 // Happens in unit tests.
760 weak_ptr_factory_.GetWeakPtr())); 772 return;
761 } 773 }
774
775 terms_of_service_negotiator_->StartNegotiation(
776 base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated,
777 weak_ptr_factory_.GetWeakPtr()));
762 } 778 }
763 779
764 void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) { 780 void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) {
765 DCHECK(terms_of_service_negotiator_); 781 DCHECK(terms_of_service_negotiator_);
766 terms_of_service_negotiator_.reset(); 782 terms_of_service_negotiator_.reset();
767 783
768 if (!accepted) { 784 if (!accepted) {
769 // To cancel, user needs to close the window. Note that clicking "Cancel" 785 // To cancel, user needs to close the window. Note that clicking "Cancel"
770 // button effectively just closes the window. 786 // button effectively just closes the window.
771 CancelAuthCode(); 787 CancelAuthCode();
772 return; 788 return;
773 } 789 }
774 790
775 // Terms were accepted. 791 // Terms were accepted.
776 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); 792 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true);
777 793
778 support_host_->ShowArcLoading(); 794 if (support_host_ && support_host_->has_message_host())
795 support_host_->ShowArcLoading();
779 StartArcAndroidManagementCheck(); 796 StartArcAndroidManagementCheck();
780 } 797 }
781 798
782 void ArcSessionManager::StartArcAndroidManagementCheck() { 799 void ArcSessionManager::StartArcAndroidManagementCheck() {
783 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 800 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
784 DCHECK(arc_bridge_service()->stopped()); 801 DCHECK(arc_bridge_service()->stopped());
785 DCHECK(state_ == State::SHOWING_TERMS_OF_SERVICE || 802 DCHECK(state_ == State::SHOWING_TERMS_OF_SERVICE ||
786 state_ == State::CHECKING_ANDROID_MANAGEMENT); 803 state_ == State::CHECKING_ANDROID_MANAGEMENT ||
804 (state_ == State::STOPPED &&
805 profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)));
787 SetState(State::CHECKING_ANDROID_MANAGEMENT); 806 SetState(State::CHECKING_ANDROID_MANAGEMENT);
788 807
789 android_management_checker_.reset(new ArcAndroidManagementChecker( 808 android_management_checker_.reset(new ArcAndroidManagementChecker(
790 profile_, context_->token_service(), context_->account_id(), 809 profile_, context_->token_service(), context_->account_id(),
791 false /* retry_on_error */)); 810 false /* retry_on_error */));
792 android_management_checker_->StartCheck( 811 android_management_checker_->StartCheck(
793 base::Bind(&ArcSessionManager::OnAndroidManagementChecked, 812 base::Bind(&ArcSessionManager::OnAndroidManagementChecked,
794 weak_ptr_factory_.GetWeakPtr())); 813 weak_ptr_factory_.GetWeakPtr()));
795 } 814 }
796 815
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 void ArcSessionManager::OnRetryClicked() { 885 void ArcSessionManager::OnRetryClicked() {
867 DCHECK(support_host_); 886 DCHECK(support_host_);
868 887
869 UpdateOptInActionUMA(OptInActionType::RETRY); 888 UpdateOptInActionUMA(OptInActionType::RETRY);
870 889
871 // TODO(hidehiko): Simplify the retry logic. 890 // TODO(hidehiko): Simplify the retry logic.
872 if (terms_of_service_negotiator_) { 891 if (terms_of_service_negotiator_) {
873 // Currently Terms of service is shown. ArcTermsOfServiceNegotiator should 892 // Currently Terms of service is shown. ArcTermsOfServiceNegotiator should
874 // handle this. 893 // handle this.
875 } else if (!profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) { 894 } else if (!profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) {
876 StartTermsOfServiceNegotiation(); 895 StartTermsOfServiceNegotiation(false);
877 } else if (support_host_->ui_page() == ArcSupportHost::UIPage::ERROR && 896 } else if (support_host_->ui_page() == ArcSupportHost::UIPage::ERROR &&
878 !arc_bridge_service()->stopped()) { 897 !arc_bridge_service()->stopped()) {
879 // ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, stopping 898 // ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, stopping
880 // ARC was postponed to contain its internal state into the report. 899 // ARC was postponed to contain its internal state into the report.
881 // Here, on retry, stop it, then restart. 900 // Here, on retry, stop it, then restart.
882 DCHECK_EQ(State::ACTIVE, state_); 901 DCHECK_EQ(State::ACTIVE, state_);
883 support_host_->ShowArcLoading(); 902 support_host_->ShowArcLoading();
884 ShutdownBridge(); 903 ShutdownBridge();
885 reenable_arc_ = true; 904 reenable_arc_ = true;
886 } else if (state_ == State::ACTIVE) { 905 } else if (state_ == State::ACTIVE) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 return os << "ACTIVE"; 942 return os << "ACTIVE";
924 } 943 }
925 944
926 // Some compiler reports an error even if all values of an enum-class are 945 // Some compiler reports an error even if all values of an enum-class are
927 // covered indivisually in a switch statement. 946 // covered indivisually in a switch statement.
928 NOTREACHED(); 947 NOTREACHED();
929 return os; 948 return os;
930 } 949 }
931 950
932 } // namespace arc 951 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698