Skip to content

Commit

Permalink
Disabling getBattery | bluetooth | credential.get/store | navigator.u…
Browse files Browse the repository at this point in the history
…sb apis
  • Loading branch information
jumde committed Jun 13, 2018
1 parent 9e67a5b commit 3ef9213
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "third_party/blink/renderer/modules/battery/navigator_battery.h"

#include "gin/converter.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
#include "net/proxy_resolution/proxy_resolver_v8.h"

namespace blink {
ScriptPromise NavigatorBattery::getBattery(ScriptState* script_state,
Navigator& navigator) {
v8::Isolate* isolate = V8PerIsolateData::MainThreadIsolate();
return blink::ScriptPromise::Reject(script_state,
v8::Exception::TypeError(gin::StringToV8(isolate, "This api has been disabled.")));
}
} // namespace blink
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "third_party/blink/renderer/modules/bluetooth/navigator_bluetooth.h"

namespace blink {
Bluetooth* NavigatorBluetooth::bluetooth(Navigator& navigator) {
return NULL;
}

Bluetooth* NavigatorBluetooth::bluetooth() {
return NULL;
}
} // namespace blink
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "third_party/blink/renderer/modules/credentialmanager/credentials_container.h"

#include "gin/converter.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"

namespace blink {

ScriptPromise CredentialsContainer::get(
ScriptState* script_state,
const CredentialRequestOptions& options) {
v8::Isolate* isolate = V8PerIsolateData::MainThreadIsolate();
return ScriptPromise::Reject(script_state, v8::Exception::TypeError(gin::StringToV8(isolate,
"This api has been disabled.")));
}

ScriptPromise CredentialsContainer::store(ScriptState* script_state,
Credential* credential) {
v8::Isolate* isolate = V8PerIsolateData::MainThreadIsolate();
return ScriptPromise::Reject(script_state, v8::Exception::TypeError(gin::StringToV8(isolate,
"This api has been disabled.")));
}
} // namespace blink
14 changes: 14 additions & 0 deletions patches/third_party-blink-renderer-modules-battery-BUILD.gn.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/third_party/blink/renderer/modules/battery/BUILD.gn b/third_party/blink/renderer/modules/battery/BUILD.gn
index 64c9513c20a1bfa765c26de56acc8ee2c16a98f5..a4cbd9ac777e35f9e108beca8b8ebe7f6cc2cbcf 100644
--- a/third_party/blink/renderer/modules/battery/BUILD.gn
+++ b/third_party/blink/renderer/modules/battery/BUILD.gn
@@ -11,8 +11,8 @@ blink_modules_sources("battery") {
"battery_manager.cc",
"battery_manager.h",
"battery_status.h",
- "navigator_battery.cc",
"navigator_battery.h",
+ "//brave/chromium_src/third_party/blink/render/modules/battery/navigator_battery.cc",
]

