[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
This commit is contained in:
@@ -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",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<grit-part>
|
||||
<include name="IDR_AI_CHAT_UI_HTML" file="../ai_chat/resources/page/ai_chat_ui.html"
|
||||
<include name="IDR_AI_CHAT_UI_HTML" file="${root_gen_dir}/brave/components/ai_chat/resources/preprocessed/page/ai_chat_ui.html"
|
||||
use_base_dir="false"
|
||||
type="BINDATA" />
|
||||
<include name="IDR_AI_CHAT_UI_CSS" file="../ai_chat/resources/page/styles.css" type="BINDATA" />
|
||||
<include name="IDR_AI_CHAT_UNTRUSTED_CONVERSATION_UI_HTML"
|
||||
file="../ai_chat/resources/untrusted_conversation_frame/untrusted_conversation_frame.html"
|
||||
file="${root_gen_dir}/brave/components/ai_chat/resources/preprocessed/untrusted_conversation_frame/untrusted_conversation_frame.html"
|
||||
use_base_dir="false"
|
||||
type="BINDATA" />
|
||||
<include name="IDR_AI_CHAT_UI_MANIFEST" file="../ai_chat/resources/page/manifest.webmanifest" type="BINDATA" />
|
||||
<include name="IDR_AI_CHAT_UI_PWA_ICON" file="../ai_chat/resources/page/pwa_icon.svg" type="BINDATA" />
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
<script src="//resources/js/load_time_data_deprecated.js"></script>
|
||||
<script src="/strings.js"></script>
|
||||
<script src="chat_ui.bundle.js" type="module"></script>
|
||||
<if expr="is_ios">
|
||||
<script src="//resources/js/ios/web_ui.js"></script>
|
||||
<script src="//resources/js/ios/mojo_api.js"></script>
|
||||
</if>
|
||||
<link rel="icon" href="//resources/brave-icons/social-leo-favicon-fullheight-color.svg">
|
||||
<link rel="manifest" href="manifest.webmanifest">
|
||||
<style>
|
||||
|
||||
+4
@@ -13,6 +13,10 @@
|
||||
<script src="//resources/js/load_time_data_deprecated.js"></script>
|
||||
<script src="/strings.js"></script>
|
||||
<script src="untrusted_conversation_frame.bundle.js" type="module"></script>
|
||||
<if expr="is_ios">
|
||||
<script src="//resources/js/ios/web_ui.js"></script>
|
||||
<script src="//resources/js/ios/mojo_api.js"></script>
|
||||
</if>
|
||||
<style>
|
||||
body {
|
||||
/* This page is designed to be embedded in an opaque iframe */
|
||||
|
||||
@@ -25,6 +25,7 @@ brave_grit("static_resources") {
|
||||
]
|
||||
deps = [
|
||||
":strings",
|
||||
"//brave/components/ai_chat/resources",
|
||||
"//brave/components/brave_rewards/resources",
|
||||
"//brave/components/brave_shields/resources:bundle_js",
|
||||
"//brave/components/decentralized_dns/content/resources:bundle_js",
|
||||
|
||||
Reference in New Issue
Block a user