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

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 addresses 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 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 256e1190a53f8f5e27ed05387a91261cf7a7ec29..5b7db9d86567a2f7a3d3e647bd0b3d9ed43bbcd0 100644
--- a/chrome/browser/chromeos/arc/arc_session_manager.cc
+++ b/chrome/browser/chromeos/arc/arc_session_manager.cc
@@ -17,7 +17,8 @@
#include "chrome/browser/chromeos/arc/arc_auth_context.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_initial_oobe_negotiator_for_managed_user.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/user_flow.h"
@@ -78,6 +79,14 @@ ash::ShelfDelegate* GetShelfDelegate() {
return nullptr;
}
+// Returns true if this is the first user's login session and Arc OOBE is
+// enabled.
+bool IsFirstRunForOobeEnabledUser() {
+ return user_manager::UserManager::Get()->IsCurrentUserNew() &&
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableArcOOBEOptIn);
+}
+
} // namespace
ArcSessionManager::ArcSessionManager(ArcBridgeService* bridge_service)
@@ -270,7 +279,7 @@ void ArcSessionManager::MaybeReenableArc() {
void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- // Due asynchronous nature of stopping Arc bridge, OnProvisioningFinished may
+ // Due asynchronous nature of stopping ARC bridge, OnProvisioningFinished may
// arrive after setting the |State::STOPPED| state and |State::Active| is not
// guaranty set here. prefs::kArcDataRemoveRequested is also can be active
// for now.
@@ -445,11 +454,12 @@ void ArcSessionManager::OnPrimaryUserProfilePrepared(Profile* profile) {
g_enable_check_android_management_for_testing) {
ArcAndroidManagementChecker::StartClient();
}
+
pref_change_registrar_.Init(profile_->GetPrefs());
pref_change_registrar_.Add(
prefs::kArcEnabled,
base::Bind(&ArcSessionManager::OnOptInPreferenceChanged,
- weak_ptr_factory_.GetWeakPtr()));
+ weak_ptr_factory_.GetWeakPtr(), false /* initial_run */));
if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) {
// Don't start ARC if there is a pending request to remove the data. Restart
// ARC once data removal finishes.
@@ -457,7 +467,7 @@ void ArcSessionManager::OnPrimaryUserProfilePrepared(Profile* profile) {
reenable_arc_ = true;
RemoveArcData();
} else {
- OnOptInPreferenceChanged();
+ OnOptInPreferenceChanged(true /* initial_run */);
}
} else {
RemoveArcData();
@@ -475,7 +485,7 @@ void ArcSessionManager::OnIsSyncingChanged() {
pref_service_syncable->RemoveObserver(this);
if (IsArcEnabled())
- OnOptInPreferenceChanged();
+ OnOptInPreferenceChanged(false);
}
void ArcSessionManager::Shutdown() {
@@ -526,7 +536,7 @@ void ArcSessionManager::StopArc() {
support_host_->Close();
}
-void ArcSessionManager::OnOptInPreferenceChanged() {
+void ArcSessionManager::OnOptInPreferenceChanged(bool initial_run) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(profile_);
@@ -549,7 +559,7 @@ void ArcSessionManager::OnOptInPreferenceChanged() {
return;
if (state_ == State::REMOVING_DATA_DIR) {
- // Data removal request is in progress. Set flag to re-enable Arc once it is
+ // Data removal request is in progress. Set flag to re-enable ARC once it is
// finished.
reenable_arc_ = true;
return;
@@ -604,13 +614,12 @@ 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();
StartArcAndroidManagementCheck();
return;
}
- // Need user's explicit Terms Of Service agreement.
- StartTermsOfServiceNegotiation();
+ // Need user's explicit Terms Of Service acceptance.
+ StartTermsOfServiceNegotiation(initial_run);
}
void ArcSessionManager::ShutdownBridge() {
@@ -647,7 +656,7 @@ void ArcSessionManager::StopAndEnableArc() {
void ArcSessionManager::StartArc() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- // Arc must be started only if no pending data removal request exists.
+ // ARC must be started only if no pending data removal request exists.
DCHECK(!profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested));
provisioning_reported_ = false;
@@ -714,7 +723,7 @@ void ArcSessionManager::EnableArc() {
DCHECK(profile_);
if (IsArcEnabled()) {
- OnOptInPreferenceChanged();
+ OnOptInPreferenceChanged(false);
return;
}
@@ -735,7 +744,7 @@ void ArcSessionManager::RecordArcState() {
UpdateEnabledStateUMA(IsArcEnabled());
}
-void ArcSessionManager::StartTermsOfServiceNegotiation() {
+void ArcSessionManager::StartTermsOfServiceNegotiation(bool initial_run) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(!terms_of_service_negotiator_);
@@ -750,14 +759,21 @@ void ArcSessionManager::StartTermsOfServiceNegotiation() {
}
SetState(State::SHOWING_TERMS_OF_SERVICE);
- if (support_host_) {
+ if (initial_run && IsFirstRunForOobeEnabledUser() && IsArcManaged()) {
+ terms_of_service_negotiator_ = base::MakeUnique<
+ ArcTermsOfServiceInitialOobeNegotiatorForManagedUser>();
+ } else if (support_host_) {
terms_of_service_negotiator_ =
- base::MakeUnique<ArcTermsOfServiceNegotiator>(profile_->GetPrefs(),
- support_host_.get());
- terms_of_service_negotiator_->StartNegotiation(
- base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated,
- weak_ptr_factory_.GetWeakPtr()));
+ base::MakeUnique<ArcTermsOfServiceDefaultNegotiator>(
+ profile_->GetPrefs(), support_host_.get());
+ } else {
+ // Happens in unit tests.
+ return;
}
+
+ terms_of_service_negotiator_->StartNegotiation(
+ base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated,
+ weak_ptr_factory_.GetWeakPtr()));
}
void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) {
@@ -774,7 +790,8 @@ void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) {
// Terms were accepted.
profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true);
- support_host_->ShowArcLoading();
+ if (support_host_)
+ support_host_->ShowArcLoading(false);
StartArcAndroidManagementCheck();
}
@@ -782,7 +799,9 @@ void ArcSessionManager::StartArcAndroidManagementCheck() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(arc_bridge_service()->stopped());
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(
@@ -854,9 +873,9 @@ void ArcSessionManager::OnWindowClosed() {
CancelAuthCode();
}
-void ArcSessionManager::OnTermsAgreed(bool is_metrics_enabled,
- bool is_backup_and_restore_enabled,
- bool is_location_service_enabled) {
+void ArcSessionManager::OnTermsAccepted(bool is_metrics_enabled,
+ bool is_backup_and_restore_enabled,
+ bool is_location_service_enabled) {
DCHECK(support_host_);
DCHECK(terms_of_service_negotiator_);
// This should be handled in ArcTermsOfServiceNegotiator. Do nothing here.
@@ -872,14 +891,14 @@ void ArcSessionManager::OnRetryClicked() {
// Currently Terms of service is shown. ArcTermsOfServiceNegotiator should
// handle this.
} else if (!profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) {
- StartTermsOfServiceNegotiation();
+ StartTermsOfServiceNegotiation(false);
} else if (support_host_->ui_page() == ArcSupportHost::UIPage::ERROR &&
!arc_bridge_service()->stopped()) {
// ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, stopping
// ARC was postponed to contain its internal state into the report.
// Here, on retry, stop it, then restart.
DCHECK_EQ(State::ACTIVE, state_);
- support_host_->ShowArcLoading();
+ support_host_->ShowArcLoading(true);
ShutdownBridge();
reenable_arc_ = true;
} else if (state_ == State::ACTIVE) {
@@ -889,7 +908,7 @@ void ArcSessionManager::OnRetryClicked() {
// Otherwise, we restart ARC. Note: this is the first boot case.
// For second or later boot, either ERROR_WITH_FEEDBACK case or ACTIVE
// case must hit.
- support_host_->ShowArcLoading();
+ support_host_->ShowArcLoading(true);
StartArcAndroidManagementCheck();
}
}

Powered by Google App Engine
This is Rietveld 408576698