|
| 1 | +// Copyright 2025 The Cobalt Authors. All Rights Reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#include "cobalt/browser/h5vcc_system/h5vcc_system_impl.h" |
| 16 | +#include "base/functional/bind.h" |
| 17 | +#include "base/functional/callback.h" |
| 18 | + |
| 19 | +#if BUILDFLAG(IS_ANDROID) |
| 20 | +#include "starboard/android/shared/starboard_bridge.h" |
| 21 | + |
| 22 | +using starboard::android::shared::StarboardBridge; |
| 23 | +#endif |
| 24 | + |
| 25 | +namespace h5vcc_system { |
| 26 | + |
| 27 | +// TODO (b/395126160): refactor mojom implementation on Android |
| 28 | +H5vccSystemImpl::H5vccSystemImpl( |
| 29 | + content::RenderFrameHost& render_frame_host, |
| 30 | + mojo::PendingReceiver<mojom::H5vccSystem> receiver) |
| 31 | + : content::DocumentService<mojom::H5vccSystem>(render_frame_host, |
| 32 | + std::move(receiver)) {} |
| 33 | + |
| 34 | +void H5vccSystemImpl::Create( |
| 35 | + content::RenderFrameHost* render_frame_host, |
| 36 | + mojo::PendingReceiver<mojom::H5vccSystem> receiver) { |
| 37 | + new H5vccSystemImpl(*render_frame_host, std::move(receiver)); |
| 38 | +} |
| 39 | + |
| 40 | +void H5vccSystemImpl::GetAdvertisingId(GetAdvertisingIdCallback callback) { |
| 41 | + std::string advertising_id; |
| 42 | +#if BUILDFLAG(IS_ANDROID) |
| 43 | + JNIEnv* env = base::android::AttachCurrentThread(); |
| 44 | + StarboardBridge* starbooard_bridge = StarboardBridge::GetInstance(); |
| 45 | + advertising_id = starbooard_bridge->GetAdvertisingId(env); |
| 46 | +#endif |
| 47 | + std::move(callback).Run(advertising_id); |
| 48 | +} |
| 49 | + |
| 50 | +} // namespace h5vcc_system |
0 commit comments