From 01721525e95ea59e93a9390fd5e977c481e4dda6 Mon Sep 17 00:00:00 2001 From: Sergey P Date: Wed, 5 May 2021 16:49:48 +0300 Subject: [PATCH] Added IPNS keys manager UI to IPFS Settings --- app/brave_generated_resources.grd | 9 ++ .../brave_ipfs_page/add_p2p_key_dialog.html | 8 +- .../brave_ipfs_page/add_p2p_key_dialog.js | 5 +- .../brave_ipfs_browser_proxy.js | 7 ++ .../brave_ipfs_page/brave_ipfs_page.js | 3 +- .../brave_ipfs_page/p2p_keys_subpage.html | 4 +- .../brave_ipfs_page/p2p_keys_subpage.js | 38 +++++-- .../brave_default_extensions_handler.cc | 106 ++++++++++++++---- .../brave_default_extensions_handler.h | 19 +++- .../settings_localized_strings_provider.cc | 3 + components/ipfs/ipfs_network_utils.cc | 18 --- .../ipfs/ipfs_network_utils_unittest.cc | 4 +- components/ipfs/keys/ipns_keys_manager.cc | 89 +++++++++++++-- components/ipfs/keys/ipns_keys_manager.h | 19 +++- 14 files changed, 268 insertions(+), 64 deletions(-) diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index 1488926b9604..85bc61442dd2 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -790,6 +790,15 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U IPFS service launch error, more information is available on the <a target="_blank" rel="noopener noreferrer" style="text-decoration: underline;" href="chrome://ipfs-internals/">diagnostic page</a> + + '$1MyCustomKey' key import failed + + + Import + + + Generate + Start node diff --git a/browser/resources/settings/brave_ipfs_page/add_p2p_key_dialog.html b/browser/resources/settings/brave_ipfs_page/add_p2p_key_dialog.html index e1e1ba8aaa55..e8498e2c79e9 100644 --- a/browser/resources/settings/brave_ipfs_page/add_p2p_key_dialog.html +++ b/browser/resources/settings/brave_ipfs_page/add_p2p_key_dialog.html @@ -2,6 +2,9 @@
$i18n{ipfsAddKeyDialogTitle}
@@ -14,9 +17,12 @@
+ + $i18n{ipfsKeyImport} + - Submit + $i18n{ipfsKeyGenerate}
diff --git a/browser/resources/settings/brave_ipfs_page/add_p2p_key_dialog.js b/browser/resources/settings/brave_ipfs_page/add_p2p_key_dialog.js index 7b2bfd2b889e..fe38e8b27a9d 100644 --- a/browser/resources/settings/brave_ipfs_page/add_p2p_key_dialog.js +++ b/browser/resources/settings/brave_ipfs_page/add_p2p_key_dialog.js @@ -65,7 +65,10 @@ Polymer({ this.isNameValid_ = value; this.isSubmitButtonEnabled_ = value; }, - + onImportKeyTap_: function(item) { + this.browserProxy_.importIpnsKey(this.$.key.value) + this.fire('close'); + }, handleSubmit_: function() { var name = this.$.key.value this.browserProxy_.addIpnsKey(name).then(json => { diff --git a/browser/resources/settings/brave_ipfs_page/brave_ipfs_browser_proxy.js b/browser/resources/settings/brave_ipfs_page/brave_ipfs_browser_proxy.js index b3b3031f9e6b..9498f4109534 100644 --- a/browser/resources/settings/brave_ipfs_page/brave_ipfs_browser_proxy.js +++ b/browser/resources/settings/brave_ipfs_page/brave_ipfs_browser_proxy.js @@ -13,6 +13,7 @@ export class BraveIPFSBrowserProxy { getIPFSResolveMethodList () {} getIPFSEnabled () {} setIPFSStorageMax (value) {} + importIpnsKey () {} } /** @@ -27,6 +28,12 @@ export class BraveIPFSBrowserProxyImpl { chrome.send('setIPFSStorageMax', [value]) } + importIpnsKey (value) { + chrome.send('importIpnsKey', [value]) + } + notifyIpfsNodeStatus () { + chrome.send('notifyIpfsNodeStatus', []) + } launchIPFSService () { return new Promise(resolve => { if (!chrome.ipfs) { diff --git a/browser/resources/settings/brave_ipfs_page/brave_ipfs_page.js b/browser/resources/settings/brave_ipfs_page/brave_ipfs_page.js index 5a8e9c92cb19..24ab445bfb8c 100644 --- a/browser/resources/settings/brave_ipfs_page/brave_ipfs_page.js +++ b/browser/resources/settings/brave_ipfs_page/brave_ipfs_page.js @@ -63,13 +63,12 @@ Polymer({ }); this.browserProxy_.getIPFSEnabled().then(enabled => { this.ipfsEnabled_ = enabled - }); this.addWebUIListener('brave-ipfs-node-status-changed', (launched) => { this.isLocalNodeLaunched_ = launched }) - + this.browserProxy_.notifyIpfsNodeStatus(); window.addEventListener('load', this.onLoad_.bind(this)); }, diff --git a/browser/resources/settings/brave_ipfs_page/p2p_keys_subpage.html b/browser/resources/settings/brave_ipfs_page/p2p_keys_subpage.html index c72ce82aab48..585ab2b7c3d5 100644 --- a/browser/resources/settings/brave_ipfs_page/p2p_keys_subpage.html +++ b/browser/resources/settings/brave_ipfs_page/p2p_keys_subpage.html @@ -55,13 +55,15 @@
$i18n{ipfsKeysListTitle} +
$i18n{add}
-