Commit dcfaebf1 authored by Anastasiia N's avatar Anastasiia N Committed by Chromium LUCI CQ

Load webview_saml_injected from file

After we migrated c/b/resources/gaia_auth_host/ to JS modules,
webview_saml_injected.js file in saml_handler.js wasn't inlined in
"injectedJs" variable anymore.

Since "// <include ..." doesn't work for generated files,
"addContentScripts" call is updated to load the script from file
instead.

saml_handler.js is also used in OOBE and in-session password change
flow. This CL updates their webui files to include
webview_saml_injected.js.

Bug: 1160632
Change-Id: I47a5bc0b2119dd0bab9bb492ccd743ce2cd48d05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2599861Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarYusuf Sengul <yusufsn@google.com>
Commit-Queue: Anastasiia N <anastasiian@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839080}
parent 2a842e6c
...@@ -162,6 +162,7 @@ ...@@ -162,6 +162,7 @@
<include name="IDR_INLINE_LOGIN_HTML" file="resources\inline_login\inline_login.html" type="BINDATA" /> <include name="IDR_INLINE_LOGIN_HTML" file="resources\inline_login\inline_login.html" type="BINDATA" />
<include name="IDR_INLINE_LOGIN_APP_JS" file="${root_gen_dir}\chrome\browser\resources\inline_login\inline_login_app.js" use_base_dir="false" type ="BINDATA" preprocess="true" /> <include name="IDR_INLINE_LOGIN_APP_JS" file="${root_gen_dir}\chrome\browser\resources\inline_login\inline_login_app.js" use_base_dir="false" type ="BINDATA" preprocess="true" />
<include name="IDR_INLINE_LOGIN_BROWSER_PROXY_JS" file="resources\inline_login\inline_login_browser_proxy.js" type ="BINDATA" preprocess="true"/> <include name="IDR_INLINE_LOGIN_BROWSER_PROXY_JS" file="resources\inline_login\inline_login_browser_proxy.js" type ="BINDATA" preprocess="true"/>
<include name="IDR_GAIA_AUTH_WEBVIEW_SAML_INJECTED_JS" file="resources\gaia_auth_host\webview_saml_injected.js" flattenhtml="true" type="BINDATA" />
</if> </if>
<if expr="chromeos"> <if expr="chromeos">
......
...@@ -63,9 +63,7 @@ cr.define('cr.login', function() { ...@@ -63,9 +63,7 @@ cr.define('cr.login', function() {
* The script to inject into webview and its sub frames. * The script to inject into webview and its sub frames.
* @type {string} * @type {string}
*/ */
const injectedJs = String.raw` const injectedJs = 'webview_saml_injected.js';
// <include src="webview_saml_injected.js">
`;
/** /**
* @typedef {{ * @typedef {{
...@@ -313,7 +311,7 @@ cr.define('cr.login', function() { ...@@ -313,7 +311,7 @@ cr.define('cr.login', function() {
this.webview_.addContentScripts([{ this.webview_.addContentScripts([{
name: injectedScriptName, name: injectedScriptName,
matches: ['http://*/*', 'https://*/*'], matches: ['http://*/*', 'https://*/*'],
js: {code: injectedJs}, js: {files: [injectedJs]},
all_frames: true, all_frames: true,
run_at: 'document_start' run_at: 'document_start'
}]); }]);
......
...@@ -58,6 +58,8 @@ LockScreenStartReauthUI::LockScreenStartReauthUI(content::WebUI* web_ui) ...@@ -58,6 +58,8 @@ LockScreenStartReauthUI::LockScreenStartReauthUI(content::WebUI* web_ui)
source->SetDefaultResource(IDR_LOCK_SCREEN_REAUTH_HTML); source->SetDefaultResource(IDR_LOCK_SCREEN_REAUTH_HTML);
source->AddResourcePath("authenticator.js", IDR_GAIA_AUTH_AUTHENTICATOR_JS); source->AddResourcePath("authenticator.js", IDR_GAIA_AUTH_AUTHENTICATOR_JS);
source->AddResourcePath("webview_saml_injected.js",
IDR_GAIA_AUTH_WEBVIEW_SAML_INJECTED_JS);
source->AddResourcePath("lock_screen_reauth.js", IDR_LOCK_SCREEN_REAUTH_JS); source->AddResourcePath("lock_screen_reauth.js", IDR_LOCK_SCREEN_REAUTH_JS);
......
...@@ -99,6 +99,8 @@ PasswordChangeUI::PasswordChangeUI(content::WebUI* web_ui) ...@@ -99,6 +99,8 @@ PasswordChangeUI::PasswordChangeUI(content::WebUI* web_ui)
source->AddResourcePath("password_change.css", IDR_PASSWORD_CHANGE_CSS); source->AddResourcePath("password_change.css", IDR_PASSWORD_CHANGE_CSS);
source->AddResourcePath("authenticator.js", source->AddResourcePath("authenticator.js",
IDR_PASSWORD_CHANGE_AUTHENTICATOR_JS); IDR_PASSWORD_CHANGE_AUTHENTICATOR_JS);
source->AddResourcePath("webview_saml_injected.js",
IDR_GAIA_AUTH_WEBVIEW_SAML_INJECTED_JS);
source->AddResourcePath("password_change.js", IDR_PASSWORD_CHANGE_JS); source->AddResourcePath("password_change.js", IDR_PASSWORD_CHANGE_JS);
content::WebUIDataSource::Add(profile, source); content::WebUIDataSource::Add(profile, source);
......
...@@ -150,6 +150,7 @@ constexpr char kProductLogoPath[] = "product-logo.png"; ...@@ -150,6 +150,7 @@ constexpr char kProductLogoPath[] = "product-logo.png";
constexpr char kRecommendAppListViewHTMLPath[] = "recommend_app_list_view.html"; constexpr char kRecommendAppListViewHTMLPath[] = "recommend_app_list_view.html";
constexpr char kRecommendAppListViewJSPath[] = "recommend_app_list_view.js"; constexpr char kRecommendAppListViewJSPath[] = "recommend_app_list_view.js";
constexpr char kTestAPIJSPath[] = "test_api.js"; constexpr char kTestAPIJSPath[] = "test_api.js";
constexpr char kWebviewSamlInjectedJSPath[] = "webview_saml_injected.js";
// Components // Components
constexpr char kCommonStylesHTML[] = "components/common_styles.html"; constexpr char kCommonStylesHTML[] = "components/common_styles.html";
...@@ -367,6 +368,8 @@ content::WebUIDataSource* CreateOobeUIDataSource( ...@@ -367,6 +368,8 @@ content::WebUIDataSource* CreateOobeUIDataSource(
AddDebuggerResources(source); AddDebuggerResources(source);
AddTestAPIResources(source); AddTestAPIResources(source);
source->AddResourcePath(kWebviewSamlInjectedJSPath,
IDR_GAIA_AUTH_WEBVIEW_SAML_INJECTED_JS);
source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS); source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS);
source->OverrideContentSecurityPolicy( source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ObjectSrc, "object-src chrome:;"); network::mojom::CSPDirectiveName::ObjectSrc, "object-src chrome:;");
......
...@@ -128,6 +128,7 @@ content::WebUIDataSource* CreateWebUIDataSource(Profile* profile) { ...@@ -128,6 +128,7 @@ content::WebUIDataSource* CreateWebUIDataSource(Profile* profile) {
static constexpr webui::ResourcePath kResources[] = { static constexpr webui::ResourcePath kResources[] = {
{"inline_login_app.js", IDR_INLINE_LOGIN_APP_JS}, {"inline_login_app.js", IDR_INLINE_LOGIN_APP_JS},
{"inline_login_browser_proxy.js", IDR_INLINE_LOGIN_BROWSER_PROXY_JS}, {"inline_login_browser_proxy.js", IDR_INLINE_LOGIN_BROWSER_PROXY_JS},
{"webview_saml_injected.js", IDR_GAIA_AUTH_WEBVIEW_SAML_INJECTED_JS},
#if BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH)
{"welcome_page_app.js", IDR_INLINE_LOGIN_WELCOME_PAGE_APP_JS}, {"welcome_page_app.js", IDR_INLINE_LOGIN_WELCOME_PAGE_APP_JS},
{"account_manager_shared_css.js", IDR_ACCOUNT_MANAGER_SHARED_CSS_JS}, {"account_manager_shared_css.js", IDR_ACCOUNT_MANAGER_SHARED_CSS_JS},
......
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