[cr140] Migrate SkusJSHandler to gin::Wrappable

This class had been moved to `gin::DeprecatedWrappable` with all the
other classes, but now it is being migrated to the modern version we are
supposed to use.

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/61e491610dac67129273aa96549603483c59759f

commit 61e491610dac67129273aa96549603483c59759f
Author: Andreas Haas <ahaas@chromium.org>
Date:   Wed Jul 30 03:35:32 2025 -0700

    [gin] Delete DeprecatedWrappable

    This CL deletes gin::DeprecatedWrappable, and classes and data
    structures related to gin::DeprecatedWrappable. Additionally it removes
    internal fields of JS wrapper objects that were only used by
    gin::DeprecatedWrappable, but are not needed anymore with the new
    gin::Wrappable.

    Bug: 345640553
    Change-Id: Ideb4424048e62fec6c6a7ee5fd60a4635f6ef1e8
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6799157
    Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
    Reviewed-by: Camille Lamy <clamy@chromium.org>
    Commit-Queue: Andreas Haas <ahaas@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1494071}
This commit is contained in:
Claudio DeSouza
2025-08-19 19:54:32 +01:00
parent fee9806cde
commit 06c9414a0d
3 changed files with 16 additions and 13 deletions
@@ -13,6 +13,7 @@
kEthereumProvider, \
kMetaMask, \
kSolanaProvider, \
kSkusBindings, \
kCardanoProvider
// clang-format on
+11 -11
View File
@@ -18,7 +18,6 @@
#include "content/public/renderer/v8_value_converter.h"
#include "gin/arguments.h"
#include "gin/function_template.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
@@ -28,6 +27,8 @@
#include "third_party/blink/public/web/web_console_message.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_script_source.h"
#include "v8/include/cppgc/allocation.h"
#include "v8/include/v8-cppgc.h"
#if BUILDFLAG(ENABLE_BRAVE_VPN)
#include "brave/components/brave_vpn/common/brave_vpn_utils.h"
@@ -35,9 +36,6 @@
namespace skus {
gin::DeprecatedWrapperInfo SkusJSHandler::kWrapperInfo = {
gin::kEmbedderNativeGin};
SkusJSHandler::SkusJSHandler(content::RenderFrame* render_frame)
: content::RenderFrameObserver(render_frame) {}
@@ -89,10 +87,10 @@ void SkusJSHandler::Install(content::RenderFrame* render_frame) {
}
// window.chrome.braveSkus
gin::Handle<SkusJSHandler> handler =
gin::CreateHandle(isolate, new SkusJSHandler(render_frame));
CHECK(!handler.IsEmpty());
v8::PropertyDescriptor skus_desc(handler.ToV8(), false);
SkusJSHandler* handler = cppgc::MakeGarbageCollected<SkusJSHandler>(
isolate->GetCppHeap()->GetAllocationHandle(), render_frame);
v8::PropertyDescriptor skus_desc(
handler->GetWrapper(isolate).ToLocalChecked(), false);
skus_desc.set_configurable(false);
chrome_obj
@@ -102,7 +100,6 @@ void SkusJSHandler::Install(content::RenderFrame* render_frame) {
}
void SkusJSHandler::OnDestruct() {
delete this;
}
// window.chrome.braveSkus.refresh_order
@@ -320,8 +317,7 @@ void SkusJSHandler::OnCredentialSummary(
gin::ObjectTemplateBuilder SkusJSHandler::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return gin::DeprecatedWrappable<SkusJSHandler>::GetObjectTemplateBuilder(
isolate)
return gin::Wrappable<SkusJSHandler>::GetObjectTemplateBuilder(isolate)
.SetMethod("refresh_order", &SkusJSHandler::RefreshOrder)
.SetMethod("fetch_order_credentials",
&SkusJSHandler::FetchOrderCredentials)
@@ -330,4 +326,8 @@ gin::ObjectTemplateBuilder SkusJSHandler::GetObjectTemplateBuilder(
.SetMethod("credential_summary", &SkusJSHandler::CredentialSummary);
}
const gin::WrapperInfo* SkusJSHandler::wrapper_info() const {
return &kWrapperInfo;
}
} // namespace skus
+4 -2
View File
@@ -37,14 +37,15 @@ namespace skus {
// detect the purchase and use those credentials during authentication when
// establishing a connection to our partner providing the VPN service.
class SkusJSHandler : public content::RenderFrameObserver,
public gin::DeprecatedWrappable<SkusJSHandler> {
public gin::Wrappable<SkusJSHandler> {
public:
explicit SkusJSHandler(content::RenderFrame* render_frame);
SkusJSHandler(const SkusJSHandler&) = delete;
SkusJSHandler& operator=(const SkusJSHandler&) = delete;
~SkusJSHandler() override;
static gin::DeprecatedWrapperInfo kWrapperInfo;
static constexpr gin::WrapperInfo kWrapperInfo = {{gin::kEmbedderNativeGin},
gin::kSkusBindings};
static void Install(content::RenderFrame* render_frame);
@@ -57,6 +58,7 @@ class SkusJSHandler : public content::RenderFrameObserver,
// gin::WrappableBase
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;
const gin::WrapperInfo* wrapper_info() const override;
// window.chrome.braveSkus.refresh_order
v8::Local<v8::Promise> RefreshOrder(v8::Isolate* isolate,