Commit 233e2581 authored by Shakti Sahu's avatar Shakti Sahu Committed by Commit Bot

Video Player: Set up untrusted data source for serving HTML/JS

This CL sets up the video player HTML/JS files to be served locally
through chrome-untrusted:// scheme. It currently uses a WebUIDataSource
and will be moved to an untrusted WebUIController factory once it is
ready.

Bug: 1129715
Change-Id: I1d514c5f316a462547ef6e1dff78cfecbf143fdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414787
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809209}
parent 4664e902
......@@ -112,6 +112,9 @@
<include name="IDR_OFFLINE_INTERNALS_CSS" file="resources\offline_pages\offline_internals.css" type="BINDATA" />
<include name="IDR_OFFLINE_INTERNALS_JS" file="resources\offline_pages\offline_internals.js" type="BINDATA" />
<include name="IDR_OFFLINE_INTERNALS_BROWSER_PROXY_JS" file="resources\offline_pages\offline_internals_browser_proxy.js" type="BINDATA" />
<include name="IDR_VIDEO_PLAYER_HTML" file="resources\video_tutorials\video_player.html" type="BINDATA" />
<include name="IDR_VIDEO_PLAYER_CSS" file="resources\video_tutorials\video_player.css" type="BINDATA" />
<include name="IDR_VIDEO_PLAYER_JS" file="resources\video_tutorials\video_player.js" type="BINDATA" />
</if>
<if expr="not is_android">
......
......@@ -88,6 +88,7 @@ if (enable_js_type_check) {
"internals/query_tiles:closure_compile",
"offline_pages:closure_compile",
"snippets_internals:closure_compile",
"video_tutorials:closure_compile",
"webapks:closure_compile",
]
}
......
# Copyright 2020 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.
import("//third_party/closure_compiler/compile_js.gni")
js_type_check("closure_compile") {
uses_js_modules = true
deps = [ ":video_player" ]
}
js_library("video_player") {
deps = [ "//ui/webui/resources/js:util.m" ]
}
file://chrome/browser/video_tutorials/OWNERS
# TEAM: chrome-upboarding-eng@google.com
# COMPONENT: Upboarding>VideoTutorials
/* Copyright 2020 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. */
html,
body {
background-color: black;
height: 100%;
margin: 0;
}
video {
height: 100%;
width: 100%;
}
.video-ended {
height: 50%;
left: 25%;
position: absolute;
top: 15%;
width: 50%;
}
video::-webkit-media-controls-fullscreen-button {
display: none !important;
}
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control"
content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<link rel="stylesheet" href="video_player.css">
<script type="module" src="video_player.js"></script>
</head>
<body>
<video id="video" preload="metadata" controls disablePictureInPicture
controlsList="nodownload nofullscreen noremoteplayback">
<source type="video/mp4"></source>
<track id="track" label="English" kind="captions" srclang="en-us"
mode="showing" default >
</video>
</body>
</html>
// Copyright 2020 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.
import {$} from 'chrome://resources/js/util.m.js';
function onDocumentLoaded() {
// Find out the video, image, and caption urls from the url params.
const urlParams = new URLSearchParams(window.location.search);
video.src = urlParams.get('video_url');
video.poster = urlParams.get('poster_url');
track.src = urlParams.get('caption_url');
video.play();
}
function onVideoEnded() {
// Resize the poster.
video.style.classList.add('video-ended');
video.controls = false;
}
const video = $('video');
const track = $('track');
video.addEventListener('ended', onVideoEnded);
document.addEventListener('DOMContentLoaded', onDocumentLoaded);
......@@ -785,6 +785,8 @@ static_library("ui") {
"webui/snippets_internals/snippets_internals_page_handler.h",
"webui/snippets_internals/snippets_internals_ui.cc",
"webui/snippets_internals/snippets_internals_ui.h",
"webui/video_tutorials/video_player_source.cc",
"webui/video_tutorials/video_player_source.h",
"webui/webapks_handler.cc",
"webui/webapks_handler.h",
"webui/webapks_ui.cc",
......
file://chrome/browser/video_tutorials/OWNERS
# TEAM: chrome-upboarding-eng@google.com
# COMPONENT: Upboarding>VideoTutorials
// Copyright 2020 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.
#include "chrome/browser/ui/webui/video_tutorials/video_player_source.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
namespace video_tutorials {
// static
content::WebUIDataSource* CreateVideoPlayerUntrustedDataSource() {
content::WebUIDataSource* source = content::WebUIDataSource::Create(
chrome::kChromeUIUntrustedVideoPlayerUrl);
source->AddResourcePath("", IDR_VIDEO_PLAYER_HTML);
source->AddResourcePath("video_player.css", IDR_VIDEO_PLAYER_CSS);
source->AddResourcePath("video_player.js", IDR_VIDEO_PLAYER_JS);
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ConnectSrc, "connect-src https:;");
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ImgSrc, "img-src https:;");
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::MediaSrc, "media-src https:;");
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::StyleSrc, "style-src 'self';");
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc, "script-src 'self';");
return source;
}
} // namespace video_tutorials
// Copyright 2019 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.
#ifndef CHROME_BROWSER_UI_WEBUI_VIDEO_TUTORIALS_VIDEO_PLAYER_SOURCE_H_
#define CHROME_BROWSER_UI_WEBUI_VIDEO_TUTORIALS_VIDEO_PLAYER_SOURCE_H_
#include "content/public/browser/web_ui_data_source.h"
namespace video_tutorials {
// The data source creation for chrome-untrusted://video-tutorials/.
content::WebUIDataSource* CreateVideoPlayerUntrustedDataSource();
} // namespace video_tutorials
#endif // CHROME_BROWSER_UI_WEBUI_VIDEO_TUTORIALS_VIDEO_PLAYER_SOURCE_H_
......@@ -32,6 +32,7 @@ source_set("internal") {
"//chrome/browser/video_tutorials:public",
"//chrome/browser/video_tutorials/proto",
"//components/leveldb_proto",
"//content/public/browser",
]
if (is_android) {
......
......@@ -6,6 +6,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_android.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/ui/webui/video_tutorials/video_player_source.h"
#include "chrome/browser/video_tutorials/internal/android/video_tutorial_service_bridge.h"
#include "chrome/browser/video_tutorials/internal/jni_headers/VideoTutorialServiceFactory_jni.h"
#include "chrome/browser/video_tutorials/video_tutorial_service_factory.h"
......@@ -18,6 +19,10 @@ JNI_VideoTutorialServiceFactory_GetForProfile(
Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
ProfileKey* profile_key = profile->GetProfileKey();
// TODO(shaktisahu): Move this to VideoTutorialServiceFactory.
content::WebUIDataSource::Add(
profile, video_tutorials::CreateVideoPlayerUntrustedDataSource());
// Return null if there is no reasonable context for the provided Java
// profile.
if (profile_key == nullptr)
......
......@@ -198,6 +198,8 @@ const char kChromeUINativeHistoryURL[] = "chrome-native://history/";
const char kChromeUINativeNewTabURL[] = "chrome-native://newtab/";
const char kChromeUIOfflineInternalsHost[] = "offline-internals";
const char kChromeUISnippetsInternalsHost[] = "snippets-internals";
const char kChromeUIUntrustedVideoPlayerUrl[] =
"chrome-untrusted://video-tutorials/";
const char kChromeUIWebApksHost[] = "webapks";
#else
const char kChromeUINearbyInternalsHost[] = "nearby-internals";
......
......@@ -195,6 +195,7 @@ extern const char kChromeUINativeExploreURL[];
extern const char kChromeUINativeHistoryURL[];
extern const char kChromeUINativeNewTabURL[];
extern const char kChromeUISnippetsInternalsHost[];
extern const char kChromeUIUntrustedVideoPlayerUrl[];
extern const char kChromeUIWebApksHost[];
#else
extern const char kChromeUINearbyInternalsHost[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment