From 73e76c5e24e8b93168c29c763e541acff53d201b Mon Sep 17 00:00:00 2001 From: Colin Liang Date: Fri, 24 Jan 2025 13:28:26 -0800 Subject: [PATCH 1/3] Add H5vccSystem web interface, set window.h5vcc.h5vccSystem object The readonly property advertisingId under H5vccSystem return a dummy value. b/377049113 --- .../bindings/generated_in_modules.gni | 2 + .../renderer/bindings/idl_in_modules.gni | 1 + third_party/blink/renderer/modules/BUILD.gn | 1 + .../blink/renderer/modules/cobalt/BUILD.gn | 5 +- .../modules/cobalt/h5vcc_system/BUILD.gn | 7 +++ .../cobalt/h5vcc_system/h_5_vcc_system.cc | 57 +++++++++++++++++ .../cobalt/h5vcc_system/h_5_vcc_system.h | 61 +++++++++++++++++++ .../cobalt/h5vcc_system/h_5_vcc_system.idl | 21 +++++++ .../blink/renderer/modules/cobalt/h_5_vcc.cc | 5 +- .../blink/renderer/modules/cobalt/h_5_vcc.h | 4 ++ .../blink/renderer/modules/cobalt/h_5_vcc.idl | 1 + 11 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 third_party/blink/renderer/modules/cobalt/h5vcc_system/BUILD.gn create mode 100644 third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.cc create mode 100644 third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h create mode 100644 third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.idl diff --git a/third_party/blink/renderer/bindings/generated_in_modules.gni b/third_party/blink/renderer/bindings/generated_in_modules.gni index 7394d035208..2104bfb492e 100644 --- a/third_party/blink/renderer/bindings/generated_in_modules.gni +++ b/third_party/blink/renderer/bindings/generated_in_modules.gni @@ -2797,6 +2797,8 @@ if (is_cobalt) { "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_crash_annotator.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_h_5_vcc.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_h_5_vcc.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_h_5_vcc_system.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_h_5_vcc_system.h", ] } diff --git a/third_party/blink/renderer/bindings/idl_in_modules.gni b/third_party/blink/renderer/bindings/idl_in_modules.gni index a9653c43645..32d5c937c96 100644 --- a/third_party/blink/renderer/bindings/idl_in_modules.gni +++ b/third_party/blink/renderer/bindings/idl_in_modules.gni @@ -1212,6 +1212,7 @@ if (is_cobalt) { "//third_party/blink/renderer/modules/cobalt/crash_annotator/crash_annotator.idl", "//third_party/blink/renderer/modules/cobalt/h_5_vcc.idl", "//third_party/blink/renderer/modules/cobalt/window_h_5_vcc.idl", + "//third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.idl", ], "abspath") } diff --git a/third_party/blink/renderer/modules/BUILD.gn b/third_party/blink/renderer/modules/BUILD.gn index b1989956316..d8bd3ee36bb 100644 --- a/third_party/blink/renderer/modules/BUILD.gn +++ b/third_party/blink/renderer/modules/BUILD.gn @@ -171,6 +171,7 @@ component("modules") { sub_modules += [ "//third_party/blink/renderer/modules/cobalt:h_5_vcc", "//third_party/blink/renderer/modules/cobalt/crash_annotator", + "//third_party/blink/renderer/modules/cobalt/h5vcc_system", ] } diff --git a/third_party/blink/renderer/modules/cobalt/BUILD.gn b/third_party/blink/renderer/modules/cobalt/BUILD.gn index 7441313f2f2..2972145f424 100644 --- a/third_party/blink/renderer/modules/cobalt/BUILD.gn +++ b/third_party/blink/renderer/modules/cobalt/BUILD.gn @@ -19,5 +19,8 @@ blink_modules_sources("h_5_vcc") { "h_5_vcc.cc", "h_5_vcc.h", ] - deps = ["//third_party/blink/renderer/modules/cobalt/crash_annotator"] + deps = [ + "//third_party/blink/renderer/modules/cobalt/crash_annotator", + "//third_party/blink/renderer/modules/cobalt/h5vcc_system", + ] } diff --git a/third_party/blink/renderer/modules/cobalt/h5vcc_system/BUILD.gn b/third_party/blink/renderer/modules/cobalt/h5vcc_system/BUILD.gn new file mode 100644 index 00000000000..f58c8a5b87b --- /dev/null +++ b/third_party/blink/renderer/modules/cobalt/h5vcc_system/BUILD.gn @@ -0,0 +1,7 @@ +import("//third_party/blink/renderer/modules/modules.gni") +blink_modules_sources("h5vcc_system") { + sources = [ + "h_5_vcc_system.cc", + "h_5_vcc_system.h", + ] +} \ No newline at end of file diff --git a/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.cc b/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.cc new file mode 100644 index 00000000000..391e3b36dd1 --- /dev/null +++ b/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.cc @@ -0,0 +1,57 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h" + +#include "mojo/public/cpp/bindings/pending_receiver.h" +#include "mojo/public/cpp/bindings/remote.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/core/execution_context/execution_context.h" +#include "third_party/blink/renderer/core/frame/local_dom_window.h" +#include "third_party/blink/renderer/platform/bindings/exception_state.h" +#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" + +namespace blink { + +// static +const char H5vccSystem::kSupplementName[] = "H5vccSystem"; + +//static +H5vccSystem* H5vccSystem::h5vccSystem(LocalDOMWindow& window) { + H5vccSystem* h5vccSystem = Supplement::From(window); + if (!h5vccSystem && window.GetExecutionContext()) { + h5vccSystem = MakeGarbageCollected(window); + } + return h5vccSystem; +} + +H5vccSystem::H5vccSystem(LocalDOMWindow& window) + : Supplement(window), + ExecutionContextLifecycleObserver(window.GetExecutionContext()) {} + +void H5vccSystem::ContextDestroyed() {} + +const String H5vccSystem::advertisingId() const { + // TODO populate the value here. +// return advertising_id_; + return String("fake advertisingId"); +} + +void H5vccSystem::Trace(Visitor* visitor) const { + ExecutionContextLifecycleObserver::Trace(visitor); + ScriptWrappable::Trace(visitor); +} + +} // namespace blink diff --git a/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h b/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h new file mode 100644 index 00000000000..71050df1024 --- /dev/null +++ b/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h @@ -0,0 +1,61 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_H_5_VCC_SYSTEM_H_ +#define THIRD_PARTY_BLINK_RENDERER_MODULES_H_5_VCC_SYSTEM_H_ + +#include "third_party/blink/renderer/bindings/core/v8/script_promise.h" +#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h" +#include "third_party/blink/renderer/modules/modules_export.h" +#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" +#include "third_party/blink/renderer/platform/mojo/heap_mojo_receiver.h" +#include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h" +#include "third_party/blink/renderer/platform/mojo/heap_mojo_wrapper_mode.h" +#include "third_party/blink/renderer/platform/supplementable.h" + +namespace blink { + +class ExecutionContext; +class LocalDOMWindow; +class ScriptPromiseResolver; +class ScriptState; + +class MODULES_EXPORT H5vccSystem final + : public ScriptWrappable, + public Supplement, + public ExecutionContextLifecycleObserver { + DEFINE_WRAPPERTYPEINFO(); + + public: + static const char kSupplementName[]; + + // For window.h5vccSystem + static H5vccSystem* h5vccSystem(LocalDOMWindow&); + + explicit H5vccSystem(LocalDOMWindow&); + + void ContextDestroyed() override; + + // Web-exposed interface: + const String advertisingId() const; + + void Trace(Visitor*) const override; + + private: + String advertising_id_; +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_H_5_VCC_SYSTEM_H_ diff --git a/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.idl b/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.idl new file mode 100644 index 00000000000..4b6f7862cce --- /dev/null +++ b/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.idl @@ -0,0 +1,21 @@ +// Copyright 2025 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +[ + Exposed=Window, + SecureContext +] +interface H5vccSystem { + readonly attribute DOMString advertisingId; +}; diff --git a/third_party/blink/renderer/modules/cobalt/h_5_vcc.cc b/third_party/blink/renderer/modules/cobalt/h_5_vcc.cc index bd21a25dfcd..a085acb2787 100644 --- a/third_party/blink/renderer/modules/cobalt/h_5_vcc.cc +++ b/third_party/blink/renderer/modules/cobalt/h_5_vcc.cc @@ -16,6 +16,7 @@ #include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/modules/cobalt/crash_annotator/crash_annotator.h" +#include "third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h" namespace blink { @@ -34,10 +35,12 @@ H5vcc* H5vcc::h5vcc(LocalDOMWindow& window) { H5vcc::H5vcc(LocalDOMWindow& window) : Supplement(window), - crash_annotator_(MakeGarbageCollected(window)) {} + crash_annotator_(MakeGarbageCollected(window)), + h5vcc_system_(MakeGarbageCollected(window)) {} void H5vcc::Trace(Visitor* visitor) const { visitor->Trace(crash_annotator_); + visitor->Trace(h5vcc_system_); Supplement::Trace(visitor); ScriptWrappable::Trace(visitor); } diff --git a/third_party/blink/renderer/modules/cobalt/h_5_vcc.h b/third_party/blink/renderer/modules/cobalt/h_5_vcc.h index 6bebc73af1e..2773ac572f2 100644 --- a/third_party/blink/renderer/modules/cobalt/h_5_vcc.h +++ b/third_party/blink/renderer/modules/cobalt/h_5_vcc.h @@ -27,6 +27,7 @@ namespace blink { class ScriptState; class CrashAnnotator; class LocalDOMWindow; +class H5vccSystem; class MODULES_EXPORT H5vcc final : public ScriptWrappable, @@ -43,10 +44,13 @@ class MODULES_EXPORT H5vcc final CrashAnnotator* crashAnnotator() { return crash_annotator_; } + H5vccSystem* h5vccSystem() { return h5vcc_system_; } + void Trace(Visitor*) const override; private: Member crash_annotator_; + Member h5vcc_system_; }; } diff --git a/third_party/blink/renderer/modules/cobalt/h_5_vcc.idl b/third_party/blink/renderer/modules/cobalt/h_5_vcc.idl index fa8677effd1..7bd381ad0c4 100644 --- a/third_party/blink/renderer/modules/cobalt/h_5_vcc.idl +++ b/third_party/blink/renderer/modules/cobalt/h_5_vcc.idl @@ -18,4 +18,5 @@ ] interface H5vcc { readonly attribute CrashAnnotator crashAnnotator; + readonly attribute H5vccSystem h5vccSystem; }; From d5135b76511dce4ea69b0ced14dc980b2a5c0d16 Mon Sep 17 00:00:00 2001 From: Colin Liang Date: Mon, 27 Jan 2025 10:22:48 -0800 Subject: [PATCH 2/3] Fix comments. --- .pre-commit-config.yaml | 1 + .../bindings/generated_in_modules.gni | 4 +- .../renderer/bindings/idl_in_modules.gni | 2 +- third_party/blink/renderer/modules/BUILD.gn | 2 +- .../blink/renderer/modules/cobalt/BUILD.gn | 2 +- .../modules/cobalt/cobalt_system/BUILD.gn | 21 +++++++ .../cobalt/cobalt_system/cobalt_system.cc | 35 +++++++++++ .../cobalt/cobalt_system/cobalt_system.h | 41 +++++++++++++ .../cobalt_system.idl} | 4 +- .../modules/cobalt/h5vcc_system/BUILD.gn | 7 --- .../cobalt/h5vcc_system/h_5_vcc_system.cc | 57 ----------------- .../cobalt/h5vcc_system/h_5_vcc_system.h | 61 ------------------- .../blink/renderer/modules/cobalt/h_5_vcc.cc | 8 +-- .../blink/renderer/modules/cobalt/h_5_vcc.h | 13 ++-- .../blink/renderer/modules/cobalt/h_5_vcc.idl | 4 +- 15 files changed, 119 insertions(+), 143 deletions(-) create mode 100644 third_party/blink/renderer/modules/cobalt/cobalt_system/BUILD.gn create mode 100644 third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.cc create mode 100644 third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.h rename third_party/blink/renderer/modules/cobalt/{h5vcc_system/h_5_vcc_system.idl => cobalt_system/cobalt_system.idl} (79%) delete mode 100644 third_party/blink/renderer/modules/cobalt/h5vcc_system/BUILD.gn delete mode 100644 third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.cc delete mode 100644 third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e527a330601..e1b3296c4e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,7 @@ files: | media/base/starboard/| media/starboard/| starboard/| + third_party/blink/renderer/modules/cobalt/| components/viz/service/display/starboard/| ui/ozone/platform/starboard/| .pre-commit-config.yaml| diff --git a/third_party/blink/renderer/bindings/generated_in_modules.gni b/third_party/blink/renderer/bindings/generated_in_modules.gni index 2104bfb492e..7c4a4b90cba 100644 --- a/third_party/blink/renderer/bindings/generated_in_modules.gni +++ b/third_party/blink/renderer/bindings/generated_in_modules.gni @@ -2797,8 +2797,8 @@ if (is_cobalt) { "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_crash_annotator.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_h_5_vcc.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_h_5_vcc.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_h_5_vcc_system.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_h_5_vcc_system.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_cobalt_system.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_cobalt_system.h", ] } diff --git a/third_party/blink/renderer/bindings/idl_in_modules.gni b/third_party/blink/renderer/bindings/idl_in_modules.gni index 32d5c937c96..646e011cb4a 100644 --- a/third_party/blink/renderer/bindings/idl_in_modules.gni +++ b/third_party/blink/renderer/bindings/idl_in_modules.gni @@ -1212,7 +1212,7 @@ if (is_cobalt) { "//third_party/blink/renderer/modules/cobalt/crash_annotator/crash_annotator.idl", "//third_party/blink/renderer/modules/cobalt/h_5_vcc.idl", "//third_party/blink/renderer/modules/cobalt/window_h_5_vcc.idl", - "//third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.idl", + "//third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.idl", ], "abspath") } diff --git a/third_party/blink/renderer/modules/BUILD.gn b/third_party/blink/renderer/modules/BUILD.gn index d8bd3ee36bb..8ad56309172 100644 --- a/third_party/blink/renderer/modules/BUILD.gn +++ b/third_party/blink/renderer/modules/BUILD.gn @@ -171,7 +171,7 @@ component("modules") { sub_modules += [ "//third_party/blink/renderer/modules/cobalt:h_5_vcc", "//third_party/blink/renderer/modules/cobalt/crash_annotator", - "//third_party/blink/renderer/modules/cobalt/h5vcc_system", + "//third_party/blink/renderer/modules/cobalt/cobalt_system", ] } diff --git a/third_party/blink/renderer/modules/cobalt/BUILD.gn b/third_party/blink/renderer/modules/cobalt/BUILD.gn index 2972145f424..f71b2c6a1cc 100644 --- a/third_party/blink/renderer/modules/cobalt/BUILD.gn +++ b/third_party/blink/renderer/modules/cobalt/BUILD.gn @@ -20,7 +20,7 @@ blink_modules_sources("h_5_vcc") { "h_5_vcc.h", ] deps = [ + "//third_party/blink/renderer/modules/cobalt/cobalt_system", "//third_party/blink/renderer/modules/cobalt/crash_annotator", - "//third_party/blink/renderer/modules/cobalt/h5vcc_system", ] } diff --git a/third_party/blink/renderer/modules/cobalt/cobalt_system/BUILD.gn b/third_party/blink/renderer/modules/cobalt/cobalt_system/BUILD.gn new file mode 100644 index 00000000000..35f5ac982a2 --- /dev/null +++ b/third_party/blink/renderer/modules/cobalt/cobalt_system/BUILD.gn @@ -0,0 +1,21 @@ +# Copyright 2025 The Cobalt Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//third_party/blink/renderer/modules/modules.gni") +blink_modules_sources("cobalt_system") { + sources = [ + "cobalt_system.cc", + "cobalt_system.h", + ] +} diff --git a/third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.cc b/third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.cc new file mode 100644 index 00000000000..04f040d47d1 --- /dev/null +++ b/third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.cc @@ -0,0 +1,35 @@ +// Copyright 2025 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.h" + +#include "third_party/blink/renderer/core/frame/local_dom_window.h" + +namespace blink { + +CobaltSystem::CobaltSystem(LocalDOMWindow& window) {} + +const String CobaltSystem::advertisingId() const { + NOTIMPLEMENTED(); + + // TODO add a mojom service and populate the value for advertising_id_. + // return advertising_id_; + return String("fake advertisingId"); +} + +void CobaltSystem::Trace(Visitor* visitor) const { + ScriptWrappable::Trace(visitor); +} + +} // namespace blink diff --git a/third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.h b/third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.h new file mode 100644 index 00000000000..6b524e2bd95 --- /dev/null +++ b/third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.h @@ -0,0 +1,41 @@ +// Copyright 2025 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_COBALT_SYSTEM_H_ +#define THIRD_PARTY_BLINK_RENDERER_MODULES_COBALT_SYSTEM_H_ + +#include "third_party/blink/renderer/modules/modules_export.h" +#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" +#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" + +namespace blink { + +class LocalDOMWindow; +class ScriptState; + +class MODULES_EXPORT CobaltSystem final : public ScriptWrappable { + DEFINE_WRAPPERTYPEINFO(); + + public: + explicit CobaltSystem(LocalDOMWindow&); + + // Web-exposed interface: + const String advertisingId() const; + + void Trace(Visitor*) const override; +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_COBALT_SYSTEM_H_ diff --git a/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.idl b/third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.idl similarity index 79% rename from third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.idl rename to third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.idl index 4b6f7862cce..43e32d8f840 100644 --- a/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.idl +++ b/third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.idl @@ -12,10 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +// This interface mirrors the H5vccSystem Web IDL defined in Cobalt LTS 25: +// https://github.com/youtube/cobalt/blob/25.lts.stable/cobalt/h5vcc/h5vcc_system.idl [ Exposed=Window, SecureContext ] -interface H5vccSystem { +interface CobaltSystem { readonly attribute DOMString advertisingId; }; diff --git a/third_party/blink/renderer/modules/cobalt/h5vcc_system/BUILD.gn b/third_party/blink/renderer/modules/cobalt/h5vcc_system/BUILD.gn deleted file mode 100644 index f58c8a5b87b..00000000000 --- a/third_party/blink/renderer/modules/cobalt/h5vcc_system/BUILD.gn +++ /dev/null @@ -1,7 +0,0 @@ -import("//third_party/blink/renderer/modules/modules.gni") -blink_modules_sources("h5vcc_system") { - sources = [ - "h_5_vcc_system.cc", - "h_5_vcc_system.h", - ] -} \ No newline at end of file diff --git a/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.cc b/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.cc deleted file mode 100644 index 391e3b36dd1..00000000000 --- a/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.cc +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h" - -#include "mojo/public/cpp/bindings/pending_receiver.h" -#include "mojo/public/cpp/bindings/remote.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/core/execution_context/execution_context.h" -#include "third_party/blink/renderer/core/frame/local_dom_window.h" -#include "third_party/blink/renderer/platform/bindings/exception_state.h" -#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" - -namespace blink { - -// static -const char H5vccSystem::kSupplementName[] = "H5vccSystem"; - -//static -H5vccSystem* H5vccSystem::h5vccSystem(LocalDOMWindow& window) { - H5vccSystem* h5vccSystem = Supplement::From(window); - if (!h5vccSystem && window.GetExecutionContext()) { - h5vccSystem = MakeGarbageCollected(window); - } - return h5vccSystem; -} - -H5vccSystem::H5vccSystem(LocalDOMWindow& window) - : Supplement(window), - ExecutionContextLifecycleObserver(window.GetExecutionContext()) {} - -void H5vccSystem::ContextDestroyed() {} - -const String H5vccSystem::advertisingId() const { - // TODO populate the value here. -// return advertising_id_; - return String("fake advertisingId"); -} - -void H5vccSystem::Trace(Visitor* visitor) const { - ExecutionContextLifecycleObserver::Trace(visitor); - ScriptWrappable::Trace(visitor); -} - -} // namespace blink diff --git a/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h b/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h deleted file mode 100644 index 71050df1024..00000000000 --- a/third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_H_5_VCC_SYSTEM_H_ -#define THIRD_PARTY_BLINK_RENDERER_MODULES_H_5_VCC_SYSTEM_H_ - -#include "third_party/blink/renderer/bindings/core/v8/script_promise.h" -#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h" -#include "third_party/blink/renderer/modules/modules_export.h" -#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" -#include "third_party/blink/renderer/platform/mojo/heap_mojo_receiver.h" -#include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h" -#include "third_party/blink/renderer/platform/mojo/heap_mojo_wrapper_mode.h" -#include "third_party/blink/renderer/platform/supplementable.h" - -namespace blink { - -class ExecutionContext; -class LocalDOMWindow; -class ScriptPromiseResolver; -class ScriptState; - -class MODULES_EXPORT H5vccSystem final - : public ScriptWrappable, - public Supplement, - public ExecutionContextLifecycleObserver { - DEFINE_WRAPPERTYPEINFO(); - - public: - static const char kSupplementName[]; - - // For window.h5vccSystem - static H5vccSystem* h5vccSystem(LocalDOMWindow&); - - explicit H5vccSystem(LocalDOMWindow&); - - void ContextDestroyed() override; - - // Web-exposed interface: - const String advertisingId() const; - - void Trace(Visitor*) const override; - - private: - String advertising_id_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_H_5_VCC_SYSTEM_H_ diff --git a/third_party/blink/renderer/modules/cobalt/h_5_vcc.cc b/third_party/blink/renderer/modules/cobalt/h_5_vcc.cc index a085acb2787..1c78ca50fe1 100644 --- a/third_party/blink/renderer/modules/cobalt/h_5_vcc.cc +++ b/third_party/blink/renderer/modules/cobalt/h_5_vcc.cc @@ -15,15 +15,15 @@ #include "third_party/blink/renderer/modules/cobalt/h_5_vcc.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h" +#include "third_party/blink/renderer/modules/cobalt/cobalt_system/cobalt_system.h" #include "third_party/blink/renderer/modules/cobalt/crash_annotator/crash_annotator.h" -#include "third_party/blink/renderer/modules/cobalt/h5vcc_system/h_5_vcc_system.h" namespace blink { // static const char H5vcc::kSupplementName[] = "H5vcc"; -//static +// static H5vcc* H5vcc::h5vcc(LocalDOMWindow& window) { H5vcc* h5vcc = Supplement::From(window); if (!h5vcc && window.GetExecutionContext()) { @@ -36,11 +36,11 @@ H5vcc* H5vcc::h5vcc(LocalDOMWindow& window) { H5vcc::H5vcc(LocalDOMWindow& window) : Supplement(window), crash_annotator_(MakeGarbageCollected(window)), - h5vcc_system_(MakeGarbageCollected(window)) {} + cobalt_system_(MakeGarbageCollected(window)) {} void H5vcc::Trace(Visitor* visitor) const { visitor->Trace(crash_annotator_); - visitor->Trace(h5vcc_system_); + visitor->Trace(cobalt_system_); Supplement::Trace(visitor); ScriptWrappable::Trace(visitor); } diff --git a/third_party/blink/renderer/modules/cobalt/h_5_vcc.h b/third_party/blink/renderer/modules/cobalt/h_5_vcc.h index 2773ac572f2..2b86f23f973 100644 --- a/third_party/blink/renderer/modules/cobalt/h_5_vcc.h +++ b/third_party/blink/renderer/modules/cobalt/h_5_vcc.h @@ -27,11 +27,10 @@ namespace blink { class ScriptState; class CrashAnnotator; class LocalDOMWindow; -class H5vccSystem; +class CobaltSystem; -class MODULES_EXPORT H5vcc final - : public ScriptWrappable, - public Supplement { +class MODULES_EXPORT H5vcc final : public ScriptWrappable, + public Supplement { DEFINE_WRAPPERTYPEINFO(); public: @@ -44,15 +43,15 @@ class MODULES_EXPORT H5vcc final CrashAnnotator* crashAnnotator() { return crash_annotator_; } - H5vccSystem* h5vccSystem() { return h5vcc_system_; } + CobaltSystem* cobaltSystem() { return cobalt_system_; } void Trace(Visitor*) const override; private: Member crash_annotator_; - Member h5vcc_system_; + Member cobalt_system_; }; -} +} // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_COBALT_H_5_VCC_H_ diff --git a/third_party/blink/renderer/modules/cobalt/h_5_vcc.idl b/third_party/blink/renderer/modules/cobalt/h_5_vcc.idl index 7bd381ad0c4..63c426cc90d 100644 --- a/third_party/blink/renderer/modules/cobalt/h_5_vcc.idl +++ b/third_party/blink/renderer/modules/cobalt/h_5_vcc.idl @@ -12,11 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +// This interface mirrors the H5vcc Web IDL defined in Cobalt LTS 25: +// https://github.com/youtube/cobalt/blob/25.lts.stable/cobalt/h5vcc/h5vcc.idl [ Exposed=Window, SecureContext ] interface H5vcc { readonly attribute CrashAnnotator crashAnnotator; - readonly attribute H5vccSystem h5vccSystem; + readonly attribute CobaltSystem cobaltSystem; }; From eebd648619ac222f3f32e0200ce52bcbf2c9f64b Mon Sep 17 00:00:00 2001 From: Colin Liang Date: Mon, 27 Jan 2025 11:17:25 -0800 Subject: [PATCH 3/3] Add web_tests for CobaltSystem WEB IDL. --- .../cobalt-system/cobalt-system.https.sub.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 third_party/blink/web_tests/external/wpt/cobalt/cobalt-system/cobalt-system.https.sub.html diff --git a/third_party/blink/web_tests/external/wpt/cobalt/cobalt-system/cobalt-system.https.sub.html b/third_party/blink/web_tests/external/wpt/cobalt/cobalt-system/cobalt-system.https.sub.html new file mode 100644 index 00000000000..ffc79008e24 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/cobalt/cobalt-system/cobalt-system.https.sub.html @@ -0,0 +1,15 @@ + + + + Test CobaltSystem web API. + + + + + + + \ No newline at end of file