Skip to content

Commit

Permalink
Add browser_proxy.js as the bridge to implement echeapi.d.ts
Browse files Browse the repository at this point in the history
Bug: b/178379656
Change-Id: I819b18bca7df55691fdd57ecaee94f5ebaf69617
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2717248
Reviewed-by: Daniel Nishi <dhnishi@chromium.org>
Commit-Queue: Guanru Lee <guanrulee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#858426}
  • Loading branch information
Guanru Lee authored and Chromium LUCI CQ committed Feb 28, 2021
1 parent 4f81039 commit d2144eb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
9 changes: 5 additions & 4 deletions chromeos/components/eche_app_ui/BUILD.gn
Expand Up @@ -39,7 +39,10 @@ js_type_check("closure_compile") {
}

js_library("app") {
sources = [ "resources/prod/js/app_bundle.js" ]
sources = [
"resources/browser_proxy.js",
"resources/prod/js/app_bundle.js",
]
}

js2gtest("browser_tests_js") {
Expand All @@ -50,11 +53,9 @@ js2gtest("browser_tests_js") {
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
}

# TODO(b/176936453): add js files for mojo API and remove
# the dummy icon once adding in the real resources.
generate_grd("build_grd") {
input_files_base_dir = rebase_path("resources", "//")
input_files = [ "eche_icon_256.png" ]
input_files = [ "browser_proxy.js" ]
manifest_files = []
grd_prefix = "chromeos_eche_app"
out_grd = "$target_gen_dir/${grd_prefix}_resources.grd"
Expand Down
3 changes: 3 additions & 0 deletions chromeos/components/eche_app_ui/eche_app_ui.cc
Expand Up @@ -7,6 +7,7 @@
#include <memory>

#include "chromeos/components/eche_app_ui/url_constants.h"
#include "chromeos/grit/chromeos_eche_app_resources.h"
#include "chromeos/grit/chromeos_eche_bundle_resources.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
Expand All @@ -28,6 +29,8 @@ EcheAppUI::EcheAppUI(content::WebUI* web_ui) : ui::MojoWebUIController(web_ui) {
IDR_CHROMEOS_ECHE_APP_BUNDLE_JS);
html_source->AddResourcePath("assets/app_bundle.css",
IDR_CHROMEOS_ECHE_APP_BUNDLE_CSS);
html_source->AddResourcePath("browser_proxy.js",
IDR_CHROMEOS_ECHE_APP_BROWSER_PROXY_JS);

// DisableTrustedTypesCSP to support TrustedTypePolicy named 'goog#html'.
// It is the Closure templating system that renders our UI, as it does many
Expand Down
23 changes: 23 additions & 0 deletions chromeos/components/eche_app_ui/resources/browser_proxy.js
@@ -0,0 +1,23 @@
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// The implementation of echeapi.d.ts
const EcheApiBindingImpl = new class {
onWebRtcSignalReceived(callback) {
// TODO(b/178379656): hook the callback to mojo interface.
}

sendWebRtcSignal(signaling) {
// TODO(b/178379656): hook the sending function to mojo interface.
}
};

// Declare module echeapi and bind the implementation to echeapi.d.ts
const echeapi = {};
echeapi.webrtc = {};
echeapi.webrtc.sendSignal =
EcheApiBindingImpl.sendWebRtcSignal.bind(EcheApiBindingImpl);
echeapi.webrtc.registerSignalReceiver =
EcheApiBindingImpl.onWebRtcSignalReceived.bind(EcheApiBindingImpl);
window['echeapi'] = echeapi;
Binary file not shown.

0 comments on commit d2144eb

Please sign in to comment.