-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AI Chat becomes a trusted WebUI with an UntrustedWebUI frame for LLM-…
…generated responses (#26855) * AI Chat becomes a trusted WebUI with an UntrustedWebUI frame for LLM-generated responses - changes Leo Url to chrome://leo-ai - untrusted frame content Url is chrome-untrusted://leo-ai-conversation-entries They use the same JS build to optimize bundle size, but do not share the same allowed mojom interfaces. The untrusted frame is limited to UntrustedConversationHandler to send calls to the browser and UntrustedConversationUI to receive calls from the browser.
- Loading branch information
Showing
103 changed files
with
1,941 additions
and
844 deletions.
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
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,29 @@ | ||
// 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 "brave/browser/ai_chat/ai_chat_urls.h" | ||
|
||
#include <string_view> | ||
|
||
#include "base/strings/strcat.h" | ||
#include "base/strings/string_util.h" | ||
#include "brave/components/constants/webui_url_constants.h" | ||
#include "url/gurl.h" | ||
|
||
namespace ai_chat { | ||
|
||
GURL TabAssociatedConversationUrl() { | ||
return GURL(base::StrCat({kAIChatUIURL, "tab"})); | ||
} | ||
|
||
GURL ConversationUrl(std::string_view conversation_uuid) { | ||
return GURL(base::StrCat({kAIChatUIURL, conversation_uuid})); | ||
} | ||
|
||
std::string_view ConversationUUIDFromURL(const GURL& url) { | ||
return base::TrimString(url.path_piece(), "/", base::TrimPositions::TRIM_ALL); | ||
} | ||
|
||
} // namespace ai_chat |
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,29 @@ | ||
// 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/. | ||
|
||
#ifndef BRAVE_BROWSER_AI_CHAT_AI_CHAT_URLS_H_ | ||
#define BRAVE_BROWSER_AI_CHAT_AI_CHAT_URLS_H_ | ||
|
||
#include <string_view> | ||
|
||
#include "url/gurl.h" | ||
|
||
namespace ai_chat { | ||
|
||
// UI that will open a conversation associated with the active Tab in the same | ||
// browser window. The conversation will change when that Tab navigates. | ||
GURL TabAssociatedConversationUrl(); | ||
|
||
// UI that will open to a specific conversation. The conversation will not | ||
// change upon any navigation. | ||
GURL ConversationUrl(std::string_view conversation_uuid); | ||
|
||
// Extracts the conversation UUID from a conversation URL or a conversation | ||
// entries iframe | ||
std::string_view ConversationUUIDFromURL(const GURL& url); | ||
|
||
} // namespace ai_chat | ||
|
||
#endif // BRAVE_BROWSER_AI_CHAT_AI_CHAT_URLS_H_ |
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
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
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
Oops, something went wrong.