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

Unified Diff: chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc

Issue 1737453003: Revert of Reland: No longer start up profile if there was an error fetching policy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/policy/user_cloud_policy_manager_chromeos.cc
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc
index 8fa1b39e51f83eec3da46f3f08f077069fd1488b..7e3610c98731638ab9058f5e94913a29dc091afb 100644
--- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc
+++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc
@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/command_line.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/metrics/sparse_histogram.h"
@@ -25,7 +24,6 @@
#include "chrome/browser/chromeos/policy/wildcard_login_checker.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/common/chrome_content_client.h"
-#include "chromeos/chromeos_switches.h"
#include "components/policy/core/common/cloud/cloud_external_data_manager.h"
#include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h"
#include "components/policy/core/common/cloud/device_management_service.h"
@@ -33,7 +31,6 @@
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_pref_names.h"
#include "components/policy/core/common/policy_types.h"
-#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "net/url_request/url_request_context_getter.h"
#include "policy/policy_constants.h"
@@ -102,15 +99,7 @@
wait_for_policy_fetch_(wait_for_policy_fetch),
policy_fetch_timeout_(false, false) {
time_init_started_ = base::Time::Now();
-
- // Caller should pass a non-zero policy_fetch_timeout iff
- // |wait_for_policy_fetch| is true.
- DCHECK_NE(wait_for_policy_fetch_, initial_policy_fetch_timeout.is_zero());
- allow_failed_policy_fetches_ =
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kAllowFailedPolicyFetchForTest) ||
- !initial_policy_fetch_timeout.is_max();
- if (wait_for_policy_fetch_ && allow_failed_policy_fetches_) {
+ if (wait_for_policy_fetch_ && !initial_policy_fetch_timeout.is_max()) {
policy_fetch_timeout_.Start(
FROM_HERE,
initial_policy_fetch_timeout,
@@ -271,7 +260,7 @@
} else {
// If the client has switched to not registered, we bail out as this
// indicates the cloud policy setup flow has been aborted.
- CancelWaitForPolicyFetch(true);
+ CancelWaitForPolicyFetch();
}
}
}
@@ -283,18 +272,7 @@
UMA_HISTOGRAM_SPARSE_SLOWLY(kUMAInitialFetchClientError,
cloud_policy_client->status());
}
- switch (client()->status()) {
- case DM_STATUS_SUCCESS:
- case DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED:
- // If management is not supported for this user, then a registration
- // error is to be expected.
- CancelWaitForPolicyFetch(true);
- break;
- default:
- // Unexpected error fetching policy.
- CancelWaitForPolicyFetch(false);
- break;
- }
+ CancelWaitForPolicyFetch();
}
void UserCloudPolicyManagerChromeOS::OnComponentCloudPolicyUpdated() {
@@ -376,6 +354,9 @@
policy_token, std::string(), std::string(),
std::string());
} else {
+ // Failed to get a token, stop waiting and use an empty policy.
+ CancelWaitForPolicyFetch();
+
UMA_HISTOGRAM_ENUMERATION(kUMAInitialFetchOAuth2Error,
error.state(),
GoogleServiceAuthError::NUM_STATES);
@@ -385,9 +366,6 @@
UMA_HISTOGRAM_SPARSE_SLOWLY(kUMAInitialFetchOAuth2NetworkError,
-error.network_error());
}
- // Failed to get a token, stop waiting if policy is not required for this
- // user.
- CancelWaitForPolicyFetch(false);
}
token_fetcher_.reset();
@@ -400,38 +378,23 @@
now - time_client_registered_);
UMA_HISTOGRAM_MEDIUM_TIMES(kUMAInitialFetchDelayTotal,
now - time_init_started_);
- CancelWaitForPolicyFetch(success);
+ CancelWaitForPolicyFetch();
}
void UserCloudPolicyManagerChromeOS::OnBlockingFetchTimeout() {
if (!wait_for_policy_fetch_)
return;
- LOG(WARNING) << "Timed out while waiting for the policy fetch. "
- << "The session will start with the cached policy.";
- CancelWaitForPolicyFetch(false);
-}
-
-void UserCloudPolicyManagerChromeOS::CancelWaitForPolicyFetch(bool success) {
+ LOG(WARNING) << "Timed out while waiting for the initial policy fetch. "
+ << "The first session will start without policy.";
+ CancelWaitForPolicyFetch();
+}
+
+void UserCloudPolicyManagerChromeOS::CancelWaitForPolicyFetch() {
if (!wait_for_policy_fetch_)
return;
+ wait_for_policy_fetch_ = false;
policy_fetch_timeout_.Stop();
-
- // If there was an error, and we don't want to allow profile initialization
- // to go forward after a failed policy fetch, then just return (profile
- // initialization will not complete).
- // TODO(atwilson): Add code to retry policy fetching.
- if (!success && !allow_failed_policy_fetches_) {
- LOG(ERROR) << "Policy fetch failed for "
- << user_manager::UserManager::Get()->GetActiveUser()->email()
- << " - aborting profile initialization";
- // Need to exit the current user, because we've already started this user's
- // session.
- chrome::AttemptUserExit();
- return;
- }
-
- wait_for_policy_fetch_ = false;
CheckAndPublishPolicy();
// Now that |wait_for_policy_fetch_| is guaranteed to be false, the scheduler
// can be started.

Powered by Google App Engine
This is Rietveld 408576698