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

Unified Diff: chrome/browser/profiles/guest_mode_policy_handler.cc

Issue 2530943002: Disable guest mode by default if force sign in is enabled. (Closed)
Patch Set: fix presubmit warning Created 4 years, 1 month 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/profiles/guest_mode_policy_handler.cc
diff --git a/chrome/browser/profiles/guest_mode_policy_handler.cc b/chrome/browser/profiles/guest_mode_policy_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..151cf07cb6a837e3bb47895b661af9bbdd54469a
--- /dev/null
+++ b/chrome/browser/profiles/guest_mode_policy_handler.cc
@@ -0,0 +1,41 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/profiles/guest_mode_policy_handler.h"
+
+#include "base/values.h"
+#include "chrome/common/pref_names.h"
+#include "components/policy/core/common/policy_map.h"
+#include "components/policy/policy_constants.h"
+#include "components/prefs/pref_value_map.h"
+
+namespace policy {
+
+GuestModePolicyHandler::GuestModePolicyHandler()
+ : TypeCheckingPolicyHandler(key::kBrowserGuestModeEnabled,
+ base::Value::TYPE_BOOLEAN) {}
+
+GuestModePolicyHandler::~GuestModePolicyHandler() {}
+
+void GuestModePolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
+ PrefValueMap* prefs) {
+ const base::Value* guest_mode_value = policies.GetValue(policy_name());
+ bool is_guest_mode_enabled;
+ if (guest_mode_value &&
+ guest_mode_value->GetAsBoolean(&is_guest_mode_enabled)) {
+ prefs->SetBoolean(prefs::kBrowserGuestModeEnabled, is_guest_mode_enabled);
+ return;
+ }
+ // Disable guest mode by default if force signin is enabled.
+ const base::Value* force_signin_value =
+ policies.GetValue(key::kForceBrowserSignin);
+ bool is_force_signin_enabled;
+ if (force_signin_value &&
+ force_signin_value->GetAsBoolean(&is_force_signin_enabled) &&
+ is_force_signin_enabled) {
+ prefs->SetBoolean(prefs::kBrowserGuestModeEnabled, false);
+ }
+}
+
+} // namespace policy
« no previous file with comments | « chrome/browser/profiles/guest_mode_policy_handler.h ('k') | chrome/browser/profiles/guest_mode_policy_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698