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

Unified 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: comments addressed Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/arc_session_manager.cc
diff --git a/chrome/browser/chromeos/arc/arc_session_manager.cc b/chrome/browser/chromeos/arc/arc_session_manager.cc
index fdc74180993d965389de64eca4a8f0869cec6be3..8a0642937d1cd3f4c8ee441223e5c7d335dff421 100644
--- a/chrome/browser/chromeos/arc/arc_session_manager.cc
+++ b/chrome/browser/chromeos/arc/arc_session_manager.cc
@@ -20,9 +20,11 @@
#include "chrome/browser/chromeos/arc/arc_auth_notification.h"
#include "chrome/browser/chromeos/arc/arc_optin_uma.h"
#include "chrome/browser/chromeos/arc/arc_support_host.h"
-#include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_negotiator.h"
+#include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_default_negotiator.h"
+#include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator.h"
#include "chrome/browser/chromeos/arc/policy/arc_android_management_checker.h"
#include "chrome/browser/chromeos/arc/policy/arc_policy_util.h"
+#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/user_flow.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
@@ -129,6 +131,20 @@ void ArcSessionManager::RegisterProfilePrefs(
}
// static
+bool ArcSessionManager::IsOobeOptInActive() {
+ // ARC OOBE OptIn is optional for now. Test if it exists and login host is
+ // active.
+ if (!user_manager::UserManager::Get()->IsCurrentUserNew())
+ return false;
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableArcOOBEOptIn))
+ return false;
+ if (!chromeos::LoginDisplayHost::default_host())
+ return false;
+ return true;
+}
+
+// static
void ArcSessionManager::DisableUIForTesting() {
g_disable_ui_for_testing = true;
}
@@ -666,13 +682,18 @@ void ArcSessionManager::OnOptInPreferenceChanged() {
// 2) User accepted the Terms of service on Opt-in flow, but logged out
// before ARC sign in procedure was done. Then, logs in again.
if (profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) {
- support_host_->ShowArcLoading();
+ // Don't show UI for this progress if it was not shown.
+ if (support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE)
+ support_host_->ShowArcLoading();
StartArcAndroidManagementCheck();
return;
}
- // Need user's explicit Terms Of Service agreement.
- StartTermsOfServiceNegotiation();
+ // Need user's explicit Terms Of Service agreement. Prevent race condition
+ // when ARC can be enabled before profile is synced. In last case
+ // OnOptInPreferenceChanged is called twice.
+ if (state_ != State::SHOWING_TERMS_OF_SERVICE)
+ StartTermsOfServiceNegotiation();
}
void ArcSessionManager::ShutdownSession() {
@@ -838,10 +859,18 @@ void ArcSessionManager::StartTermsOfServiceNegotiation() {
}
SetState(State::SHOWING_TERMS_OF_SERVICE);
- if (support_host_) {
+ if (IsOobeOptInActive()) {
+ VLOG(1) << "Use OOBE negotiator.";
terms_of_service_negotiator_ =
- base::MakeUnique<ArcTermsOfServiceNegotiator>(profile_->GetPrefs(),
- support_host_.get());
+ base::MakeUnique<ArcTermsOfServiceOobeNegotiator>();
+ } else if (support_host_) {
+ VLOG(1) << "Use default negotiator.";
+ terms_of_service_negotiator_ =
+ base::MakeUnique<ArcTermsOfServiceDefaultNegotiator>(
+ profile_->GetPrefs(), support_host_.get());
+ }
+
+ if (terms_of_service_negotiator_) {
terms_of_service_negotiator_->StartNegotiation(
base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated,
weak_ptr_factory_.GetWeakPtr()));
@@ -862,7 +891,10 @@ void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) {
// Terms were accepted.
profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true);
- support_host_->ShowArcLoading();
+ // Don't show UI for this progress if it was not shown.
+ if (support_host_ &&
+ support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE)
+ support_host_->ShowArcLoading();
StartArcAndroidManagementCheck();
}
@@ -870,7 +902,9 @@ void ArcSessionManager::StartArcAndroidManagementCheck() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(arc_session_runner_->IsStopped());
DCHECK(state_ == State::SHOWING_TERMS_OF_SERVICE ||
- state_ == State::CHECKING_ANDROID_MANAGEMENT);
+ state_ == State::CHECKING_ANDROID_MANAGEMENT ||
+ (state_ == State::STOPPED &&
+ profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)));
SetState(State::CHECKING_ANDROID_MANAGEMENT);
android_management_checker_.reset(new ArcAndroidManagementChecker(

Powered by Google App Engine
This is Rietveld 408576698