1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "chrome/browser/ui/webui/video_tutorials/video_player_source.h" 6 7 #include "chrome/common/webui_url_constants.h" 8 #include "chrome/grit/browser_resources.h" 9 #include "services/network/public/mojom/content_security_policy.mojom.h" 10 11 namespace video_tutorials { 12 13 // static CreateVideoPlayerUntrustedDataSource()14content::WebUIDataSource* CreateVideoPlayerUntrustedDataSource() { 15 content::WebUIDataSource* source = content::WebUIDataSource::Create( 16 chrome::kChromeUIUntrustedVideoPlayerUrl); 17 source->AddResourcePath("", IDR_VIDEO_PLAYER_HTML); 18 source->AddResourcePath("video_player.css", IDR_VIDEO_PLAYER_CSS); 19 source->AddResourcePath("video_player.js", IDR_VIDEO_PLAYER_JS); 20 21 source->OverrideContentSecurityPolicy( 22 network::mojom::CSPDirectiveName::ConnectSrc, "connect-src https:;"); 23 source->OverrideContentSecurityPolicy( 24 network::mojom::CSPDirectiveName::ImgSrc, "img-src https:;"); 25 source->OverrideContentSecurityPolicy( 26 network::mojom::CSPDirectiveName::MediaSrc, "media-src https:;"); 27 source->OverrideContentSecurityPolicy( 28 network::mojom::CSPDirectiveName::StyleSrc, "style-src 'self';"); 29 source->OverrideContentSecurityPolicy( 30 network::mojom::CSPDirectiveName::ScriptSrc, 31 "script-src chrome-untrusted://resources/ 'self';"); 32 33 return source; 34 } 35 36 } // namespace video_tutorials 37