Commit 68696843 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Add ManagedBookmark flags

This CL creates two flags:

1) ShouldInstallManagedBookmarksPolicyHandler() checks the presence of
a command line flag to decide whether to install the ManagedBookmarks
policy handler. See below for explanation of the need to use a command
line flag.

2) IsManagedBookmarksEnabled() checks a Finch feature flag to decide
whether to show the managed bookmarks in the bookmarks UI. A Finch
feature flag is used to act as a server-side kill switch.


The policy system is initialized before about:flags or field trials, so
it is not possible for either of those mechanisms to decide whether or
not policy should be enabled at runtime. Instead, we will switch to
looking for the presence (or absence) of a command line flag. This will
allow us to easily turn policy on locally during development, and when
we are ready to ship policy support, we can remove the command line
flag.

Bug: 1065187
Change-Id: I1aea8c106642ec86b422e4bb333294d05d3dba95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2142752
Commit-Queue: edchin <edchin@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757906}
parent 4bd6ec7a
......@@ -2747,6 +2747,11 @@
"owners": [ "kerrnel@google.com" ],
"expiry_milestone": 88
},
{
"name": "managed-bookmarks-ios",
"owners": [ "edchin", "rohitrao" ],
"expiry_milestone": 90
},
{
"name": "media-app",
"owners": [ "//chromeos/components/media_app_ui/OWNERS" ],
......
......@@ -36,6 +36,10 @@ const char kEnableSpotlightActions[] = "enable-spotlight-actions";
const char kEnableThirdPartyKeyboardWorkaround[] =
"enable-third-party-keyboard-workaround";
// Installs the managed bookmarks policy handler.
const char kInstallManagedBookmarksHandler[] =
"install-managed-bookmarks-handler";
// A string used to override the default user agent with a custom one.
const char kUserAgent[] = "user-agent";
......
......@@ -16,6 +16,7 @@ extern const char kEnableEnterprisePolicy[];
extern const char kEnableIOSHandoffToOtherDevices[];
extern const char kEnableSpotlightActions[];
extern const char kEnableThirdPartyKeyboardWorkaround[];
extern const char kInstallManagedBookmarksHandler[];
extern const char kUserAgent[];
......
......@@ -46,6 +46,7 @@ source_set("flags") {
"//ios/chrome/browser/drag_and_drop",
"//ios/chrome/browser/find_in_page:feature_flags",
"//ios/chrome/browser/passwords:feature_flags",
"//ios/chrome/browser/policy:feature_flags",
"//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui/download:features",
"//ios/chrome/browser/ui/fullscreen:feature_flags",
......
......@@ -57,6 +57,7 @@
#include "ios/chrome/browser/find_in_page/features.h"
#include "ios/chrome/browser/flags/ios_chrome_flag_descriptions.h"
#include "ios/chrome/browser/passwords/password_manager_features.h"
#include "ios/chrome/browser/policy/policy_features.h"
#include "ios/chrome/browser/system_flags.h"
#import "ios/chrome/browser/ui/download/features.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
......@@ -592,6 +593,9 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
flags_ui::kOsIos,
FEATURE_VALUE_TYPE(
autofill::features::kAutofillEnableSurfacingServerCardNickname)},
{"managed-bookmarks-ios", flag_descriptions::kManagedBookmarksIOSName,
flag_descriptions::kManagedBookmarksIOSDescription, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(kManagedBookmarksIOS)},
};
// Add all switches from experimental flags to |command_line|.
......
......@@ -278,6 +278,11 @@ const char kLockBottomToolbarDescription[] =
"When enabled, the bottom toolbar will not get collapsed when scrolling "
"into fullscreen mode.";
const char kManagedBookmarksIOSName[] = "Managed Bookmarks IOS";
const char kManagedBookmarksIOSDescription[] =
"When enabled, managed bookmarks set by an enterprise policy can be shown "
"in the bookmarks UI on iOS";
const char kMarkHttpAsName[] = "Mark non-secure origins as non-secure";
const char kMarkHttpAsDescription[] = "Change the UI treatment for HTTP pages";
......
......@@ -235,6 +235,11 @@ extern const char kIOSLookalikeUrlNavigationSuggestionsUIDescription[];
extern const char kLockBottomToolbarName[];
extern const char kLockBottomToolbarDescription[];
// Title and description for the flag to enable ManagedBookmarks enterprise
// policy on iOS.
extern const char kManagedBookmarksIOSName[];
extern const char kManagedBookmarksIOSDescription[];
// Title, description, and options for the MarkHttpAs setting that controls
// display of omnibox warnings about non-secure pages.
extern const char kMarkHttpAsName[];
......
......@@ -9,6 +9,9 @@
#include "ios/chrome/browser/chrome_switches.h"
#include "ios/chrome/common/channel_info.h"
const base::Feature kManagedBookmarksIOS{"ManagedBookmarksIOS",
base::FEATURE_DISABLED_BY_DEFAULT};
namespace {
// Returns true if the current command line contains the
......@@ -32,3 +35,16 @@ bool IsEnterprisePolicyEnabled() {
bool ShouldInstallEnterprisePolicyHandlers() {
return IsEnableEnterprisePolicySwitchPresent();
}
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);
}
bool IsManagedBookmarksEnabled() {
return ShouldInstallManagedBookmarksPolicyHandler() &&
base::FeatureList::IsEnabled(kManagedBookmarksIOS);
}
......@@ -5,6 +5,11 @@
#ifndef IOS_CHROME_BROWSER_POLICY_POLICY_FEATURES_H_
#define IOS_CHROME_BROWSER_POLICY_POLICY_FEATURES_H_
#include "base/feature_list.h"
// Feature flag for supporting the ManagedBookmarks enterprise policy on iOS.
extern const base::Feature kManagedBookmarksIOS;
// 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.
......@@ -14,4 +19,11 @@ bool IsEnterprisePolicyEnabled();
// policy data and make it user visible.
bool ShouldInstallEnterprisePolicyHandlers();
// Returns true if the ManagedBookmarks policy handler should be installed to
// parse policy data and make it user visible.
bool ShouldInstallManagedBookmarksPolicyHandler();
// Returns true if ManagedBookmarks enterprise policy is enabled.
bool IsManagedBookmarksEnabled();
#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