deps = [
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/third_party/blink/renderer/modules/bluetooth/BUILD.gn b/third_party/blink/renderer/modules/bluetooth/BUILD.gn
index 86525ded88b86ee42b6f01cfe19231dec5cedbb5..cc7fec1705f7034f732bafc10290da72b88dbea7 100644
--- a/third_party/blink/renderer/modules/bluetooth/BUILD.gn
+++ b/third_party/blink/renderer/modules/bluetooth/BUILD.gn
@@ -28,7 +28,7 @@ blink_modules_sources("bluetooth") {
"bluetooth_remote_gatt_utils.h",
"bluetooth_uuid.cc",
"bluetooth_uuid.h",
- "navigator_bluetooth.cc",
+ "//brave/chromium_src/third_party/blink/render/modules/bluetooth/navigator_bluetooth.cc",
"navigator_bluetooth.h",
]

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/third_party/blink/renderer/modules/credentialmanager/BUILD.gn b/third_party/blink/renderer/modules/credentialmanager/BUILD.gn
index 18f143a1e7c1a8bfb9ecf8d2b2702195c0065488..d530694993fa2082f8d463f111f57543da237613 100644
--- a/third_party/blink/renderer/modules/credentialmanager/BUILD.gn
+++ b/third_party/blink/renderer/modules/credentialmanager/BUILD.gn
@@ -19,6 +19,7 @@ blink_modules_sources("credentialmanager") {
"credential_manager_type_converters.cc",
"credential_manager_type_converters.h",
"credentials_container.cc",
+ "//brave/chromium_src/third_party/blink/render/modules/credentialmanager/brave_credentials_container.cc",
"credentials_container.h",
"federated_credential.cc",
"federated_credential.h",
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
diff --git a/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc b/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc
index 004fca6cd7d6a1fbba472d7ead99f18659d5e402..3d225496d5f00d049808aab8d754d46569f84ff0 100644
--- a/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc
+++ b/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc
@@ -214,6 +214,7 @@ bool CheckPublicKeySecurityRequirements(ScriptPromiseResolver* resolver,
return true;
}

+#if defined(MUON_CHROMIUM_BUILD)
// Checks if the icon URL of |credential| is an a-priori authenticated URL.
// https://w3c.github.io/webappsec-credential-management/#dom-credentialuserdata-iconurl
bool IsIconURLEmptyOrSecure(const Credential* credential) {
@@ -235,6 +236,7 @@ bool IsIconURLEmptyOrSecure(const Credential* credential) {
url.ProtocolIsData() ||
SecurityOrigin::Create(url)->IsPotentiallyTrustworthy();
}
+#endif

DOMException* CredentialManagerErrorToDOMException(
CredentialManagerError reason) {
@@ -303,12 +305,14 @@ DOMException* CredentialManagerErrorToDOMException(
return nullptr;
}

+#if defined(MUON_CHROMIUM_BUILD)
void OnStoreComplete(std::unique_ptr<ScopedPromiseResolver> scoped_resolver,
RequiredOriginType required_origin_type) {
auto* resolver = scoped_resolver->Release();
AssertSecurityRequirementsBeforeResponse(resolver, required_origin_type);
resolver->Resolve();
}
+#endif

void OnPreventSilentAccessComplete(
std::unique_ptr<ScopedPromiseResolver> scoped_resolver) {
@@ -319,6 +323,7 @@ void OnPreventSilentAccessComplete(
resolver->Resolve();
}

+#if defined(MUON_CHROMIUM_BUILD)
void OnGetComplete(std::unique_ptr<ScopedPromiseResolver> scoped_resolver,
RequiredOriginType required_origin_type,
CredentialManagerError error,
@@ -336,6 +341,7 @@ void OnGetComplete(std::unique_ptr<ScopedPromiseResolver> scoped_resolver,
resolver->Reject(CredentialManagerErrorToDOMException(error));
}
}
+#endif

DOMArrayBuffer* VectorToDOMArrayBuffer(const Vector<uint8_t> buffer) {
return DOMArrayBuffer::Create(static_cast<const void*>(buffer.data()),
@@ -375,6 +381,7 @@ void OnMakePublicKeyCredentialComplete(
}
}

+#if defined(MUON_CHROMIUM_BUILD)
void OnGetAssertionComplete(
std::unique_ptr<ScopedPromiseResolver> scoped_resolver,
AuthenticatorStatus status,
@@ -415,6 +422,7 @@ void OnGetAssertionComplete(
mojo::ConvertTo<CredentialManagerError>(status)));
}
}
+#endif

} // namespace

@@ -424,6 +432,7 @@ CredentialsContainer* CredentialsContainer::Create() {

CredentialsContainer::CredentialsContainer() = default;

+#if defined(MUON_CHROMIUM_BUILD)
ScriptPromise CredentialsContainer::get(
ScriptState* script_state,
const CredentialRequestOptions& options) {
@@ -549,6 +558,7 @@ ScriptPromise CredentialsContainer::store(ScriptState* script_state,

return promise;
}
+#endif

ScriptPromise CredentialsContainer::create(
ScriptState* script_state,
5 changes: 5 additions & 0 deletions renderer/brave_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/renderer/brave_content_renderer_client.h"
#include "third_party/blink/public/platform/web_runtime_features.h"

BraveContentRendererClient::BraveContentRendererClient()
: ChromeContentRendererClient() {}

void BraveContentRendererClient::SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() {
blink::WebRuntimeFeatures::EnableWebUsb(false);
blink::WebRuntimeFeatures::EnableSharedArrayBuffer(false);
}
BraveContentRendererClient::~BraveContentRendererClient() = default;
1 change: 1 addition & 0 deletions renderer/brave_content_renderer_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class BraveContentRendererClient : public ChromeContentRendererClient {
public:
BraveContentRendererClient();
~BraveContentRendererClient() override;
void SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() override;

private:
DISALLOW_COPY_AND_ASSIGN(BraveContentRendererClient);
Expand Down

0 comments on commit 3ef9213

Please sign in to comment.