Expose the MacViewsWebUIDialogs feature flag to chrome://flags
Currently it's enabled via --enable=features=MacViewsWebUIDialogs, but
we want to allow changing it in chrome://flags as well.
Replace the old-style --enable-mac-views-dialogs switch for other dialog
types with a feature flag as well to be consistent. Now it is
--enable-features=MacViewsNativeDialogs.
BUG=603373
Review-Url: https://codereview.chromium.org/2004043003
Cr-Commit-Position: refs/heads/master@{#396100}
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index c3e19df..d2bf6598 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6594,11 +6594,17 @@
<message name="IDS_FLAGS_APP_WINDOW_CYCLING_DESCRIPTION" desc="Description of flag to enable or disable custom Cmd+` App window cycling on Mac.">
Changes the behavior of Cmd+` when a Chrome App becomes active. When enabled, Chrome Apps will not be cycled when Cmd+` is pressed from a browser window, and browser windows will not be cycled when a Chrome App is active.
</message>
- <message name="IDS_FLAGS_MAC_VIEWS_DIALOGS_NAME" desc="Name of the flag to enable toolkit-views browser dialogs on Mac.">
- Toolkit-Views Browser Dialogs.
+ <message name="IDS_FLAGS_MAC_VIEWS_NATIVE_DIALOGS_NAME" desc="Name of the flag to enable toolkit-views for native-looking browser dialogs on Mac." translateable="false">
+ Toolkit-Views Native-style Browser Dialogs.
</message>
- <message name="IDS_FLAGS_MAC_VIEWS_DIALOGS_DESCRIPTION" desc="Description of the flag to enable toolkit-views browser dialogs on Mac.">
- Causes Chrome on Mac to use a toolkit-views browser dialog when available, in place of the equivalent Cocoa dialog.
+ <message name="IDS_FLAGS_MAC_VIEWS_NATIVE_DIALOGS_DESCRIPTION" desc="Description of the flag to enable toolkit-views for native-looking browser dialogs on Mac." translateable="false">
+ Use toolkit-views dialogs in place of the native Cocoa dialogs that use unaltered OSX-style buttons.
+ </message>
+ <message name="IDS_FLAGS_MAC_VIEWS_WEBUI_DIALOGS_NAME" desc="Name of the flag to enable toolkit-views for WebUI-themed browser dialogs on Mac." translateable="false">
+ Toolkit-Views WebUI-style Browser Dialogs.
+ </message>
+ <message name="IDS_FLAGS_MAC_VIEWS_WEBUI_DIALOGS_DESCRIPTION" desc="Description of the flag to enable toolkit-views for WebUI-themed browser dialogs on Mac." translateable="false">
+ Use toolkit-views dialogs in place of the native Cocoa dialogs that use square, grey, webui-style buttons.
</message>
</if>
<if expr="chromeos">
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 180fcdc..ec958d8 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -88,6 +88,10 @@
#include "third_party/cros_system_api/switches/chrome_switches.h"
#endif
+#if defined(OS_MACOSX)
+#include "chrome/browser/ui/browser_dialogs.h"
+#endif
+
#if defined(ENABLE_APP_LIST)
#include "ui/app_list/app_list_switches.h"
#endif
@@ -1576,9 +1580,12 @@
IDS_FLAGS_APP_WINDOW_CYCLING_DESCRIPTION, kOsMac,
ENABLE_DISABLE_VALUE_TYPE(switches::kEnableAppWindowCycling,
switches::kDisableAppWindowCycling)},
- {"mac-views-dialogs", IDS_FLAGS_MAC_VIEWS_DIALOGS_NAME,
- IDS_FLAGS_MAC_VIEWS_DIALOGS_DESCRIPTION, kOsMac,
- SINGLE_VALUE_TYPE(switches::kEnableMacViewsDialogs)},
+ {"mac-views-native-dialogs", IDS_FLAGS_MAC_VIEWS_NATIVE_DIALOGS_NAME,
+ IDS_FLAGS_MAC_VIEWS_NATIVE_DIALOGS_DESCRIPTION, kOsMac,
+ FEATURE_VALUE_TYPE(chrome::kMacViewsNativeDialogs)},
+ {"mac-views-webui-dialogs", IDS_FLAGS_MAC_VIEWS_WEBUI_DIALOGS_NAME,
+ IDS_FLAGS_MAC_VIEWS_WEBUI_DIALOGS_DESCRIPTION, kOsMac,
+ FEATURE_VALUE_TYPE(chrome::kMacViewsWebUIDialogs)},
#endif
#if defined(ENABLE_WEBVR)
{"enable-webvr", IDS_FLAGS_WEBVR_NAME, IDS_FLAGS_WEBVR_DESCRIPTION, kOsAll,
diff --git a/chrome/browser/ui/browser_dialogs.h b/chrome/browser/ui/browser_dialogs.h
index 968999d..864cfda 100644
--- a/chrome/browser/ui/browser_dialogs.h
+++ b/chrome/browser/ui/browser_dialogs.h
@@ -18,6 +18,10 @@
class LoginHandler;
class Profile;
+namespace base {
+struct Feature;
+}
+
namespace bookmarks {
class BookmarkBubbleObserver;
}
@@ -48,6 +52,14 @@
namespace chrome {
+#if defined(OS_MACOSX)
+// Makes ToolkitViewsDialogsEnabled() available to chrome://flags.
+extern const base::Feature kMacViewsNativeDialogs;
+
+// Makes ToolkitViewsWebUIDialogsEnabled() available to chrome://flags.
+extern const base::Feature kMacViewsWebUIDialogs;
+#endif // OS_MACOSX
+
// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
// Returns a pointer to the underlying TableModel, which can be ignored, or used
// for testing.
@@ -85,12 +97,11 @@
#if defined(OS_MACOSX)
// For Mac, returns true if Chrome should show an equivalent toolkit-views based
-// dialog using one of the functions below, rather than showing a Cocoa dialog.
+// dialog instead of a native-looking Cocoa dialog.
bool ToolkitViewsDialogsEnabled();
// For Mac, returns true if Chrome should show an equivalent toolkit-views based
-// dialog instead of a WebUI-styled Cocoa dialog. ToolkitViewsDialogsEnabled()
-// implies ToolkitViewsWebUIDialogsEnabled().
+// dialog instead of a WebUI-styled Cocoa dialog.
bool ToolkitViewsWebUIDialogsEnabled();
// Shows a Views website settings bubble at the given anchor point.
diff --git a/chrome/browser/ui/browser_dialogs_mac.cc b/chrome/browser/ui/browser_dialogs_mac.cc
index a85fbcb..2fd94ae 100644
--- a/chrome/browser/ui/browser_dialogs_mac.cc
+++ b/chrome/browser/ui/browser_dialogs_mac.cc
@@ -4,19 +4,20 @@
#include "chrome/browser/ui/browser_dialogs.h"
-#include "base/command_line.h"
#include "base/feature_list.h"
-#include "chrome/common/chrome_switches.h"
+
+namespace chrome {
+
+const base::Feature kMacViewsNativeDialogs {
+ "MacViewsNativeDialogs", base::FEATURE_DISABLED_BY_DEFAULT
+};
const base::Feature kMacViewsWebUIDialogs {
"MacViewsWebUIDialogs", base::FEATURE_DISABLED_BY_DEFAULT
};
-namespace chrome {
-
bool ToolkitViewsDialogsEnabled() {
- return base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableMacViewsDialogs);
+ return base::FeatureList::IsEnabled(kMacViewsNativeDialogs);
}
bool ToolkitViewsWebUIDialogsEnabled() {
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 5165238..e18442ad 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -1168,10 +1168,6 @@
const char kEnableMacViewsNativeAppWindows[] =
"enable-mac-views-native-app-windows";
-// Causes Chrome to use an equivalent toolkit-views version of a browser dialog
-// when available, rather than a Cocoa one.
-const char kEnableMacViewsDialogs[] = "enable-mac-views-dialogs";
-
// Enables Translate experimental new UX which replaces the infobar.
const char kEnableTranslateNewUX[] = "enable-translate-new-ux";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 7810996..2c0ff4f 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -346,7 +346,6 @@
extern const char kEnableFullscreenTabDetaching[];
extern const char kEnableHostedAppsInWindows[];
extern const char kEnableMacViewsNativeAppWindows[];
-extern const char kEnableMacViewsDialogs[];
extern const char kEnableTranslateNewUX[];
extern const char kMetricsClientID[];
extern const char kRelauncherProcess[];