diff --git a/chrome/browser/ui/page_info/page_info.cc b/chrome/browser/ui/page_info/page_info.cc index 818288d636b3..e0e59f3123c2 100644 --- a/chrome/browser/ui/page_info/page_info.cc +++ b/chrome/browser/ui/page_info/page_info.cc @@ -448,10 +448,14 @@ void PageInfo::OpenSiteSettingsView() { // settings page specific to the current origin of the page. crbug.com/655876 url::Origin site_origin = url::Origin(site_url()); std::string link_destination(chrome::kChromeUIContentSettingsURL); + // TODO(https://crbug.com/444047): Site Details should work with file:// urls + // when this bug is fixed, so add it to the whitelist when that happens. if ((base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableSiteSettings) || base::FeatureList::IsEnabled(features::kSiteDetails)) && - !site_origin.unique()) { + !site_origin.unique() && + (site_url().SchemeIsHTTPOrHTTPS() || + site_url().SchemeIs(content_settings::kExtensionScheme))) { std::string origin_string = site_origin.Serialize(); url::RawCanonOutputT percent_encoded_origin; url::EncodeURIComponent(origin_string.c_str(), origin_string.length(), diff --git a/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc b/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc index 726395fb2983..6da6887730f3 100644 --- a/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc +++ b/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc @@ -192,6 +192,15 @@ IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, OpenSiteSettingsForUrl(browser(), GURL(url::kAboutBlankURL), true)); } +// Test opening "Site Details" via Page Info from a file:// URL goes to "Content +// Settings". +IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, + SiteSettingsLinkWithSiteDetailsEnabledAndFileUrl) { + GURL url = GURL("file:///Users/homedirname/folder/file.pdf"); + EXPECT_EQ(GURL(chrome::kChromeUIContentSettingsURL), + OpenSiteSettingsForUrl(browser(), url, true)); +} + // Test opening page info bubble that matches SB_THREAT_TYPE_PASSWORD_REUSE // threat type. IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,