From 32fe1e9b4ad9e432f67ce34bc248654be6be4579 Mon Sep 17 00:00:00 2001 From: Evan Stade Date: Mon, 3 May 2021 20:41:55 +0000 Subject: [PATCH] File Handling: add extensions subtext to list items in chrome://settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both the "file handling" entry in an app's permissions list and the allowed exceptions in chrome://settings/content/fileHandlers get subtext that matches the exact file handlers allowed for the given app. Bug: 1203396, 1205103 Change-Id: Id156eeff6ddd4f17780e859ee2b6ed7c082ad09d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2848688 Commit-Queue: Evan Stade Reviewed-by: Darwin Huang Reviewed-by: Chase Phillips Reviewed-by: Theodore Olsauskas-Warren Reviewed-by: Martin Šrámek Cr-Commit-Position: refs/heads/master@{#878553} --- ...HANDLING_EXTENSION_LIST_SEPARATOR.png.sha1 | 2 +- .../chrome_content_settings_utils.cc | 12 +++++ .../chrome_content_settings_utils.h | 15 +++++++ .../site_details_permission.html | 13 ++++-- .../site_settings/site_details_permission.js | 31 +++++++++---- .../settings/site_settings/site_list_entry.js | 7 ++- .../site_settings/site_settings_behavior.js | 1 + .../site_settings_prefs_browser_proxy.js | 2 + .../webui/settings/site_settings_handler.cc | 5 +++ .../site_settings_handler_unittest.cc | 3 +- .../ui/webui/settings/site_settings_helper.cc | 23 +++++++--- .../ui/webui/settings/site_settings_helper.h | 3 ++ .../components/web_app_utils.cc | 14 +++--- .../settings/site_details_permission_tests.js | 33 ++++++++++++++ .../webui/settings/site_list_entry_tests.js | 45 +++++++++++++++++++ .../data/webui/settings/site_list_tests.js | 1 + 16 files changed, 183 insertions(+), 27 deletions(-) diff --git a/chrome/app/generated_resources_grd/IDS_WEB_APP_FILE_HANDLING_EXTENSION_LIST_SEPARATOR.png.sha1 b/chrome/app/generated_resources_grd/IDS_WEB_APP_FILE_HANDLING_EXTENSION_LIST_SEPARATOR.png.sha1 index 6ee6d61a3e4afe..4a1988adad51e2 100644 --- a/chrome/app/generated_resources_grd/IDS_WEB_APP_FILE_HANDLING_EXTENSION_LIST_SEPARATOR.png.sha1 +++ b/chrome/app/generated_resources_grd/IDS_WEB_APP_FILE_HANDLING_EXTENSION_LIST_SEPARATOR.png.sha1 @@ -1 +1 @@ -aa286efbaee111ce1a8e37854ff384fa397f929e \ No newline at end of file +8d581b03984765654d656d238290675b9293c282 \ No newline at end of file diff --git a/chrome/browser/content_settings/chrome_content_settings_utils.cc b/chrome/browser/content_settings/chrome_content_settings_utils.cc index dace9ca84354ae..46ed25af51424c 100644 --- a/chrome/browser/content_settings/chrome_content_settings_utils.cc +++ b/chrome/browser/content_settings/chrome_content_settings_utils.cc @@ -12,6 +12,7 @@ #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/location_bar/location_bar.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/browser/web_applications/components/web_app_utils.h" #include "content/public/browser/web_contents.h" #endif @@ -42,4 +43,15 @@ void UpdateLocationBarUiForWebContents(content::WebContents* web_contents) { #endif } +#if !defined(OS_ANDROID) +std::u16string GetPermissionDetailString(Profile* profile, + ContentSettingsType content_type, + const GURL& url) { + if (content_type != ContentSettingsType::FILE_HANDLING || !url.is_valid()) + return {}; + + return web_app::GetFileExtensionsHandledByWebAppDisplayedAsList(profile, url); +} +#endif + } // namespace content_settings diff --git a/chrome/browser/content_settings/chrome_content_settings_utils.h b/chrome/browser/content_settings/chrome_content_settings_utils.h index e01e28581a3beb..3347fa78675418 100644 --- a/chrome/browser/content_settings/chrome_content_settings_utils.h +++ b/chrome/browser/content_settings/chrome_content_settings_utils.h @@ -6,11 +6,16 @@ #define CHROME_BROWSER_CONTENT_SETTINGS_CHROME_CONTENT_SETTINGS_UTILS_H_ #include "build/build_config.h" +#include "components/content_settings/core/common/content_settings.h" // Put utility functions only used by //chrome code here. If a function declared // here would be meaningfully shared with other platforms, consider moving it to // components/content_settings/core/browser/content_settings_utils.h. +class GURL; +class Profile; +enum class ContentSettingsType; + namespace content { class WebContents; } // namespace content @@ -51,6 +56,16 @@ void RecordPopupsAction(PopupsAction action); // Calls UpdateContentSettingsIcons on the |LocationBar| for |web_contents|. void UpdateLocationBarUiForWebContents(content::WebContents* web_contents); +#if !defined(OS_ANDROID) +// Returns a string for display alongside UI that describes the given content +// setting in `profile`. This string gives extra, pertinent details about the +// content setting. `url` represents the site for which the given setting +// applies. +std::u16string GetPermissionDetailString(Profile* profile, + ContentSettingsType content_type, + const GURL& url); +#endif + } // namespace content_settings #endif // CHROME_BROWSER_CONTENT_SETTINGS_CHROME_CONTENT_SETTINGS_UTILS_H_ diff --git a/chrome/browser/resources/settings/site_settings/site_details_permission.html b/chrome/browser/resources/settings/site_settings/site_details_permission.html index ea9cb5776096ba..6d18d7ae23caf8 100644 --- a/chrome/browser/resources/settings/site_settings/site_details_permission.html +++ b/chrome/browser/resources/settings/site_settings/site_details_permission.html @@ -1,8 +1,10 @@
+ class$="list-item [[permissionInfoStringClass_(site.source, + category, + site.setting, + site.settingDetail)]]">
@@ -10,12 +12,15 @@