Added AboutUI page for connection-help.

Added an AboutUI page for chrome://connection-help, that displays a
subset of the information available at
support.google.com/chrome/answer/6098869. On a separate CL, logic
will be added to redirect users who visit the online help center and
get an interstitial to the chrome://connection-help site.

Bug: 811382

Change-Id: Ic53d81a902fd8f59894f935a691b90c6eec98c11
Reviewed-on: https://chromium-review.googlesource.com/854793
Commit-Queue: Carlos IL <[email protected]>
Reviewed-by: Tommy Li <[email protected]>
Reviewed-by: Emily Stark <[email protected]>
Cr-Commit-Position: refs/heads/master@{#537119}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index c3de7c44..0790942 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -3728,6 +3728,10 @@
          service_manager::switches::kDisableGpuAppContainer)},
 #endif  // OS_WIN
 
+    {"BundledConnectionHelp", flag_descriptions::kBundledConnectionHelpName,
+     flag_descriptions::kBundledConnectionHelpDescription, kOsAll,
+     FEATURE_VALUE_TYPE(features::kBundledConnectionHelpFeature)},
+
     // NOTE: Adding a new flag requires adding a corresponding entry to enum
     // "LoginCustomFlags" in tools/metrics/histograms/enums.xml. See "Flag
     // Histograms" in tools/metrics/histograms/README.md (run the
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 3acca5ec..f7b3af2 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -93,6 +93,12 @@
 const char kBrowserTaskSchedulerDescription[] =
     "Enables redirection of some task posting APIs to the task scheduler.";
 
+const char kBundledConnectionHelpName[] = "Bundled Connection Help";
+const char kBundledConnectionHelpDescription[] =
+    "Enables or disables redirecting users who get an interstitial when "
+    "accessing https://support.google.com/chrome/answer/6098869 to local "
+    "connection help content.";
+
 const char kBypassAppBannerEngagementChecksName[] =
     "Bypass user engagement checks";
 const char kBypassAppBannerEngagementChecksDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index 68dac0c..b550c0a 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -87,6 +87,9 @@
 extern const char kBrowserTaskSchedulerName[];
 extern const char kBrowserTaskSchedulerDescription[];
 
+extern const char kBundledConnectionHelpName[];
+extern const char kBundledConnectionHelpDescription[];
+
 extern const char kBypassAppBannerEngagementChecksName[];
 extern const char kBypassAppBannerEngagementChecksDescription[];
 
diff --git a/chrome/browser/ui/webui/about_ui.cc b/chrome/browser/ui/webui/about_ui.cc
index 8c97750..808d6e7 100644
--- a/chrome/browser/ui/webui/about_ui.cc
+++ b/chrome/browser/ui/webui/about_ui.cc
@@ -51,6 +51,7 @@
 #include "components/about_ui/credit_utils.h"
 #include "components/grit/components_resources.h"
 #include "components/strings/grit/components_locale_settings.h"
+#include "components/strings/grit/components_strings.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/render_process_host.h"
 #include "content/public/browser/render_view_host.h"
@@ -325,6 +326,25 @@
   return html;
 }
 
