Commit 46dfbde9 authored by Ovidio Henriquez's avatar Ovidio Henriquez Committed by Commit Bot

[Native File System] Page Info for Write Perm.

This change adds an entry for the Native File System API write
permission in the Page Info dialog box. This permission controls whether
the current site is allowed to ask for permission to save changes to the
original file that was selected by the user through the API.

Bug: 983726
Change-Id: I5e61d6a899b6ca09d9c8108cdc7239d0acb87152
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1718353
Commit-Queue: Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683590}
parent 78e32ecc
......@@ -129,6 +129,7 @@ ContentSettingsType kPermissionType[] = {
CONTENT_SETTINGS_TYPE_USB_GUARD,
#if !defined(OS_ANDROID)
CONTENT_SETTINGS_TYPE_SERIAL_GUARD,
CONTENT_SETTINGS_TYPE_NATIVE_FILE_SYSTEM_WRITE_GUARD,
#endif
CONTENT_SETTINGS_TYPE_BLUETOOTH_SCANNING,
};
......@@ -186,6 +187,10 @@ bool ShouldShowPermission(
// gets checked there regardless of default setting on Desktop.
if (info.type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
return true;
// The Native File System write permission is desktop only at the moment.
if (info.type == CONTENT_SETTINGS_TYPE_NATIVE_FILE_SYSTEM_WRITE_GUARD)
return false;
#else
// Flash is shown if the user has ever changed its setting for |site_url|.
if (info.type == CONTENT_SETTINGS_TYPE_PLUGINS &&
......@@ -194,12 +199,17 @@ bool ShouldShowPermission(
std::string(), nullptr) != nullptr) {
return true;
}
#endif
#if !defined(OS_ANDROID)
// Autoplay is Android-only at the moment.
if (info.type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
return false;
// Only display the Native File System write permission if it's currently
// being used.
if (info.type == CONTENT_SETTINGS_TYPE_NATIVE_FILE_SYSTEM_WRITE_GUARD &&
web_contents->HasWritableNativeFileSystemHandles()) {
return true;
}
#endif
// Show the content setting if it has been changed by the user since the last
......
......@@ -176,6 +176,8 @@ base::span<const PermissionsUIInfo> GetContentSettingsUIInfo() {
#if !defined(OS_ANDROID)
{CONTENT_SETTINGS_TYPE_SERIAL_GUARD, IDS_PAGE_INFO_TYPE_SERIAL},
#endif
{CONTENT_SETTINGS_TYPE_NATIVE_FILE_SYSTEM_WRITE_GUARD,
IDS_PAGE_INFO_TYPE_NATIVE_FILE_SYSTEM_WRITE},
{CONTENT_SETTINGS_TYPE_BLUETOOTH_SCANNING,
IDS_PAGE_INFO_TYPE_BLUETOOTH_SCANNING},
};
......@@ -579,6 +581,9 @@ const gfx::ImageSkia PageInfoUI::GetPermissionIcon(const PermissionInfo& info,
case CONTENT_SETTINGS_TYPE_BLUETOOTH_SCANNING:
icon = &vector_icons::kBluetoothScanningIcon;
break;
case CONTENT_SETTINGS_TYPE_NATIVE_FILE_SYSTEM_WRITE_GUARD:
icon = &kSaveOriginalFileIcon;
break;
default:
// All other |ContentSettingsType|s do not have icons on desktop or are
// not shown in the Page Info bubble.
......
......@@ -74,34 +74,35 @@ void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) {
}
bool PermissionMenuModel::ShouldShowAllow(const GURL& url) {
// Notifications does not support CONTENT_SETTING_ALLOW in incognito.
if (permission_.is_incognito &&
permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
return false;
switch (permission_.type) {
// Notifications does not support CONTENT_SETTING_ALLOW in incognito.
case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
return !permission_.is_incognito;
// Media only supports CONTENT_SETTING_ALLOW for secure origins.
case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
return content::IsOriginSecure(url);
// Chooser permissions do not support CONTENT_SETTING_ALLOW.
case CONTENT_SETTINGS_TYPE_SERIAL_GUARD:
case CONTENT_SETTINGS_TYPE_USB_GUARD:
// Bluetooth scanning does not support CONTENT_SETTING_ALLOW.
case CONTENT_SETTINGS_TYPE_BLUETOOTH_SCANNING:
// Native file system write does not support CONTENT_SETTING_ALLOW.
case CONTENT_SETTINGS_TYPE_NATIVE_FILE_SYSTEM_WRITE_GUARD:
return false;
default:
return true;
}
// Media only supports CONTENT_SETTING_ALLOW for secure origins.
if ((permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) &&
!content::IsOriginSecure(url)) {
return false;
}
// Chooser permissions do not support CONTENT_SETTING_ALLOW.
if (permission_.type == CONTENT_SETTINGS_TYPE_SERIAL_GUARD ||
permission_.type == CONTENT_SETTINGS_TYPE_USB_GUARD) {
return false;
}
// Bluetooth scanning permission does not support CONTENT_SETTING_ALLOW.
if (permission_.type == CONTENT_SETTINGS_TYPE_BLUETOOTH_SCANNING)
return false;
return true;
}
bool PermissionMenuModel::ShouldShowAsk(const GURL& url) {
return permission_.type == CONTENT_SETTINGS_TYPE_USB_GUARD ||
permission_.type == CONTENT_SETTINGS_TYPE_SERIAL_GUARD ||
permission_.type == CONTENT_SETTINGS_TYPE_BLUETOOTH_SCANNING;
switch (permission_.type) {
case CONTENT_SETTINGS_TYPE_USB_GUARD:
case CONTENT_SETTINGS_TYPE_SERIAL_GUARD:
case CONTENT_SETTINGS_TYPE_BLUETOOTH_SCANNING:
case CONTENT_SETTINGS_TYPE_NATIVE_FILE_SYSTEM_WRITE_GUARD:
return true;
default:
return false;
}
}
......@@ -270,6 +270,9 @@
<message name="IDS_PAGE_INFO_TYPE_SERIAL" desc="The label used for the serial port permission controls in the Page Info popup.">
Serial ports
</message>
<message name="IDS_PAGE_INFO_TYPE_NATIVE_FILE_SYSTEM_WRITE" desc="The label used for the native file system write permission controls in the Page Info popup. The write permission determines whether sites are allowed to save to the original file that was selected by the user through the Native File System API.">
Files on device
</message>
<message name="IDS_PAGE_INFO_TYPE_BLUETOOTH_SCANNING" desc="The label used for the Bluetooth scanning controls in the Page Info popup.">
Bluetooth scanning
</message>
......
38a70bcecbe1c8daeb8341794641d670195ab398
\ No newline at end of file
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