Commit c61d2d64 authored by Trent Begin's avatar Trent Begin Committed by Commit Bot

connectivity-diagnostics: add Chrome OS net-error diagnostics dialog

This change adds an implementation of the net error diagnostics dialog
for Chrome OS. Now if the connectivity diagnostics webui feature is
enabled, the new application is launched, otherwise the legacy chrome
app is launched.

Bug: 1144261
Change-Id: I924cc5c2fbedfb1a7a5cba90fcd6bbf0b3f48855
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2510799
Commit-Queue: Trent Begin <tbegin@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarEdward Jung (EMEA) <edwardjung@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825701}
parent f4cea481
...@@ -2379,11 +2379,20 @@ static_library("browser") { ...@@ -2379,11 +2379,20 @@ static_library("browser") {
deps += [ "//chrome/services/machine_learning" ] deps += [ "//chrome/services/machine_learning" ]
} }
# Platforms that have a network diagnostics dialog. All others fall through
# to the stub which is not implemented.
if (is_chromeos) {
sources += [ "net/net_error_diagnostics_dialog_chromeos.cc" ]
} else if (is_win) {
sources += [ "net/net_error_diagnostics_dialog_win.cc" ]
} else {
sources += [ "net/net_error_diagnostics_dialog_stub.cc" ]
}
if (is_posix || is_fuchsia) { if (is_posix || is_fuchsia) {
sources += [ sources += [
"download/trusted_sources_manager_posix.cc", "download/trusted_sources_manager_posix.cc",
"google/google_update_settings_posix.cc", "google/google_update_settings_posix.cc",
"net/net_error_diagnostics_dialog_posix.cc",
"performance_monitor/metric_evaluator_helper_posix.cc", "performance_monitor/metric_evaluator_helper_posix.cc",
"performance_monitor/metric_evaluator_helper_posix.h", "performance_monitor/metric_evaluator_helper_posix.h",
] ]
...@@ -4540,7 +4549,6 @@ static_library("browser") { ...@@ -4540,7 +4549,6 @@ static_library("browser") {
"metrics/jumplist_metrics_win.h", "metrics/jumplist_metrics_win.h",
"metrics/tab_stats_tracker_delegate_win.cc", "metrics/tab_stats_tracker_delegate_win.cc",
"metrics/tab_stats_tracker_win.cc", "metrics/tab_stats_tracker_win.cc",
"net/net_error_diagnostics_dialog_win.cc",
"net/service_providers_win.cc", "net/service_providers_win.cc",
"net/service_providers_win.h", "net/service_providers_win.h",
"notifications/win/notification_template_builder.cc", "notifications/win/notification_template_builder.cc",
......
...@@ -164,12 +164,7 @@ void ExpectDisplayingErrorPage(Browser* browser, net::Error error_code) { ...@@ -164,12 +164,7 @@ void ExpectDisplayingErrorPage(Browser* browser, net::Error error_code) {
// Returns true if the platform has support for a diagnostics tool, and it // Returns true if the platform has support for a diagnostics tool, and it
// can be launched from |web_contents|. // can be launched from |web_contents|.
bool WebContentsCanShowDiagnosticsTool(content::WebContents* web_contents) { bool WebContentsCanShowDiagnosticsTool(content::WebContents* web_contents) {
#if defined(OS_CHROMEOS)
// ChromeOS uses an extension instead of a diagnostics dialog.
return true;
#else
return CanShowNetworkDiagnosticsDialog(web_contents); return CanShowNetworkDiagnosticsDialog(web_contents);
#endif
} }
class ErrorPageTest : public InProcessBrowserTest { class ErrorPageTest : public InProcessBrowserTest {
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/net/net_error_diagnostics_dialog.h"
#include "apps/launcher.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/web_applications/system_web_app_ui_utils.h"
#include "chromeos/components/connectivity_diagnostics/url_constants.h"
#include "chromeos/constants/chromeos_features.h"
#include "extensions/browser/extension_registry.h"
bool CanShowNetworkDiagnosticsDialog(content::WebContents* web_contents) {
// The ChromeOS network diagnostics dialog can be shown in incognito and guest
// profiles since it does not log the referring URL.
return true;
}
void ShowNetworkDiagnosticsDialog(content::WebContents* web_contents,
const std::string& failed_url) {
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
if (base::FeatureList::IsEnabled(
chromeos::features::kConnectivityDiagnosticsWebUi)) {
LaunchSystemWebApp(profile,
web_app::SystemAppType::CONNECTIVITY_DIAGNOSTICS,
GURL(chromeos::kChromeUIConnectivityDiagnosticsUrl));
} else {
const extensions::Extension* extension =
extensions::ExtensionRegistry::Get(profile)->GetInstalledExtension(
"kodldpbjkkmmnilagfdheibampofhaom");
apps::LaunchPlatformAppWithUrl(web_contents->GetBrowserContext(), extension,
"", GURL::EmptyGURL(), GURL(failed_url));
}
}
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/app_management/app_management_uma.h" #include "chrome/browser/ui/webui/settings/chromeos/app_management/app_management_uma.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h" #include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes_util.h" #include "chrome/browser/ui/webui/settings/chromeos/constants/routes_util.h"
#include "chromeos/components/connectivity_diagnostics/url_constants.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
#else #else
#include "chrome/browser/ui/signin_view_controller.h" #include "chrome/browser/ui/signin_view_controller.h"
...@@ -455,6 +456,13 @@ void ShowPrintManagementApp(Profile* profile, ...@@ -455,6 +456,13 @@ void ShowPrintManagementApp(Profile* profile,
GURL(chrome::kChromeUIPrintManagementUrl)); GURL(chrome::kChromeUIPrintManagementUrl));
} }
void ShowConnectivityDiagnosticsApp(Profile* profile) {
DCHECK(base::FeatureList::IsEnabled(
chromeos::features::kConnectivityDiagnosticsWebUi));
LaunchSystemWebApp(profile, web_app::SystemAppType::CONNECTIVITY_DIAGNOSTICS,
GURL(chromeos::kChromeUIConnectivityDiagnosticsUrl));
}
GURL GetOSSettingsUrl(const std::string& sub_page) { GURL GetOSSettingsUrl(const std::string& sub_page) {
DCHECK(sub_page.empty() || chromeos::settings::IsOSSettingsSubPage(sub_page)) DCHECK(sub_page.empty() || chromeos::settings::IsOSSettingsSubPage(sub_page))
<< sub_page; << sub_page;
......
...@@ -153,6 +153,8 @@ void ShowAppManagementPage(Profile* profile, ...@@ -153,6 +153,8 @@ void ShowAppManagementPage(Profile* profile,
void ShowPrintManagementApp(Profile* profile, void ShowPrintManagementApp(Profile* profile,
PrintManagementAppEntryPoint entry_point); PrintManagementAppEntryPoint entry_point);
void ShowConnectivityDiagnosticsApp(Profile* profile);
#endif #endif
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
</div> </div>
</div> </div>
</div> </div>
<div id="diagnose-frame" class="hidden"></div>
<div id="download-links-wrapper" class="hidden"> <div id="download-links-wrapper" class="hidden">
<div id="download-link-wrapper"> <div id="download-link-wrapper">
<a id="download-link" class="link-button" <a id="download-link" class="link-button"
......
...@@ -56,18 +56,9 @@ function toggleHelpBox() { ...@@ -56,18 +56,9 @@ function toggleHelpBox() {
} }
function diagnoseErrors() { function diagnoseErrors() {
// <if expr="not chromeos"> if (window.errorPageController) {
if (window.errorPageController) { errorPageController.diagnoseErrorsButtonClick();
errorPageController.diagnoseErrorsButtonClick(); }
}
// </if>
// <if expr="chromeos">
const extensionId = 'idddmepepmjcgiedknnmlbadcokidhoa';
const diagnoseFrame = document.getElementById('diagnose-frame');
diagnoseFrame.innerHTML =
'<iframe src="chrome-extension://' + extensionId +
'/index.html"></iframe>';
// </if>
} }
// Subframes use a different layout but the same html file. This is to make it // Subframes use a different layout but the same html file. This is to make it
......
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