From 055cabb7ba3587bd582c8c7c1114cd90f7b20a9c Mon Sep 17 00:00:00 2001 From: Sergey P Date: Mon, 20 Sep 2021 18:46:17 +0300 Subject: [PATCH] Improve error message for IPFS gateway without Origin isolation --- app/brave_generated_resources.grd | 3 +++ .../brave_ipfs_page/change_ipfs_gateway_dialog.html | 2 +- .../settings/brave_ipfs_page/change_ipfs_gateway_dialog.js | 7 ++++++- .../webui/settings/settings_localized_strings_provider.cc | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index c6210567330..2042ad42a68 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -939,6 +939,9 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U Invalid gateway address + + Only a valid IPFS gateway with Origin isolation enabled can be used in Brave + IPFS public gateway fallback diff --git a/browser/resources/settings/brave_ipfs_page/change_ipfs_gateway_dialog.html b/browser/resources/settings/brave_ipfs_page/change_ipfs_gateway_dialog.html index a1508aa643d..71166e4a65b 100644 --- a/browser/resources/settings/brave_ipfs_page/change_ipfs_gateway_dialog.html +++ b/browser/resources/settings/brave_ipfs_page/change_ipfs_gateway_dialog.html @@ -6,7 +6,7 @@ diff --git a/browser/resources/settings/brave_ipfs_page/change_ipfs_gateway_dialog.js b/browser/resources/settings/brave_ipfs_page/change_ipfs_gateway_dialog.js index 1a0ab7e9a77..0c8fa8ba823 100644 --- a/browser/resources/settings/brave_ipfs_page/change_ipfs_gateway_dialog.js +++ b/browser/resources/settings/brave_ipfs_page/change_ipfs_gateway_dialog.js @@ -43,11 +43,14 @@ Polymer({ * @private */ gatewayUrl_: String, + + invalidAddressMessage_: String }, browserProxy_: null, /** @override */ created: function() { this.browserProxy_ = BraveIPFSBrowserProxyImpl.getInstance(); + this.invalidAddressMessage_ = this.i18n('ipfsErrorInvalidAddress') }, /** @override */ @@ -65,7 +68,7 @@ Polymer({ this.isSubmitButtonEnabled_ = false; return; } - + this.invalidAddressMessage_ = this.i18n('ipfsErrorInvalidAddress') let url; try { url = new URL(url_.trim()); @@ -90,6 +93,8 @@ Polymer({ if (success) { this.setPrefValue('brave.ipfs.public_gateway_address', this.gatewayUrl_); this.fire('close'); + } else { + this.invalidAddressMessage_ = this.i18n('ipfsErrorInvalidAddressOrigin') } }); }, diff --git a/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc index 83ff01793ad..47ce53d1f0b 100644 --- a/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc @@ -262,6 +262,8 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source, {"changeIpfsStorageMaxLabel", IDS_SETTINGS_CHANGE_IPFS_STORAGE_MAX_LABEL}, {"changeIpfsStorageMaxDesc", IDS_SETTINGS_CHANGE_IPFS_STORAGE_MAX_DESC}, {"ipfsErrorInvalidAddress", IDS_SETTINGS_IPFS_ERROR_INVALID_ADDRESS}, + {"ipfsErrorInvalidAddressOrigin", + IDS_SETTINGS_IPFS_ERROR_INVALID_ADDRESS_ORIGIN_ISOLATION}, {"ipfsAutoFallbackToGatewayLabel", IDS_SETTINGS_IPFS_AUTO_FALLBACK_TO_GATEWAY_LABEL}, {"ipfsAutoFallbackToGatewayDesc",