+std::string HelpCenterContent() {
+  std::string html;
+  AppendHeader(&html, 0, l10n_util::GetStringUTF8(IDS_CONNECTION_HELP_TITLE));
+  html +=
+      "<meta name=\"viewport\" content=\"initial-scale=1, minimum-scale=1, "
+      "width=device-width\">\n";
+  webui::AppendWebUiCssTextDefaults(&html);
+  html += "<style>";
+  html += l10n_util::GetStringUTF8(IDR_SECURITY_INTERSTITIAL_COMMON_CSS);
+  html += l10n_util::GetStringUTF8(IDR_SECURITY_INTERSTITIAL_CORE_CSS);
+  html += "</style>";
+  AppendBody(&html);
+  html += "<div class=\"interstitial-wrapper\">\n";
+  html += l10n_util::GetStringUTF8(IDS_CONNECTION_HELP_HTML);
+  html += "</div>\n";
+  AppendFooter(&html);
+  return html;
+}
+
 // AboutDnsHandler bounces the request back to the IO thread to collect
 // the DNS information.
 class AboutDnsHandler : public base::RefCountedThreadSafe<AboutDnsHandler> {
@@ -425,6 +445,8 @@
   // Add your data source here, in alphabetical order.
   if (source_name_ == chrome::kChromeUIChromeURLsHost) {
     response = ChromeURLs();
+  } else if (source_name_ == chrome::kChromeUIConnectionHelpHost) {
+    response = HelpCenterContent();
   } else if (source_name_ == chrome::kChromeUICreditsHost) {
     int idr = IDR_ABOUT_UI_CREDITS_HTML;
     if (path == kCreditsJsPath)
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index f055f9c..86a72d4 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -9,6 +9,7 @@
 #include <vector>
 
 #include "base/bind.h"
+#include "base/feature_list.h"
 #include "base/location.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "build/build_config.h"
@@ -195,6 +196,7 @@
 #if BUILDFLAG(ENABLE_EXTENSIONS)
 #include "chrome/browser/extensions/extension_web_ui.h"
 #include "chrome/browser/ui/webui/extensions/extensions_ui.h"
+#include "chrome/common/chrome_features.h"
 #include "chrome/common/extensions/extension_constants.h"
 #include "extensions/browser/extension_registry.h"
 #include "extensions/browser/extension_system.h"
@@ -275,6 +277,10 @@
 #endif  // defined(OS_WIN)
 
 bool IsAboutUI(const GURL& url) {
+  if (base::FeatureList::IsEnabled(features::kBundledConnectionHelpFeature) &&
+      url.host_piece() == chrome::kChromeUIConnectionHelpHost) {
+    return true;
+  }
   return (url.host_piece() == chrome::kChromeUIChromeURLsHost ||
           url.host_piece() == chrome::kChromeUICreditsHost ||
           url.host_piece() == chrome::kChromeUIDNSHost
diff --git a/chrome/browser/ui/webui/webui_browsertest.cc b/chrome/browser/ui/webui/webui_browsertest.cc
index dc838bc..95e722ad 100644
--- a/chrome/browser/ui/webui/webui_browsertest.cc
+++ b/chrome/browser/ui/webui/webui_browsertest.cc
@@ -3,14 +3,18 @@
 // found in the LICENSE file.
 
 #include "base/command_line.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/test/scoped_feature_list.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/browser_commands.h"
 #include "chrome/browser/ui/tabs/tab_strip_model.h"
 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
+#include "chrome/common/chrome_features.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/url_constants.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "chrome/test/base/ui_test_utils.h"
+#include "components/strings/grit/components_strings.h"
 #include "content/public/browser/child_process_security_policy.h"
 #include "content/public/browser/render_frame_host.h"
 #include "content/public/browser/render_process_host.h"
@@ -18,6 +22,7 @@
 #include "content/public/common/content_switches.h"
 #include "content/public/test/browser_test_utils.h"
 #include "content/public/test/test_utils.h"
+#include "ui/base/l10n/l10n_util.h"
 
 namespace {
 
@@ -93,3 +98,18 @@
   // Verify that after a reload, the test handler has been disallowed.
   EXPECT_FALSE(test_handler->IsJavascriptAllowed());
 }
+
+// Tests that navigating to chrome://connection-help displays the proper help
+// page.
+IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest, ConnectionHelpUI) {
+  base::test::ScopedFeatureList feature_list;
+  feature_list.InitAndEnableFeature(features::kBundledConnectionHelpFeature);
+  ui_test_utils::NavigateToURL(browser(),
+                               GURL(chrome::kChromeUIConnectionHelpURL));
+  content::WaitForLoadStop(
+      browser()->tab_strip_model()->GetActiveWebContents());
+  base::string16 tab_title;
+  ui_test_utils::GetCurrentTabTitle(browser(), &tab_title);
+  EXPECT_EQ(base::UTF16ToUTF8(tab_title),
+            l10n_util::GetStringUTF8(IDS_CONNECTION_HELP_TITLE));
+}