diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd
index 32d64d561f11..9f7f7b6a0b6d 100644
--- a/app/brave_generated_resources.grd
+++ b/app/brave_generated_resources.grd
@@ -393,6 +393,10 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
Use Google Services for Push Messaging
+
+
+ Remote debugging
+
Sync
diff --git a/browser/brave_local_state_prefs.cc b/browser/brave_local_state_prefs.cc
index 440adb6b79dd..44550b3db815 100644
--- a/browser/brave_local_state_prefs.cc
+++ b/browser/brave_local_state_prefs.cc
@@ -9,13 +9,14 @@
#include "brave/browser/brave_stats_updater.h"
#include "brave/browser/metrics/metrics_reporting_util.h"
#include "brave/browser/tor/buildflags.h"
+#include "brave/common/pref_names.h"
#include "brave/components/brave_referrals/buildflags/buildflags.h"
#include "brave/components/brave_shields/browser/ad_block_service.h"
#include "brave/components/brave_shields/browser/brave_shields_p3a.h"
-#include "brave/components/p3a/buildflags.h"
#include "brave/components/p3a/brave_p3a_service.h"
-#include "chrome/common/pref_names.h"
+#include "brave/components/p3a/buildflags.h"
#include "chrome/browser/first_run/first_run.h"
+#include "chrome/common/pref_names.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "third_party/widevine/cdm/buildflags.h"
@@ -41,6 +42,7 @@ namespace brave {
void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
brave_shields::RegisterPrefsForAdBlockService(registry);
RegisterPrefsForBraveStatsUpdater(registry);
+ registry->RegisterBooleanPref(kRemoteDebuggingEnabled, false);
#if BUILDFLAG(ENABLE_BRAVE_REFERRALS)
RegisterPrefsForBraveReferralsService(registry);
#endif
diff --git a/browser/resources/settings/brave_privacy_page/brave_personalization_options.html b/browser/resources/settings/brave_privacy_page/brave_personalization_options.html
index 35409d3124eb..937704298863 100644
--- a/browser/resources/settings/brave_privacy_page/brave_personalization_options.html
+++ b/browser/resources/settings/brave_privacy_page/brave_personalization_options.html
@@ -48,6 +48,12 @@
+
+
diff --git a/browser/resources/settings/brave_privacy_page/brave_personalization_options.js b/browser/resources/settings/brave_privacy_page/brave_personalization_options.js
index 1d1ecd4c69dd..3707ec292388 100644
--- a/browser/resources/settings/brave_privacy_page/brave_personalization_options.js
+++ b/browser/resources/settings/brave_privacy_page/brave_personalization_options.js
@@ -23,7 +23,8 @@ Polymer({
},
webRTCPolicy_: String,
- p3aEnabled_: Boolean
+ p3aEnabled_: Boolean,
+ remoteDebuggingEnabled_: Boolean
},
/** @private {?settings.BravePrivacyBrowserProxy} */
@@ -46,6 +47,9 @@ Polymer({
this.browserProxy_.getP3AEnabled().then(enabled => {
this.p3aEnabled_ = enabled;
});
+ this.browserProxy_.getRemoteDebuggingEnabled().then(enabled => {
+ this.remoteDebuggingEnabled_ = enabled;
+ });
},
/**
@@ -65,7 +69,11 @@ Polymer({
onP3AEnabledChange_: function() {
this.browserProxy_.setP3AEnabled(this.$.p3aEnabled.checked);
},
-
+
+ onRemoteDebuggingEnabledChange_: function() {
+ this.browserProxy_.setRemoteDebuggingEnabled(this.$.remoteDebuggingEnabled.checked);
+ },
+
shouldShowRestart_: function(enabled) {
return enabled != this.browserProxy_.wasPushMessagingEnabledAtStartup();
},
diff --git a/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.js b/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.js
index 0d63ababbe6a..10d3e0c1ddd2 100644
--- a/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.js
+++ b/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.js
@@ -21,6 +21,14 @@ cr.define('settings', function() {
* @param {boolean} enabled (true/false).
*/
setP3AEnabled(value) {}
+ /**
+ * @return {!Promise}
+ */
+ getRemoteDebuggingEnabled() {}
+ /**
+ * @param {boolean} enabled (true/false).
+ */
+ setRemoteDebuggingEnabled(value) {}
/**
* @return {boolean}
*/
@@ -31,26 +39,31 @@ cr.define('settings', function() {
* @implements {settings.BravePrivacyBrowserProxy}
*/
class BravePrivacyBrowserProxyImpl {
- /** @override */
+ /** @overrides */
getWebRTCPolicy() {
return cr.sendWithPromise('getWebRTCPolicy');
}
- /** @override */
setWebRTCPolicy(policy) {
chrome.send('setWebRTCPolicy', [policy]);
}
- /** @override */
getP3AEnabled() {
return cr.sendWithPromise('getP3AEnabled');
}
- /** @override */
setP3AEnabled(value) {
chrome.send('setP3AEnabled', [value])
}
+ getRemoteDebuggingEnabled() {
+ return cr.sendWithPromise('getRemoteDebuggingEnabled');
+ }
+
+ setRemoteDebuggingEnabled(value) {
+ chrome.send('setRemoteDebuggingEnabled', [value])
+ }
+
wasPushMessagingEnabledAtStartup() {
return loadTimeData.getBoolean('pushMessagingEnabledAtStartup');
}
diff --git a/browser/ui/webui/settings/brave_privacy_handler.cc b/browser/ui/webui/settings/brave_privacy_handler.cc
index 668efe47a67e..b9bcd49ba746 100644
--- a/browser/ui/webui/settings/brave_privacy_handler.cc
+++ b/browser/ui/webui/settings/brave_privacy_handler.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/values.h"
+#include "brave/common/pref_names.h"
#include "brave/components/p3a/pref_names.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
@@ -16,8 +17,8 @@
#include "components/gcm_driver/gcm_buildflags.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui.h"
-#include "content/public/common/webrtc_ip_handling_policy.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/common/webrtc_ip_handling_policy.h"
#if !BUILDFLAG(USE_GCM_FROM_PLATFORM)
#include "brave/browser/gcm_driver/brave_gcm_channel_status.h"
@@ -40,6 +41,14 @@ void BravePrivacyHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"getP3AEnabled", base::BindRepeating(&BravePrivacyHandler::GetP3AEnabled,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "setRemoteDebuggingEnabled",
+ base::BindRepeating(&BravePrivacyHandler::SetRemoteDebuggingEnabled,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "getRemoteDebuggingEnabled",
+ base::BindRepeating(&BravePrivacyHandler::GetRemoteDebuggingEnabled,
+ base::Unretained(this)));
}
// static
@@ -97,3 +106,25 @@ void BravePrivacyHandler::GetP3AEnabled(const base::ListValue* args) {
AllowJavascript();
ResolveJavascriptCallback(args->GetList()[0].Clone(), base::Value(enabled));
}
+
+void BravePrivacyHandler::SetRemoteDebuggingEnabled(
+ const base::ListValue* args) {
+ CHECK_EQ(args->GetSize(), 1U);
+
+ bool enabled;
+ args->GetBoolean(0, &enabled);
+
+ PrefService* local_state = g_browser_process->local_state();
+ local_state->SetBoolean(kRemoteDebuggingEnabled, enabled);
+}
+
+void BravePrivacyHandler::GetRemoteDebuggingEnabled(
+ const base::ListValue* args) {
+ CHECK_EQ(args->GetSize(), 1U);
+
+ PrefService* local_state = g_browser_process->local_state();
+ bool enabled = local_state->GetBoolean(kRemoteDebuggingEnabled);
+
+ AllowJavascript();
+ ResolveJavascriptCallback(args->GetList()[0].Clone(), base::Value(enabled));
+}
diff --git a/browser/ui/webui/settings/brave_privacy_handler.h b/browser/ui/webui/settings/brave_privacy_handler.h
index d1501b5bc10b..b97993986ac9 100644
--- a/browser/ui/webui/settings/brave_privacy_handler.h
+++ b/browser/ui/webui/settings/brave_privacy_handler.h
@@ -33,6 +33,9 @@ class BravePrivacyHandler : public settings::SettingsPageUIHandler {
void SetP3AEnabled(const base::ListValue* args);
void GetP3AEnabled(const base::ListValue* args);
+ void SetRemoteDebuggingEnabled(const base::ListValue* args);
+ void GetRemoteDebuggingEnabled(const base::ListValue* args);
+
Profile* profile_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(BravePrivacyHandler);
diff --git a/chromium_src/chrome/browser/devtools/devtools_ui_bindings.cc b/chromium_src/chrome/browser/devtools/devtools_ui_bindings.cc
new file mode 100644
index 000000000000..f65fc24e683a
--- /dev/null
+++ b/chromium_src/chrome/browser/devtools/devtools_ui_bindings.cc
@@ -0,0 +1,26 @@
+/* Copyright (c) 2019 The Brave Authors. All rights reserved.
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "brave/common/pref_names.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/devtools/devtools_ui_bindings.h"
+
+#define IsValidRemoteFrontendURL IsValidRemoteFrontendURL_ChromiumImpl
+#include "../../../../../../chrome/browser/devtools/devtools_ui_bindings.cc"
+#undef IsValidRemoteFrontendURL
+
+bool DevToolsUIBindings::IsValidRemoteFrontendURL(const GURL& url) {
+ PrefService* local_state = g_browser_process->local_state();
+ if (local_state) {
+ if (!local_state->GetBoolean(kRemoteDebuggingEnabled)) {
+ LOG(ERROR)
+ << "Remote debugging is DISABLED. If you want to use it, please "
+ "enable in brave://settings/privacy";
+ return false;
+ }
+ }
+
+ return IsValidRemoteFrontendURL_ChromiumImpl(url);
+}
diff --git a/chromium_src/chrome/browser/devtools/devtools_ui_bindings.h b/chromium_src/chrome/browser/devtools/devtools_ui_bindings.h
new file mode 100644
index 000000000000..6e13a2ccebee
--- /dev/null
+++ b/chromium_src/chrome/browser/devtools/devtools_ui_bindings.h
@@ -0,0 +1,15 @@
+// Copyright (c) 2019 The Brave Authors. All rights reserved.
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this file,
+// you can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_
+#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_
+
+#define IsValidRemoteFrontendURL \
+ IsValidRemoteFrontendURL_ChromiumImpl(const GURL& url); \
+ static bool IsValidRemoteFrontendURL
+#include "../../../../../chrome/browser/devtools/devtools_ui_bindings.h"
+#undef IsValidRemoteFrontendURL
+
+#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_
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 7b5c03a02b46..7f004b685326 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
@@ -162,7 +162,9 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source,
{"p3aEnableTitle",
IDS_BRAVE_P3A_ENABLE_SETTING},
{"p3aEnabledDesc",
- IDS_BRAVE_P3A_ENABLE_SETTING_SUBITEM}
+ IDS_BRAVE_P3A_ENABLE_SETTING_SUBITEM},
+ {"remoteDebuggingEnabledTitle",
+ IDS_SETTINGS_REMOTE_DEBUGGING_TITLE}
};
AddLocalizedStringsBulk(html_source, localized_strings,
base::size(localized_strings));
diff --git a/common/pref_names.cc b/common/pref_names.cc
index cf1173c75ea7..00a4ff3562ec 100644
--- a/common/pref_names.cc
+++ b/common/pref_names.cc
@@ -72,6 +72,7 @@ const char kBraveWalletEncryptedSeed[] = "brave.wallet.encrypted_seed";
const char kBraveWalletEnabled[] = "brave.wallet.enabled";
const char kAlwaysShowBookmarkBarOnNTP[] =
"brave.always_show_bookmark_bar_on_ntp";
+const char kRemoteDebuggingEnabled[] = "brave.remote_debugging_enabled";
#if defined(OS_ANDROID)
const char kDesktopModeEnabled[] = "brave.desktop_mode_enabled";
diff --git a/common/pref_names.h b/common/pref_names.h
index 8c3006d77977..5aeb168d93f0 100644
--- a/common/pref_names.h
+++ b/common/pref_names.h
@@ -61,6 +61,7 @@ extern const char kBraveWalletAES256GCMSivNonce[];
extern const char kBraveWalletEncryptedSeed[];
extern const char kBraveWalletEnabled[];
extern const char kAlwaysShowBookmarkBarOnNTP[];
+extern const char kRemoteDebuggingEnabled[];
#if defined(OS_ANDROID)
extern const char kDesktopModeEnabled[];
diff --git a/patches/chrome-browser-ui-webui-devtools_ui_data_source.cc.patch b/patches/chrome-browser-ui-webui-devtools_ui_data_source.cc.patch
deleted file mode 100644
index d6d407989b1f..000000000000
--- a/patches/chrome-browser-ui-webui-devtools_ui_data_source.cc.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/chrome/browser/ui/webui/devtools_ui_data_source.cc b/chrome/browser/ui/webui/devtools_ui_data_source.cc
-index 95e73c57300e7426d70c669439c18efb68be5337..b177eedddda5d5e4b740d6dee2ae870ac188f938 100644
---- a/chrome/browser/ui/webui/devtools_ui_data_source.cc
-+++ b/chrome/browser/ui/webui/devtools_ui_data_source.cc
-@@ -191,6 +191,7 @@ void DevToolsDataSource::StartBundledDataRequest(
- void DevToolsDataSource::StartRemoteDataRequest(
- const GURL& url,
- const content::URLDataSource::GotDataCallback& callback) {
-+ return; // feature disabled in Brave
- CHECK(url.is_valid());
- net::NetworkTrafficAnnotationTag traffic_annotation =
- net::DefineNetworkTrafficAnnotation("devtools_hard_coded_data_source",