Commit 4e1fcc3b authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Enables enterprise policy by default on non-stable channels.

Only enables the core policy infrastructure. The handlers that parse
policy data will remain disabled by default.

BUG=1024115

Change-Id: I57d38c44313a6b545353eb1f8c0d1a55b92a5e3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2127946Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755325}
parent 9c1ace26
...@@ -45,7 +45,9 @@ source_set("feature_flags") { ...@@ -45,7 +45,9 @@ source_set("feature_flags") {
] ]
deps = [ deps = [
"//base", "//base",
"//components/version_info",
"//ios/chrome/browser:utils", "//ios/chrome/browser:utils",
"//ios/chrome/common",
] ]
} }
......
...@@ -44,10 +44,13 @@ std::unique_ptr<policy::ConfigurationPolicyHandlerList> BuildPolicyHandlerList( ...@@ -44,10 +44,13 @@ std::unique_ptr<policy::ConfigurationPolicyHandlerList> BuildPolicyHandlerList(
base::Bind(&PopulatePolicyHandlerParameters), base::Bind(&PopulatePolicyHandlerParameters),
base::Bind(&policy::GetChromePolicyDetails)); base::Bind(&policy::GetChromePolicyDetails));
for (size_t i = 0; i < base::size(kSimplePolicyMap); ++i) { // Check the feature flag before adding handlers to the list.
handlers->AddHandler(std::make_unique<SimplePolicyHandler>( if (ShouldInstallEnterprisePolicyHandlers()) {
kSimplePolicyMap[i].policy_name, kSimplePolicyMap[i].preference_path, for (size_t i = 0; i < base::size(kSimplePolicyMap); ++i) {
kSimplePolicyMap[i].value_type)); handlers->AddHandler(std::make_unique<SimplePolicyHandler>(
kSimplePolicyMap[i].policy_name, kSimplePolicyMap[i].preference_path,
kSimplePolicyMap[i].value_type));
}
} }
return handlers; return handlers;
......
...@@ -5,12 +5,30 @@ ...@@ -5,12 +5,30 @@
#include "ios/chrome/browser/policy/policy_features.h" #include "ios/chrome/browser/policy/policy_features.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "components/version_info/version_info.h"
#include "ios/chrome/browser/chrome_switches.h" #include "ios/chrome/browser/chrome_switches.h"
#include "ios/chrome/common/channel_info.h"
bool IsEnterprisePolicyEnabled() { namespace {
// Returns true if the current command line contains the
// |kEnableEnterprisePolicy| switch.
bool IsEnableEnterprisePolicySwitchPresent() {
// This feature is controlled via the command line because policy must be // This feature is controlled via the command line because policy must be
// initialized before about:flags or field trials. Using a command line flag // initialized before about:flags or field trials. Using a command line flag
// is the only way to control this feature at runtime. // is the only way to control this feature at runtime.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
return command_line->HasSwitch(switches::kEnableEnterprisePolicy); return command_line->HasSwitch(switches::kEnableEnterprisePolicy);
} }
} // namespace
bool IsEnterprisePolicyEnabled() {
// Policy is enabled by default for non-stable channels.
return GetChannel() != version_info::Channel::STABLE ||
IsEnableEnterprisePolicySwitchPresent();
}
bool ShouldInstallEnterprisePolicyHandlers() {
return IsEnableEnterprisePolicySwitchPresent();
}
...@@ -5,7 +5,13 @@ ...@@ -5,7 +5,13 @@
#ifndef IOS_CHROME_BROWSER_POLICY_POLICY_FEATURES_H_ #ifndef IOS_CHROME_BROWSER_POLICY_POLICY_FEATURES_H_
#define IOS_CHROME_BROWSER_POLICY_POLICY_FEATURES_H_ #define IOS_CHROME_BROWSER_POLICY_POLICY_FEATURES_H_
// Returns true if enterprise policy support is enabled. // Returns true if the core enterprise policy infrastructure is enabled. Does
// not control whether policy data is parsed and made user visible; that is
// controlled by |ShouldInstallEnterprisePolicyHandlers()| below.
bool IsEnterprisePolicyEnabled(); bool IsEnterprisePolicyEnabled();
// Returns true if enterprise policy handlers should be installed to parse
// policy data and make it user visible.
bool ShouldInstallEnterprisePolicyHandlers();
#endif // IOS_CHROME_BROWSER_POLICY_POLICY_FEATURES_H_ #endif // IOS_CHROME_BROWSER_POLICY_POLICY_FEATURES_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment