-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing Asynchronous Advertising ID Retrieval for H5vccSystem (#…
…4794) 1. A new mojom interface for H5vccSystem is created, including an asynchronous API method to retrieve the advertising ID. 2. The mojom server implementation handles the request by calling JNI (Java Native Interface) functions. These JNI calls will interact with the StarboardBridge to fetch the actual advertising ID value. 3. The renderer client then utilizes the mojom interface to call the asynchronous method and retrieve the advertising ID. Tested on devtools, https://screenshot.googleplex.com/43HotkbLgJSQdx3 4. Added web_tests for the mojom interface. // Compile the web_test cobalt/build/gn.py -p linux-x64x11 -C devel && autoninja -C out/linux-x64x11_devel blink_wpt_tests && autoninja -C out/linux-x64x11_devel dump_syms && autoninja -C out/linux-x64x11_devel minidump_stackwalk && autoninja -C out/linux-x64x11_devel cobalt/browser/h5vcc_system/public/mojom:mojom_js // run the web_test third_party/blink/tools/run_web_tests.py -t linux-x64x11_devel wpt_internal/h5vcc/h5vcc-system b/377049113 --------- Co-authored-by: Colin Liang <[email protected]>
- Loading branch information
1 parent
affaaa6
commit 7bbf2ef
Showing
19 changed files
with
341 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# 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. | ||
|
||
source_set("h5vcc_system") { | ||
sources = [ | ||
"h5vcc_system_impl.cc", | ||
"h5vcc_system_impl.h", | ||
] | ||
|
||
deps = [ | ||
"//base", | ||
"//cobalt/browser/h5vcc_system/public/mojom", | ||
"//content/public/browser", | ||
"//mojo/public/cpp/bindings", | ||
] | ||
|
||
# TODO (b/395154617) clean up | ||
if (is_android) { | ||
deps += [ "//starboard/android/shared:starboard_platform" ] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// 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 "cobalt/browser/h5vcc_system/h5vcc_system_impl.h" | ||
#include "base/functional/bind.h" | ||
#include "base/functional/callback.h" | ||
|
||
#if BUILDFLAG(IS_ANDROID) | ||
#include "starboard/android/shared/starboard_bridge.h" | ||
|
||
using starboard::android::shared::StarboardBridge; | ||
#endif | ||
|
||
namespace h5vcc_system { | ||
|
||
// TODO (b/395126160): refactor mojom implementation on Android | ||
H5vccSystemImpl::H5vccSystemImpl( | ||
content::RenderFrameHost& render_frame_host, | ||
mojo::PendingReceiver<mojom::H5vccSystem> receiver) | ||
: content::DocumentService<mojom::H5vccSystem>(render_frame_host, | ||
std::move(receiver)) {} | ||
|
||
void H5vccSystemImpl::Create( | ||
content::RenderFrameHost* render_frame_host, | ||
mojo::PendingReceiver<mojom::H5vccSystem> receiver) { | ||
new H5vccSystemImpl(*render_frame_host, std::move(receiver)); | ||
} | ||
|
||
void H5vccSystemImpl::GetAdvertisingId(GetAdvertisingIdCallback callback) { | ||
std::string advertising_id; | ||
#if BUILDFLAG(IS_ANDROID) | ||
JNIEnv* env = base::android::AttachCurrentThread(); | ||
StarboardBridge* starbooard_bridge = StarboardBridge::GetInstance(); | ||
advertising_id = starbooard_bridge->GetAdvertisingId(env); | ||
#endif | ||
std::move(callback).Run(advertising_id); | ||
} | ||
|
||
} // namespace h5vcc_system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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 COBALT_BROWSER_H5VCC_SYSTEM_H5VCC_SYSTEM_IMPL_H_ | ||
#define COBALT_BROWSER_H5VCC_SYSTEM_H5VCC_SYSTEM_IMPL_H_ | ||
|
||
#include <string> | ||
|
||
#include "cobalt/browser/h5vcc_system/public/mojom/h5vcc_system.mojom.h" | ||
#include "content/public/browser/document_service.h" | ||
#include "mojo/public/cpp/bindings/pending_receiver.h" | ||
|
||
namespace content { | ||
class RenderFrameHost; | ||
} // namespace content | ||
|
||
namespace h5vcc_system { | ||
|
||
// Implements the H5vccSystem Mojo interface and extends | ||
// DocumentService so that an object's lifetime is scoped to the corresponding | ||
// document / RenderFrameHost (see DocumentService for details). | ||
class H5vccSystemImpl : public content::DocumentService<mojom::H5vccSystem> { | ||
public: | ||
// Creates a H5vccSystemImpl. The H5vccSystemImpl is bound to the | ||
// receiver and its lifetime is scoped to the render_frame_host. | ||
static void Create(content::RenderFrameHost* render_frame_host, | ||
mojo::PendingReceiver<mojom::H5vccSystem> receiver); | ||
|
||
H5vccSystemImpl(const H5vccSystemImpl&) = delete; | ||
H5vccSystemImpl& operator=(const H5vccSystemImpl&) = delete; | ||
|
||
void GetAdvertisingId(GetAdvertisingIdCallback) override; | ||
|
||
private: | ||
H5vccSystemImpl(content::RenderFrameHost& render_frame_host, | ||
mojo::PendingReceiver<mojom::H5vccSystem> receiver); | ||
}; | ||
|
||
} // namespace h5vcc_system | ||
|
||
#endif // COBALT_BROWSER_H5VCC_SYSTEM_H5VCC_SYSTEM_IMPL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# 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("//mojo/public/tools/bindings/mojom.gni") | ||
|
||
mojom("mojom") { | ||
sources = [ "h5vcc_system.mojom" ] | ||
} |
22 changes: 22 additions & 0 deletions
22
cobalt/browser/h5vcc_system/public/mojom/h5vcc_system.mojom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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. | ||
|
||
module h5vcc_system.mojom; | ||
|
||
// The browser process must provide an implementation of this interface so that | ||
// the renderer process can implement the H5vccSystem Blink API. | ||
interface H5vccSystem { | ||
// Get the GetAdvertisingId for the device. | ||
GetAdvertisingId() => (string advertising_id); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
third_party/blink/web_tests/external/wpt/cobalt/h5vcc-system/h5vcc-system.https.sub.html
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.