[AI Chat]: Allow Leo to be added to home screen (#34586)

This commit is contained in:
Jay Harris
2026-03-13 09:07:34 +13:00
committed by GitHub
parent 9e01ce2c43
commit 955bab7106
4 changed files with 82 additions and 0 deletions
@@ -0,0 +1,21 @@
# Copyright (c) 2026 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.
[[substitution]]
description = "Add import for UrlConstants."
pattern = 'import org.chromium.chrome.R;'
replace = """
import org.chromium.chrome.R;
import org.chromium.components.embedder_support.util.UrlConstants;"""
[[substitution]]
description = """
Make it possible to add chrome://leo-ai to the Home Screen on Android.
This patch updates the `shouldShowHomescreenMenuItem` function to whitelist
chrome://leo-ai.
"""
re_pattern = '(isAddToHomeIntentSupported\(\)\s+)&& (!isNativePage)$'
re_flags = ["MULTILINE"]
replace = '\1&& (\2 || (url != null && UrlConstants.CHROME_SCHEME.equals(url.getScheme()) && url.getHost().equals("leo-ai")))'
@@ -0,0 +1,19 @@
# Copyright (c) 2026 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.
[[substitution]]
description = "Add import for UrlConstants."
pattern = 'import org.chromium.chrome.R;'
replace = """
import org.chromium.chrome.R;
import org.chromium.components.embedder_support.util.UrlConstants;"""
[[substitution]]
description = """
Always make chrome:// schemes install rather than creating a shortcut (shortcuts can't handle chrome: urls).
"""
re_pattern = '(doUniversalInstall(\s|.)+?if \()(controller == null\))'
re_flags = ["MULTILINE"]
replace = '\1(currentTab.getUrl() != null && UrlConstants.CHROME_SCHEME.equals(currentTab.getUrl().getScheme())) || \3'