From c6895a85e14ee5976210e289033fc72482f2884f Mon Sep 17 00:00:00 2001 From: Kyle Hickinson Date: Mon, 29 Sep 2025 16:51:43 -0400 Subject: [PATCH] [AI Chat] Preprocess html resources to include iOS specific scripts (#31480) This change preprocesses the `ai_chat_ui.html` and `untrusted_conversation_frame.html` file so that if expression's are evaluated which allows us to add required scripts when using them in iOS --- components/ai_chat/resources/BUILD.gn | 16 +++++++++++++++- .../ai_chat/resources/ai_chat_ui_resources.grdp | 6 ++++-- .../ai_chat/resources/page/ai_chat_ui.html | 4 ++++ .../untrusted_conversation_frame.html | 4 ++++ components/resources/BUILD.gn | 1 + 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/components/ai_chat/resources/BUILD.gn b/components/ai_chat/resources/BUILD.gn index 615e35b65c2..1d9d2f0c230 100644 --- a/components/ai_chat/resources/BUILD.gn +++ b/components/ai_chat/resources/BUILD.gn @@ -4,6 +4,7 @@ # You can obtain one at https://mozilla.org/MPL/2.0/. import("//brave/components/common/typescript.gni") +import("//tools/grit/preprocess_if_expr.gni") transpile_web_ui("ai_chat_ui") { resource_name = "ai_chat_ui" @@ -24,8 +25,21 @@ transpile_web_ui("ai_chat_ui") { ] } +preprocess_if_expr("preprocess_html") { + visibility = [ ":resources_grit" ] + in_folder = "." + in_files = [ + "page/ai_chat_ui.html", + "untrusted_conversation_frame/untrusted_conversation_frame.html", + ] + out_folder = "$target_gen_dir/preprocessed" +} + pack_web_resources("resources") { resource_name = "ai_chat_ui" output_dir = "$root_gen_dir/brave/components/ai_chat/resources" - deps = [ ":ai_chat_ui" ] + deps = [ + ":ai_chat_ui", + ":preprocess_html", + ] } diff --git a/components/ai_chat/resources/ai_chat_ui_resources.grdp b/components/ai_chat/resources/ai_chat_ui_resources.grdp index 1434bd5bf96..4326092c26d 100644 --- a/components/ai_chat/resources/ai_chat_ui_resources.grdp +++ b/components/ai_chat/resources/ai_chat_ui_resources.grdp @@ -1,10 +1,12 @@ - diff --git a/components/ai_chat/resources/page/ai_chat_ui.html b/components/ai_chat/resources/page/ai_chat_ui.html index 4ae1f7cf259..0660e067e61 100644 --- a/components/ai_chat/resources/page/ai_chat_ui.html +++ b/components/ai_chat/resources/page/ai_chat_ui.html @@ -14,6 +14,10 @@ + + + +