Commit 344f12fa authored by Guillaume Jenkins's avatar Guillaume Jenkins Committed by Commit Bot

[iOS CBCM] Add command-line switch to enable CBCM on iOS

In preparation for bringing Chrome Browser Cloud Management to iOS, this
adds a command-line switch to control whether CBCM is enabled. It needs
to be a command-line flag because policy infrastructure is initialized
before Finch / about flags and field trials.

Bug: 1066495
Change-Id: I0bd27e5ee863deda949afa64b248ca5445f9ef8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2316620
Commit-Queue: Guillaume Jenkins <gujen@google.com>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791912}
parent b681e1bf
......@@ -24,6 +24,10 @@ const char kDisableIOSPasswordSuggestions[] =
const char kDisableThirdPartyKeyboardWorkaround[] =
"disable-third-party-keyboard-workaround";
// Enables Chrome Browser Cloud Management flow.
const char kEnableChromeBrowserCloudManagement[] =
"enable-chrome-browser-cloud-management";
// Enables enterprise policy support.
const char kEnableEnterprisePolicy[] = "enable-enterprise-policy";
......
......@@ -13,6 +13,7 @@ extern const char kDisableEnterprisePolicy[];
extern const char kDisableIOSPasswordSuggestions[];
extern const char kDisableThirdPartyKeyboardWorkaround[];
extern const char kEnableChromeBrowserCloudManagement[];
extern const char kEnableEnterprisePolicy[];
extern const char kEnableIOSHandoffToOtherDevices[];
extern const char kEnableSpotlightActions[];
......
......@@ -4,6 +4,8 @@
#include "ios/chrome/browser/policy/policy_features.h"
#include <string>
#include "base/command_line.h"
#include "components/version_info/version_info.h"
#include "ios/chrome/browser/chrome_switches.h"
......@@ -21,18 +23,27 @@ const base::Feature kURLBlocklistIOS{"URLBlocklistIOS",
namespace {
bool HasSwitch(const std::string& switch_name) {
// Most policy features must be controlled via the command line because policy
// infrastructure must be initialized before about:flags or field trials.
// Using a command line flag is the only way to control these features at
// runtime.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
return command_line->HasSwitch(switch_name);
}
// Returns true if the current command line contains the
// |kDisableEnterprisePolicy| switch.
bool IsDisableEnterprisePolicySwitchPresent() {
// This feature is controlled via the command line because policy must be
// initialized before about:flags or field trials. Using a command line flag
// is the only way to control this feature at runtime.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
return command_line->HasSwitch(switches::kDisableEnterprisePolicy);
return HasSwitch(switches::kDisableEnterprisePolicy);
}
} // namespace
bool IsChromeBrowserCloudManagementEnabled() {
return HasSwitch(switches::kEnableChromeBrowserCloudManagement);
}
bool IsEditBookmarksIOSEnabled() {
return base::FeatureList::IsEnabled(kEditBookmarksIOS);
}
......@@ -46,11 +57,7 @@ bool ShouldInstallEnterprisePolicyHandlers() {
}
bool ShouldInstallManagedBookmarksPolicyHandler() {
// This feature is controlled via the command line because policy must be
// initialized before about:flags or field trials. Using a command line flag
// is the only way to control this feature at runtime.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
return command_line->HasSwitch(switches::kInstallManagedBookmarksHandler);
return HasSwitch(switches::kInstallManagedBookmarksHandler);
}
bool IsManagedBookmarksEnabled() {
......@@ -59,11 +66,7 @@ bool IsManagedBookmarksEnabled() {
}
bool ShouldInstallURLBlocklistPolicyHandlers() {
// This feature is controlled via the command line because policy must be
// initialized before about:flags or field trials. Using a command line flag
// is the only way to control this feature at runtime.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
return command_line->HasSwitch(switches::kInstallURLBlocklistHandlers);
return HasSwitch(switches::kInstallURLBlocklistHandlers);
}
bool IsURLBlocklistEnabled() {
......
......@@ -15,6 +15,9 @@ extern const base::Feature kManagedBookmarksIOS;
// Feature flag for supporting the URLBlocklist enterprise policy on iOS.
extern const base::Feature kURLBlocklistIOS;
// Returns true if the Chrome Browser Cloud Management flow is enabled.
bool IsChromeBrowserCloudManagementEnabled();
// Returns true if EditBookmarksEnabled enterprise policy is supported on iOS.
bool IsEditBookmarksIOSEnabled();
......
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