Skip to content

Commit 57fdf2f

Browse files
authored
Merge pull request #7848 from brave/add-ipfs-settings-section
Refactor settings for IPFS into its own section
2 parents c652170 + 868d0fc commit 57fdf2f

18 files changed

+273
-109
lines changed

app/brave_generated_resources.grd

+3
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,9 @@ up to 6x faster on major news sites.
10221022
<message name="IDS_BRAVE_IPFS_INSTALL" desc="Install IPFS daemon infobar text">
10231023
IPFS resources detected. Would you like Brave to load them using a local IPFS node?
10241024
</message>
1025+
<message name="IDS_BRAVE_IPFS_SETTINGS_SECTION" desc="Open IPFS settings section">
1026+
IPFS Settings
1027+
</message>
10251028
<message name="IDS_BRAVE_IPFS_SETTINGS" desc="Open IPFS settings">
10261029
Settings
10271030
</message>

browser/resources/settings/BUILD.gn

+4-1
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ preprocess_if_expr("preprocess_generated") {
133133
"brave_appearance_page/super_referral.js",
134134
"brave_appearance_page/toolbar.js",
135135
"brave_clear_browsing_data_dialog/brave_clear_browsing_data_on_exit_page.js",
136+
"brave_ipfs_page/brave_ipfs_browser_proxy.m.js",
137+
"brave_ipfs_page/brave_ipfs_page.m.js",
138+
"brave_ipfs_page/change_ipfs_gateway_dialog.js",
136139
"brave_default_extensions_page/brave_default_extensions_browser_proxy.m.js",
137140
"brave_default_extensions_page/brave_default_extensions_page.m.js",
138-
"brave_default_extensions_page/change_ipfs_gateway_dialog.js",
139141
"brave_help_tips_page/brave_help_tips_page.m.js",
140142
"brave_icons.m.js",
141143
"brave_new_tab_page/brave_new_tab_browser_proxy.m.js",
@@ -164,6 +166,7 @@ group("web_modules") {
164166
"brave_clear_browsing_data_dialog:web_modules",
165167
"brave_default_extensions_page:web_modules",
166168
"brave_help_tips_page:web_modules",
169+
"brave_ipfs_page:web_modules",
167170
"brave_new_tab_page:web_modules",
168171
"brave_privacy_page:web_modules",
169172
"brave_sync_page:web_modules",

browser/resources/settings/brave_default_extensions_page/BUILD.gn

-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ group("web_modules") {
1414
public_deps = [
1515
":brave_default_extensions_page_module",
1616
":modules",
17-
":templatize",
1817
]
1918
}
2019

@@ -30,7 +29,3 @@ js_modulizer("modules") {
3029
input_files = [ "brave_default_extensions_browser_proxy.js" ]
3130
namespace_rewrites = settings_namespace_rewrites
3231
}
33-
34-
html_to_js("templatize") {
35-
js_files = [ "change_ipfs_gateway_dialog.js" ]
36-
}

browser/resources/settings/brave_default_extensions_page/brave_default_extensions_browser_proxy.js

-28
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ cr.define('settings', function () {
1515
setWebTorrentEnabled (value) {}
1616
setBraveWalletEnabled (value) {}
1717
setHangoutsEnabled (value) {}
18-
setIPFSCompanionEnabled (value) {}
1918
setTorEnabled (value) {}
2019
isTorEnabled () {}
2120
isTorManaged () {}
@@ -24,8 +23,6 @@ cr.define('settings', function () {
2423
getRestartNeeded () {}
2524
getWeb3ProviderList () {}
2625
wasSignInEnabledAtStartup () {}
27-
getIPFSResolveMethodList () {}
28-
getIPFSEnabled () {}
2926
}
3027

3128
/**
@@ -45,10 +42,6 @@ cr.define('settings', function () {
4542
chrome.send('setHangoutsEnabled', [value])
4643
}
4744

48-
setIPFSCompanionEnabled (value) {
49-
chrome.send('setIPFSCompanionEnabled', [value])
50-
}
51-
5245
setMediaRouterEnabled (value) {
5346
chrome.send('setMediaRouterEnabled', [value])
5447
}
@@ -86,27 +79,6 @@ cr.define('settings', function () {
8679
return loadTimeData.getBoolean('signInAllowedOnNextStartupInitialValue')
8780
}
8881

89-
/** @override */
90-
getIPFSResolveMethodList () {
91-
return new Promise(resolve => {
92-
if (!chrome.ipfs) {
93-
resolve(false)
94-
return
95-
}
96-
chrome.ipfs.getResolveMethodList(resolve)
97-
})
98-
}
99-
100-
/** @override */
101-
getIPFSEnabled () {
102-
return new Promise(resolve => {
103-
if (!chrome.ipfs) {
104-
resolve(false)
105-
return
106-
}
107-
chrome.ipfs.getIPFSEnabled(resolve)
108-
})
109-
}
11082
}
11183

11284
cr.addSingletonGetter(BraveDefaultExtensionsBrowserProxyImpl)

browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.html

-44
Original file line numberDiff line numberDiff line change
@@ -97,46 +97,6 @@
9797
sub-label="$i18n{hangoutsEnabledDesc}"
9898
on-settings-boolean-control-change="onHangoutsEnabledChange_">
9999
</settings-toggle-button>
100-
<template is="dom-if" if="{{ ipfsEnabled_ }}">
101-
<div class="settings-box">
102-
<div class="start">$i18n{resolveIPFSURLDesc}</div>
103-
<settings-dropdown-menu id="ipfsResolveMethodType"
104-
pref="{{prefs.brave.ipfs.resolve_method}}"
105-
menu-options="[[ipfsResolveMethod_]]">
106-
</settings-dropdown-menu>
107-
</div>
108-
<div class="settings-box">
109-
<div class="flex cr-padded-text">
110-
<div>$i18n{ipfsPublicGatewayDesc}</div>
111-
<div class="secondary" id="defaultIPFSGateway">
112-
{{prefs.brave.ipfs.public_gateway_address.value}}
113-
</div>
114-
</div>
115-
<cr-button id="changeIPFSGateway"
116-
on-click="onChangeIPFSGatewayDialogTapped_">
117-
$i18n{ipfsChangeGatewayButtonLabel}
118-
</cr-button>
119-
</div>
120-
<settings-toggle-button id="ipfsAutoGatewayFallbackEnabled"
121-
class="cr-row"
122-
pref="{{prefs.brave.ipfs.auto_fallback_to_gateway}}"
123-
label=$i18n{ipfsAutoFallbackToGatewayLabel}
124-
sub-label=$i18n{ipfsAutoFallbackToGatewayDesc}>
125-
</settings-toggle-button>
126-
<settings-toggle-button id="ipfsAutoRedirectGateway"
127-
class="cr-row"
128-
pref="{{prefs.brave.ipfs.auto_redirect_gateway}}"
129-
label="$i18n{ipfsAutoRedirectGatewayLabel}"
130-
sub-label="$i18n{ipfsAutoRedirectGatewayDesc}">
131-
</settings-toggle-button>
132-
</template>
133-
<settings-toggle-button id="ipfsCompanionEnabled"
134-
class="cr-row"
135-
pref="{{prefs.brave.ipfs_companion_enabled}}"
136-
label="IPFS Companion"
137-
sub-label="$i18n{ipfsCompanionEnabledDesc}"
138-
on-settings-boolean-control-change="onIPFSCompanionEnabledChange_">
139-
</settings-toggle-button>
140100
<settings-toggle-button id="mediaRouterEnabled"
141101
class="cr-row"
142102
pref="{{prefs.brave.enable_media_router}}"
@@ -201,10 +161,6 @@
201161
on-click="openWebStoreUrl_" external>
202162
</cr-link-row>
203163
</div>
204-
<template is="dom-if" if="[[showChangeIPFSGatewayDialog_]]" restamp>
205-
<change-ipfs-gateway-dialog prefs="{{prefs}}" on-close="onChangeIPFSGatewayDialogClosed_">
206-
</change-ipfs-gateway-dialog>
207-
</template>
208164
<template is="dom-if" if="{{ showRestartToast_ }}">
209165
<div id="needsRestart">
210166
<div class="flex-container">

browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.js

+2-25
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
33
* You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import './change_ipfs_gateway_dialog.js';
6-
75
(function() {
86
'use strict';
97

@@ -22,9 +20,7 @@ Polymer({
2220
showRestartToast_: Boolean,
2321
torEnabled_: Boolean,
2422
widevineEnabled_: Boolean,
25-
disableTorOption_: Boolean,
26-
ipfsEnabled_: Boolean,
27-
showChangeIPFSGatewayDialog_: Boolean,
23+
disableTorOption_: Boolean
2824
},
2925

3026
/** @private {?settings.BraveDefaultExtensionsBrowserProxy} */
@@ -40,7 +36,6 @@ Polymer({
4036
this.onWebTorrentEnabledChange_ = this.onWebTorrentEnabledChange_.bind(this)
4137
this.onBraveWalletEnabledChange_ = this.onBraveWalletEnabledChange_.bind(this)
4238
this.onHangoutsEnabledChange_ = this.onHangoutsEnabledChange_.bind(this)
43-
this.onIPFSCompanionEnabledChange_ = this.onIPFSCompanionEnabledChange_.bind(this)
4439
this.openExtensionsPage_ = this.openExtensionsPage_.bind(this)
4540
this.openKeyboardShortcutsPage_ = this.openKeyboardShortcutsPage_.bind(this)
4641
this.onWidevineEnabledChange_ = this.onWidevineEnabledChange_.bind(this)
@@ -72,12 +67,6 @@ Polymer({
7267
this.browserProxy_.getWeb3ProviderList().then(list => {
7368
this.braveWeb3Providers_ = JSON.parse(list)
7469
});
75-
this.browserProxy_.getIPFSResolveMethodList().then(list => {
76-
this.ipfsResolveMethod_ = JSON.parse(list)
77-
});
78-
this.browserProxy_.getIPFSEnabled().then(enabled => {
79-
this.ipfsEnabled_ = enabled
80-
});
8170
},
8271

8372
onWebTorrentEnabledChange_: function() {
@@ -92,10 +81,6 @@ Polymer({
9281
this.browserProxy_.setHangoutsEnabled(this.$.hangoutsEnabled.checked);
9382
},
9483

95-
onIPFSCompanionEnabledChange_: function() {
96-
this.browserProxy_.setIPFSCompanionEnabled(this.$.ipfsCompanionEnabled.checked);
97-
},
98-
9984
restartBrowser_: function(e) {
10085
e.stopPropagation();
10186
window.open("chrome://restart", "_self");
@@ -127,15 +112,7 @@ Polymer({
127112

128113
shouldShowRestartForGoogleLogin_: function(value) {
129114
return this.browserProxy_.wasSignInEnabledAtStartup() != value;
130-
},
131-
132-
onChangeIPFSGatewayDialogTapped_: function() {
133-
this.showChangeIPFSGatewayDialog_ = true;
134-
},
135-
136-
onChangeIPFSGatewayDialogClosed_: function() {
137-
this.showChangeIPFSGatewayDialog_ = false;
138-
},
115+
}
139116

140117
});
141118
})();

browser/resources/settings/brave_icons.html

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
<path
2121
d="M11.095 1a2.38 2.38 0 0 0-2.38 2.381V4.81h-3.81A1.904 1.904 0 0 0 3 6.714v2.857c0 .526.427.953.952.953h.34c1.246 0 2.38.896 2.505 2.135a2.38 2.38 0 0 1-2.368 2.627h-.477a.953.953 0 0 0-.952.952v2.857C3 20.148 3.852 21 4.905 21h2.857a.953.953 0 0 0 .952-.952v-.34c0-1.246.897-2.38 2.136-2.505a2.38 2.38 0 0 1 2.626 2.368v.477c0 .525.427.952.953.952h2.857a1.904 1.904 0 0 0 1.904-1.905v-3.81h1.429a2.38 2.38 0 1 0 0-4.761H19.19v-3.81a1.904 1.904 0 0 0-1.904-1.904h-3.81V3.38A2.38 2.38 0 0 0 11.096 1z" />
2222
</g>
23+
<g id="ipfs" viewBox="0 0 24 24">
24+
<path d="M18.3767 5.40622C18.3767 5.38907 18.3681 5.36334 18.3681 5.3462C18.3596 5.26045 18.3339 5.17471 18.2996 5.09754C18.291 5.08039 18.2996 5.07181 18.291 5.05466C18.291 5.04609 18.2824 5.04609 18.2738 5.03751C18.231 4.95177 18.1709 4.8746 18.0938 4.806C18.0766 4.78885 18.0595 4.78028 18.0423 4.76313C18.008 4.73741 17.9823 4.71168 17.948 4.68596L10.0337 0.115756C9.76793 -0.0385852 9.4421 -0.0385852 9.17629 0.115756L1.26204 4.69453C1.22774 4.71168 1.19344 4.73741 1.16772 4.76313C1.15057 4.78028 1.13342 4.78885 1.11627 4.806C1.0391 4.8746 0.979079 4.95177 0.936207 5.03751C0.936207 5.04609 0.927632 5.04609 0.919058 5.05466C0.910483 5.07181 0.919058 5.08039 0.910483 5.09754C0.876185 5.17471 0.850462 5.26045 0.841887 5.3462C0.841887 5.36334 0.841887 5.38049 0.833313 5.40622C0.833313 5.41479 0.833313 5.42337 0.833313 5.43194V14.5723C0.833313 14.881 0.996228 15.164 1.26204 15.3183L9.17629 19.8885C9.19344 19.8971 9.21917 19.9057 9.23631 19.9143C9.26204 19.9228 9.27919 19.9314 9.30491 19.94C9.39923 19.9743 9.50212 20 9.59644 20C9.69076 20 9.79366 19.9743 9.88798 19.94C9.9137 19.9314 9.93942 19.9228 9.95657 19.9143C9.97372 19.9057 9.99944 19.8971 10.0166 19.8885L17.9308 15.3183C18.1967 15.164 18.3596 14.881 18.3596 14.5723V5.43194C18.3853 5.42337 18.3767 5.41479 18.3767 5.40622ZM9.60502 1.85638L15.7015 5.37192L9.60502 8.34727L3.51713 5.37192L9.60502 1.85638ZM2.54821 6.80386L8.74757 9.83923V17.6592L2.54821 14.0836V6.80386ZM10.4625 17.6592V9.83923L16.6618 6.80386V14.075L10.4625 17.6592Z" fill="#495057"/>
25+
</g>
2326
<g id="sync" viewBox="0 0 24 24">
2427
<path
2528
d="M10.714 1a.933.933 0 0 0-.656.27L7.272 4.026a.914.914 0 0 0 0 1.3l2.786 2.757a.936.936 0 0 0 1.011.198.92.92 0 0 0 .574-.848V5.596c3.6 0 6.5 2.87 6.5 6.434 0 .912-.198 1.814-.579 2.645a.911.911 0 0 0 .073.934.932.932 0 0 0 1.62-.179 8.184 8.184 0 0 0 .743-3.4c0-4.558-3.752-8.272-8.357-8.272V1.919A.924.924 0 0 0 10.714 1zm-6.11 7a.929.929 0 0 0-.86.553A8.2 8.2 0 0 0 3 11.958c0 4.563 3.752 8.282 8.357 8.282v1.84a.92.92 0 0 0 .573.85.935.935 0 0 0 1.012-.2l2.786-2.76a.915.915 0 0 0 0-1.301l-2.786-2.76a.936.936 0 0 0-1.011-.199.921.921 0 0 0-.574.849v1.84c-3.6 0-6.5-2.874-6.5-6.441 0-.944.209-1.836.579-2.648a.913.913 0 0 0-.055-.88.93.93 0 0 0-.777-.43z" />
@@ -32,6 +35,9 @@
3235
<path
3336
d="M2.75 3c-.414 0-.75.42-.75.938v9.374c0 .518.336.938.75.938h1.5c.414 0 .75-.42.75-.938V3.938C5 3.42 4.664 3 4.25 3h-1.5zm6.125 0A1.866 1.866 0 0 0 7 4.857v9.278c0 .492.197.963.547 1.31l5.185 5.146a1.417 1.417 0 0 0 1.67.239c.548-.297.834-.916.7-1.52l-.932-4.24h5.955A1.866 1.866 0 0 0 22 13.215v-1.855c0-.253-.051-.502-.152-.734l-2.82-6.5A1.876 1.876 0 0 0 17.305 3h-8.43z" />
3437
</g>
38+
<g id="ipfs" viewBox="0 0 19 20">
39+
<path d="M18.3767 5.40622C18.3767 5.38907 18.3681 5.36334 18.3681 5.3462C18.3596 5.26045 18.3339 5.17471 18.2996 5.09754C18.291 5.08039 18.2996 5.07181 18.291 5.05466C18.291 5.04609 18.2824 5.04609 18.2738 5.03751C18.231 4.95177 18.1709 4.8746 18.0938 4.806C18.0766 4.78885 18.0595 4.78028 18.0423 4.76313C18.008 4.73741 17.9823 4.71168 17.948 4.68596L10.0337 0.115756C9.76793 -0.0385852 9.4421 -0.0385852 9.17629 0.115756L1.26204 4.69453C1.22774 4.71168 1.19344 4.73741 1.16772 4.76313C1.15057 4.78028 1.13342 4.78885 1.11627 4.806C1.0391 4.8746 0.979079 4.95177 0.936207 5.03751C0.936207 5.04609 0.927632 5.04609 0.919058 5.05466C0.910483 5.07181 0.919058 5.08039 0.910483 5.09754C0.876185 5.17471 0.850462 5.26045 0.841887 5.3462C0.841887 5.36334 0.841887 5.38049 0.833313 5.40622C0.833313 5.41479 0.833313 5.42337 0.833313 5.43194V14.5723C0.833313 14.881 0.996228 15.164 1.26204 15.3183L9.17629 19.8885C9.19344 19.8971 9.21917 19.9057 9.23631 19.9143C9.26204 19.9228 9.27919 19.9314 9.30491 19.94C9.39923 19.9743 9.50212 20 9.59644 20C9.69076 20 9.79366 19.9743 9.88798 19.94C9.9137 19.9314 9.93942 19.9228 9.95657 19.9143C9.97372 19.9057 9.99944 19.8971 10.0166 19.8885L17.9308 15.3183C18.1967 15.164 18.3596 14.881 18.3596 14.5723V5.43194C18.3853 5.42337 18.3767 5.41479 18.3767 5.40622ZM9.60502 1.85638L15.7015 5.37192L9.60502 8.34727L3.51713 5.37192L9.60502 1.85638ZM2.54821 6.80386L8.74757 9.83923V17.6592L2.54821 14.0836V6.80386ZM10.4625 17.6592V9.83923L16.6618 6.80386V14.075L10.4625 17.6592Z" fill="#495057"/>
40+
</g>
3541
<g id="search-engine" viewBox="0 0 24 24">
3642
<path
3743
d="M15.31 13.896l1.397 1.397a1 1 0 0 1-1.414 1.414l-1.397-1.397a4.5 4.5 0 1 1 1.414-1.414zM11.5 14a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zM5 4a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1H5zm0-2h14a3 3 0 0 1 3 3v14a3 3 0 0 1-3 3H5a3 3 0 0 1-3-3V5a3 3 0 0 1 3-3z" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) 2021 The Brave Authors. All rights reserved.
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
4+
# you can obtain one at http://mozilla.org/MPL/2.0/.
5+
6+
import("//tools/polymer/html_to_js.gni")
7+
import("//tools/polymer/polymer.gni")
8+
import("//ui/webui/resources/tools/js_modulizer.gni")
9+
import("../settings.gni")
10+
11+
# ES Module conversion from HTML Imports code
12+
13+
group("web_modules") {
14+
public_deps = [
15+
":brave_ipfs_page_module",
16+
":modules",
17+
":templatize",
18+
]
19+
}
20+
21+
polymer_modulizer("brave_ipfs_page") {
22+
js_file = "brave_ipfs_page.js"
23+
html_file = "brave_ipfs_page.html"
24+
html_type = "dom-module"
25+
auto_imports = settings_auto_imports + [ "brave/browser/resources/settings/brave_ipfs_page/brave_ipfs_browser_proxy.html|BraveIPFSBrowserProxy, BraveIPFSBrowserProxyImpl" ]
26+
namespace_rewrites = settings_namespace_rewrites
27+
}
28+
29+
js_modulizer("modules") {
30+
input_files = [ "brave_ipfs_browser_proxy.js" ]
31+
namespace_rewrites = settings_namespace_rewrites
32+
}
33+
html_to_js("templatize") {
34+
js_files = [ "change_ipfs_gateway_dialog.js" ]
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<link rel="href" src="chrome://resources/html/cr.html">
2+
<script src="brave_ipfs_browser_proxy.js"></script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
* You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
// clang-format off
6+
// #import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js';
7+
// clang-format on
8+
9+
cr.define('settings', function () {
10+
/** @interface */
11+
/* #export */ class BraveIPFSBrowserProxy {
12+
/**
13+
* @param {boolean} value name.
14+
*/
15+
setIPFSCompanionEnabled (value) {}
16+
getIPFSResolveMethodList () {}
17+
getIPFSEnabled () {}
18+
}
19+
20+
/**
21+
* @implements {settings.BraveIPFSBrowserProxy}
22+
*/
23+
/* #export */ class BraveIPFSBrowserProxyImpl {
24+
setIPFSCompanionEnabled (value) {
25+
chrome.send('setIPFSCompanionEnabled', [value])
26+
}
27+
28+
/** @override */
29+
getIPFSResolveMethodList () {
30+
return new Promise(resolve => {
31+
if (!chrome.ipfs) {
32+
resolve(false)
33+
return
34+
}
35+
chrome.ipfs.getResolveMethodList(resolve)
36+
})
37+
}
38+
39+
/** @override */
40+
getIPFSEnabled () {
41+
return new Promise(resolve => {
42+
if (!chrome.ipfs) {
43+
resolve(false)
44+
return
45+
}
46+
chrome.ipfs.getIPFSEnabled(resolve)
47+
})
48+
}
49+
}
50+
51+
cr.addSingletonGetter(BraveIPFSBrowserProxyImpl)
52+
53+
// #cr_define_end
54+
return {
55+
BraveIPFSBrowserProxy,
56+
BraveIPFSBrowserProxyImpl
57+
}
58+
})

0 commit comments

Comments
 (0)