Show bad feature flag infobar for SignedHTTPExchange
Screenshot: https://crbug.com/803774#c41
Bug: 803774
Change-Id: I3cffd4258de124df22f4bc7560e0e9dbc91ca442
Reviewed-on: https://chromium-review.googlesource.com/956654
Commit-Queue: Tsuyoshi Horo <horo@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Bernhard Bauer <bauerb@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Tommy Martino <tmartino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542990}diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 15d8a476..56f139a8 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4906,6 +4906,11 @@
You are using an unsupported command-line flag: <ph name="BAD_FLAG">$1<ex>--no-sandbox</ex></ph>. Stability and security will suffer.
</message>
+ <!-- Bad Feature Flags Infobar-->
+ <message name="IDS_BAD_FEATURES_WARNING_MESSAGE" desc="Message shown when an unsupported feature flag is used. [Keep it short so it fits in the infobar.]">
+ You are using an unsupported feature flag: <ph name="BAD_FLAG">$1<ex>SignedHTTPExchange</ex></ph>. Stability and security will suffer.
+ </message>
+
<!-- Pepper Broker Infobar -->
<if expr="is_android">
<message name="IDS_PEPPER_BROKER_MESSAGE" desc="Mobile: Message shown when a pepper plugin wants to launch its broker. This message is followed by a 'Learn more' link.">
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
index 6e00023..4653f91 100644
--- a/chrome/browser/android/tab_android.cc
+++ b/chrome/browser/android/tab_android.cc
@@ -42,6 +42,7 @@
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
#include "chrome/browser/ui/android/view_android_helper.h"
#include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
+#include "chrome/browser/ui/startup/bad_flags_prompt.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
#include "chrome/browser/ui/tab_helpers.h"
#include "chrome/common/chrome_render_frame.mojom.h"
@@ -430,6 +431,8 @@
GetProfile());
}
content_layer_->InsertChild(web_contents_->GetNativeView()->GetLayer(), 0);
+
+ chrome::ShowBadFlagsPrompt(web_contents());
}
void TabAndroid::UpdateDelegates(
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn
index dc242c2c..7a8f3d1a 100644
--- a/chrome/browser/ui/BUILD.gn
+++ b/chrome/browser/ui/BUILD.gn
@@ -748,6 +748,8 @@
"simple_message_box.h",
"simple_message_box_internal.cc",
"simple_message_box_internal.h",
+ "startup/bad_flags_prompt.cc",
+ "startup/bad_flags_prompt.h",
"status_bubble.h",
"sync/bubble_sync_promo_delegate.h",
"sync/profile_signin_confirmation_helper.cc",
@@ -1454,8 +1456,6 @@
"singleton_tabs.h",
"startup/automation_infobar_delegate.cc",
"startup/automation_infobar_delegate.h",
- "startup/bad_flags_prompt.cc",
- "startup/bad_flags_prompt.h",
"startup/google_api_keys_infobar_delegate.cc",
"startup/google_api_keys_infobar_delegate.h",
"startup/obsolete_system_infobar_delegate.cc",
diff --git a/chrome/browser/ui/startup/bad_flags_prompt.cc b/chrome/browser/ui/startup/bad_flags_prompt.cc
index c413a6d..aa0283a 100644
--- a/chrome/browser/ui/startup/bad_flags_prompt.cc
+++ b/chrome/browser/ui/startup/bad_flags_prompt.cc
@@ -6,6 +6,7 @@
#include "base/base_switches.h"
#include "base/command_line.h"
+#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/memory_dump_manager.h"
@@ -27,6 +28,7 @@
#include "components/network_session_configurator/common/network_switches.h"
#include "components/startup_metric_utils/browser/startup_metric_utils.h"
#include "components/translate/core/common/translate_switches.h"
+#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "extensions/common/switches.h"
#include "google_apis/gaia/gaia_switches.h"
@@ -39,12 +41,84 @@
namespace chrome {
-void ShowBadFlagsPrompt(Browser* browser) {
- content::WebContents* web_contents =
- browser->tab_strip_model()->GetActiveWebContents();
- if (!web_contents)
- return;
+namespace {
+// Unsupported flags for which to display a warning that "stability and security
+// will suffer".
+static const char* kBadFlags[] = {
+ network::switches::kIgnoreCertificateErrorsSPKIList,
+ // These flags disable sandbox-related security.
+ service_manager::switches::kDisableGpuSandbox,
+ service_manager::switches::kDisableSeccompFilterSandbox,
+ service_manager::switches::kDisableSetuidSandbox,
+#if defined(OS_WIN)
+ service_manager::switches::kAllowThirdPartyModules,
+#endif
+ switches::kDisableWebSecurity,
+#if BUILDFLAG(ENABLE_NACL)
+ switches::kNaClDangerousNoSandboxNonSfi,
+#endif
+ switches::kNoSandbox, switches::kSingleProcess,
+
+ // These flags disable or undermine the Same Origin Policy.
+ translate::switches::kTranslateSecurityOrigin,
+
+ // These flags undermine HTTPS / connection security.
+#if BUILDFLAG(ENABLE_WEBRTC)
+ switches::kDisableWebRtcEncryption,
+#endif
+ switches::kIgnoreCertificateErrors,
+ invalidation::switches::kSyncAllowInsecureXmppConnection,
+
+ // These flags change the URLs that handle PII.
+ switches::kGaiaUrl, translate::switches::kTranslateScriptURL,
+
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ // This flag gives extensions more powers.
+ extensions::switches::kExtensionsOnChromeURLs,
+#endif
+
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ // Speech dispatcher is buggy, it can crash and it can make Chrome freeze.
+ // http://crbug.com/327295
+ switches::kEnableSpeechDispatcher,
+#endif
+
+ // These flags control Blink feature state, which is not supported and is
+ // intended only for use by Chromium developers.
+ switches::kDisableBlinkFeatures, switches::kEnableBlinkFeatures,
+
+ // This flag allows people to whitelist certain origins as secure, even
+ // if they are not.
+ switches::kUnsafelyTreatInsecureOriginAsSecure,
+
+ // This flag allows sites to access the camera and microphone without
+ // getting the user's permission.
+ switches::kUseFakeUIForMediaStream,
+
+ // This flag allows sites to access protected media identifiers without
+ // getting the user's permission.
+ switches::kUnsafelyAllowProtectedMediaIdentifierForDomain};
+
+// Unsupported feature flags for which to display a warning that "stability
+// and security will suffer".
+static const base::Feature* kBadFeatureFlags[] = {
+ &features::kSignedHTTPExchange,
+};
+
+void ShowBadFeatureFlagsInfoBar(content::WebContents* web_contents,
+ int message_id,
+ const base::Feature* feature) {
+ SimpleAlertInfoBarDelegate::Create(
+ InfoBarService::FromWebContents(web_contents),
+ infobars::InfoBarDelegate::BAD_FLAGS_INFOBAR_DELEGATE, nullptr,
+ l10n_util::GetStringFUTF16(message_id, base::UTF8ToUTF16(feature->name)),
+ false);
+}
+
+} // namespace
+
+void ShowBadFlagsPrompt(content::WebContents* web_contents) {
// Flags only available in specific builds, for which to display a warning
// "the flag is not implemented in this build", if necessary.
struct {
@@ -64,71 +138,20 @@
}
}
- // Unsupported flags for which to display a warning that "stability and
- // security will suffer".
- static const char* kBadFlags[] = {
- network::switches::kIgnoreCertificateErrorsSPKIList,
- // These flags disable sandbox-related security.
- service_manager::switches::kDisableGpuSandbox,
- service_manager::switches::kDisableSeccompFilterSandbox,
- service_manager::switches::kDisableSetuidSandbox,
-#if defined(OS_WIN)
- service_manager::switches::kAllowThirdPartyModules,
-#endif
- switches::kDisableWebSecurity,
-#if BUILDFLAG(ENABLE_NACL)
- switches::kNaClDangerousNoSandboxNonSfi,
-#endif
- switches::kNoSandbox,
- switches::kSingleProcess,
-
- // These flags disable or undermine the Same Origin Policy.
- translate::switches::kTranslateSecurityOrigin,
-
- // These flags undermine HTTPS / connection security.
-#if BUILDFLAG(ENABLE_WEBRTC)
- switches::kDisableWebRtcEncryption,
-#endif
- switches::kIgnoreCertificateErrors,
- invalidation::switches::kSyncAllowInsecureXmppConnection,
-
- // These flags change the URLs that handle PII.
- switches::kGaiaUrl,
- translate::switches::kTranslateScriptURL,
-
- // This flag gives extensions more powers.
- extensions::switches::kExtensionsOnChromeURLs,
-
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- // Speech dispatcher is buggy, it can crash and it can make Chrome freeze.
- // http://crbug.com/327295
- switches::kEnableSpeechDispatcher,
-#endif
-
- // These flags control Blink feature state, which is not supported and is
- // intended only for use by Chromium developers.
- switches::kDisableBlinkFeatures,
- switches::kEnableBlinkFeatures,
-
- // This flag allows people to whitelist certain origins as secure, even
- // if they are not.
- switches::kUnsafelyTreatInsecureOriginAsSecure,
-
- // This flag allows sites to access the camera and microphone without
- // getting the user's permission.
- switches::kUseFakeUIForMediaStream,
-
- // This flag allows sites to access protected media identifiers without
- // getting the user's permission.
- switches::kUnsafelyAllowProtectedMediaIdentifierForDomain
- };
-
for (const char* flag : kBadFlags) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(flag)) {
ShowBadFlagsInfoBar(web_contents, IDS_BAD_FLAGS_WARNING_MESSAGE, flag);
return;
}
}
+
+ for (const base::Feature* feature : kBadFeatureFlags) {
+ if (base::FeatureList::IsEnabled(*feature)) {
+ ShowBadFeatureFlagsInfoBar(web_contents, IDS_BAD_FEATURES_WARNING_MESSAGE,
+ feature);
+ return;
+ }
+ }
}
void ShowBadFlagsInfoBar(content::WebContents* web_contents,
diff --git a/chrome/browser/ui/startup/bad_flags_prompt.h b/chrome/browser/ui/startup/bad_flags_prompt.h
index 3af7152..b2bc905 100644
--- a/chrome/browser/ui/startup/bad_flags_prompt.h
+++ b/chrome/browser/ui/startup/bad_flags_prompt.h
@@ -5,17 +5,15 @@
#ifndef CHROME_BROWSER_UI_STARTUP_BAD_FLAGS_PROMPT_H_
#define CHROME_BROWSER_UI_STARTUP_BAD_FLAGS_PROMPT_H_
-class Browser;
-
namespace content {
class WebContents;
}
namespace chrome {
-// Shows a warning notification in |browser| that the app was run with dangerous
-// command line flags.
-void ShowBadFlagsPrompt(Browser* browser);
+// Shows a warning notification in |web_contents| that the app was run with
+// dangerous command line flags.
+void ShowBadFlagsPrompt(content::WebContents* web_contents);
// Shows a warning about a specific flag. Exposed publicly only for testing;
// should otherwise be used only by ShowBadFlagsPrompt().
diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
index 85680324..9a9a46ff 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
@@ -896,9 +896,12 @@
if (is_process_startup == chrome::startup::IS_PROCESS_STARTUP &&
!command_line_.HasSwitch(switches::kTestType) &&
!command_line_.HasSwitch(switches::kEnableAutomation)) {
- chrome::ShowBadFlagsPrompt(browser);
- InfoBarService* infobar_service = InfoBarService::FromWebContents(
- browser->tab_strip_model()->GetActiveWebContents());
+ content::WebContents* web_contents =
+ browser->tab_strip_model()->GetActiveWebContents();
+ DCHECK(web_contents);
+ chrome::ShowBadFlagsPrompt(web_contents);
+ InfoBarService* infobar_service =
+ InfoBarService::FromWebContents(web_contents);
if (!google_apis::HasKeysConfigured())
GoogleApiKeysInfoBarDelegate::Create(infobar_service);
if (ObsoleteSystem::IsObsoleteNowOrSoon()) {