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[] = ...@@ -24,6 +24,10 @@ const char kDisableIOSPasswordSuggestions[] =
const char kDisableThirdPartyKeyboardWorkaround[] = const char kDisableThirdPartyKeyboardWorkaround[] =
"disable-third-party-keyboard-workaround"; "disable-third-party-keyboard-workaround";
// Enables Chrome Browser Cloud Management flow.
const char kEnableChromeBrowserCloudManagement[] =
"enable-chrome-browser-cloud-management";
// Enables enterprise policy support. // Enables enterprise policy support.
const char kEnableEnterprisePolicy[] = "enable-enterprise-policy"; const char kEnableEnterprisePolicy[] = "enable-enterprise-policy";
......
...@@ -13,6 +13,7 @@ extern const char kDisableEnterprisePolicy[]; ...@@ -13,6 +13,7 @@ extern const char kDisableEnterprisePolicy[];
extern const char kDisableIOSPasswordSuggestions[]; extern const char kDisableIOSPasswordSuggestions[];
extern const char kDisableThirdPartyKeyboardWorkaround[]; extern const char kDisableThirdPartyKeyboardWorkaround[];
extern const char kEnableChromeBrowserCloudManagement[];
extern const char kEnableEnterprisePolicy[]; extern const char kEnableEnterprisePolicy[];
extern const char kEnableIOSHandoffToOtherDevices[]; extern const char kEnableIOSHandoffToOtherDevices[];
extern const char kEnableSpotlightActions[]; extern const char kEnableSpotlightActions[];
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "ios/chrome/browser/policy/policy_features.h" #include "ios/chrome/browser/policy/policy_features.h"
#include <string>
#include "base/command_line.h" #include "base/command_line.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "ios/chrome/browser/chrome_switches.h" #include "ios/chrome/browser/chrome_switches.h"
...@@ -21,18 +23,27 @@ const base::Feature kURLBlocklistIOS{"URLBlocklistIOS", ...@@ -21,18 +23,27 @@ const base::Feature kURLBlocklistIOS{"URLBlocklistIOS",
namespace { 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 // Returns true if the current command line contains the
// |kDisableEnterprisePolicy| switch. // |kDisableEnterprisePolicy| switch.
bool IsDisableEnterprisePolicySwitchPresent() { bool IsDisableEnterprisePolicySwitchPresent() {
// This feature is controlled via the command line because policy must be return HasSwitch(switches::kDisableEnterprisePolicy);
// 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);
} }
} // namespace } // namespace
bool IsChromeBrowserCloudManagementEnabled() {
return HasSwitch(switches::kEnableChromeBrowserCloudManagement);
}
bool IsEditBookmarksIOSEnabled() { bool IsEditBookmarksIOSEnabled() {
return base::FeatureList::IsEnabled(kEditBookmarksIOS); return base::FeatureList::IsEnabled(kEditBookmarksIOS);
} }
...@@ -46,11 +57,7 @@ bool ShouldInstallEnterprisePolicyHandlers() { ...@@ -46,11 +57,7 @@ bool ShouldInstallEnterprisePolicyHandlers() {
} }
bool ShouldInstallManagedBookmarksPolicyHandler() { bool ShouldInstallManagedBookmarksPolicyHandler() {
// This feature is controlled via the command line because policy must be return HasSwitch(switches::kInstallManagedBookmarksHandler);
// 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);
} }
bool IsManagedBookmarksEnabled() { bool IsManagedBookmarksEnabled() {
...@@ -59,11 +66,7 @@ bool IsManagedBookmarksEnabled() { ...@@ -59,11 +66,7 @@ bool IsManagedBookmarksEnabled() {
} }
bool ShouldInstallURLBlocklistPolicyHandlers() { bool ShouldInstallURLBlocklistPolicyHandlers() {
// This feature is controlled via the command line because policy must be return HasSwitch(switches::kInstallURLBlocklistHandlers);
// 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);
} }
bool IsURLBlocklistEnabled() { bool IsURLBlocklistEnabled() {
......
...@@ -15,6 +15,9 @@ extern const base::Feature kManagedBookmarksIOS; ...@@ -15,6 +15,9 @@ extern const base::Feature kManagedBookmarksIOS;
// Feature flag for supporting the URLBlocklist enterprise policy on iOS. // Feature flag for supporting the URLBlocklist enterprise policy on iOS.
extern const base::Feature kURLBlocklistIOS; 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. // Returns true if EditBookmarksEnabled enterprise policy is supported on iOS.
bool IsEditBookmarksIOSEnabled(); 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