-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AI Chat] WebManifest for PWA install
- Loading branch information
Showing
11 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
chromium_src/chrome/browser/banners/app_banner_manager_desktop_browsertest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2024 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/. | ||
|
||
#include "src/chrome/browser/banners/app_banner_manager_desktop_browsertest.cc" | ||
|
||
#include "brave/components/constants/webui_url_constants.h" | ||
namespace webapps { | ||
|
||
class AppBannerManagerDesktopBrowserTestForBraveAllowedPage | ||
: public AppBannerManagerDesktopBrowserTest { | ||
public: | ||
void SetUp() override { | ||
scoped_feature_list_.InitWithFeatures( | ||
/*enabled_features=*/{}, GetDisabledFeatures()); | ||
TestAppBannerManagerDesktop::SetUp(); | ||
AppBannerManagerBrowserTestBase::SetUp(); | ||
} | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(AppBannerManagerDesktopBrowserTestForBraveAllowedPage, | ||
WebUiAIChatApp) { | ||
TestAppBannerManagerDesktop* manager = | ||
TestAppBannerManagerDesktop::FromWebContents( | ||
browser()->tab_strip_model()->GetActiveWebContents()); | ||
|
||
// Simulate loading an AI Chat page | ||
{ | ||
base::RunLoop run_loop; | ||
manager->PrepareDone(run_loop.QuitClosure()); | ||
|
||
ASSERT_TRUE(ui_test_utils::NavigateToURL( | ||
browser(), GURL(base::StrCat({"chrome://", kAIChatUIHost})))); | ||
run_loop.Run(); | ||
} | ||
|
||
EXPECT_EQ(InstallableWebAppCheckResult::kYes_Promotable, | ||
manager->GetInstallableWebAppCheckResult()); | ||
} | ||
|
||
} // namespace webapps |
23 changes: 23 additions & 0 deletions
23
chromium_src/chrome/browser/web_applications/web_app_helpers.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) 2024 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/. | ||
|
||
#include "base/containers/contains.h" | ||
#include "brave/components/constants/webui_url_constants.h" | ||
|
||
// Make sure IsValidWebAppUrl also checks for allowed Brave WebUI hosts | ||
#define IsValidWebAppUrl IsValidWebAppUrl_ChromiumImpl | ||
|
||
#include "src/chrome/browser/web_applications/web_app_helpers.cc" | ||
#undef IsValidWebAppUrl | ||
|
||
namespace web_app { | ||
|
||
bool IsValidWebAppUrl(const GURL& app_url) { | ||
return IsValidWebAppUrl_ChromiumImpl(app_url) || | ||
(app_url.SchemeIs(content::kChromeUIScheme) && | ||
base::Contains(kInstallablePWAWebUIHosts, app_url.host())); | ||
} | ||
|
||
} // namespace web_app |
14 changes: 14 additions & 0 deletions
14
chromium_src/chrome/browser/web_applications/web_app_helpers_unittest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) 2024 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/. | ||
|
||
#include "src/chrome/browser/web_applications/web_app_helpers_unittest.cc" | ||
|
||
namespace web_app { | ||
|
||
TEST(WebAppHelpers, Brave_IsValidWebAppUrl) { | ||
EXPECT_TRUE(IsValidWebAppUrl(GURL("chrome://leo-ai"))); | ||
} | ||
|
||
} // namespace web_app |
19 changes: 19 additions & 0 deletions
19
chromium_src/components/webapps/browser/banners/app_banner_manager.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2024 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/. | ||
|
||
#include "base/containers/contains.h" | ||
#include "brave/components/constants/webui_url_constants.h" | ||
|
||
// Include password_manager constants before override so we don't override the | ||
// definition. | ||
#include "components/password_manager/content/common/web_ui_constants.h" | ||
|
||
// Add some extra items to WebUI hosts considered valid for PWAs | ||
#define kChromeUIPasswordManagerHost \ | ||
kChromeUIPasswordManagerHost && \ | ||
!base::Contains(kInstallablePWAWebUIHosts, url.host()) | ||
|
||
#include "src/components/webapps/browser/banners/app_banner_manager.cc" | ||
#undef kChromeUIPasswordManagerHost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"short_name": "$i18n{siteTitle}", | ||
"name": "$i18n{siteTitle}", | ||
"icons": [ | ||
{ | ||
"src": "/pwa_icon.svg", | ||
"type": "image/svg+xml", | ||
"sizes": "any" | ||
} | ||
], | ||
"start_url": "/?source=pwa", | ||
"id": "chrome://leo-ai/", | ||
"display": "standalone", | ||
"scope": "chrome://leo-ai/" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters