Skip to content

Commit

Permalink
Lacros: Show connectivity diagnostics link on network error page
Browse files Browse the repository at this point in the history
This CL lets Lacros to show connectivity diagnostics link on network
error page.

Bug: 1308098
Change-Id: I249861e1e480871d58278d047e6945c1e3b4cdd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3762115
Reviewed-by: Yutaka Hirano <[email protected]>
Commit-Queue: Eriko Kurimoto <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1026570}
  • Loading branch information
elkurin authored and Chromium LUCI CQ committed Jul 21, 2022
1 parent 9f37112 commit b4fba88
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
2 changes: 2 additions & 0 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2470,6 +2470,8 @@ static_library("browser") {
# to the stub which is not implemented.
if (is_chromeos_ash) {
sources += [ "net/net_error_diagnostics_dialog_chromeos.cc" ]
} else if (is_chromeos_lacros) {
sources += [ "net/net_error_diagnostics_dialog_lacros.cc" ]
} else if (is_win) {
sources += [ "net/net_error_diagnostics_dialog_win.cc" ]
} else {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/net/errorpage_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ IN_PROC_BROWSER_TEST_F(DNSErrorPageTest, Incognito) {
// Verify that the expected error page is being displayed.
ExpectDisplayingErrorPage(incognito_browser, net::ERR_NAME_NOT_RESOLVED);

#if !BUILDFLAG(IS_CHROMEOS_ASH)
#if !BUILDFLAG(IS_CHROMEOS)
// Can't currently show the diagnostics in incognito on any platform but
// ChromeOS.
EXPECT_FALSE(WebContentsCanShowDiagnosticsTool(
Expand Down
23 changes: 23 additions & 0 deletions chrome/browser/net/net_error_diagnostics_dialog_lacros.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2022 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 "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "content/public/browser/web_contents.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());

chrome::ShowConnectivityDiagnosticsApp(profile);
}
4 changes: 2 additions & 2 deletions components/error_page/common/localized_error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ void GetSuggestionsSummaryList(int error_code,

// If the current platform has a directly accesible network diagnostics tool and
// the URL is valid add a suggestion.
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
if (IsOnlySuggestion(suggestions, SUGGEST_DIAGNOSE_TOOL)) {
int diagose_message_id =
error_code == error_page::DNS_PROBE_FINISHED_NXDOMAIN
Expand All @@ -753,7 +753,7 @@ void GetSuggestionsSummaryList(int error_code,
}
#else
DCHECK(!IsSuggested(suggestions, SUGGEST_DIAGNOSE_TOOL));
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
#endif // BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)

// Add list prefix header.
error_strings.Set(
Expand Down
2 changes: 1 addition & 1 deletion components/error_page_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
If spelling is correct, <ph name="BEGIN_LINK">&lt;a href="javascript:diagnoseErrors()" id="diagnose-link"&gt;</ph>try running Windows Network Diagnostics<ph name="END_LINK">&lt;/a&gt;</ph>.
</message>
</if>
<if expr="chromeos_ash">
<if expr="chromeos_ash or chromeos_lacros">
<message name="IDS_ERRORPAGES_SUGGESTION_DIAGNOSE" desc="Label for the link that invokes the connection diagnostic tool on the error page displayed in a list of suggestions. The suggestions list is prefixed with 'Try:'.">
<ph name="BEGIN_LINK">&lt;a href="javascript:diagnoseErrors()" id="diagnose-link"&gt;</ph>Running Connectivity Diagnostics<ph name="END_LINK">&lt;/a&gt;</ph>
</message>
Expand Down

0 comments on commit b4fba88

Please sign in to comment.