-
Notifications
You must be signed in to change notification settings - Fork 896
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AI Chat: show web sources that were used (normally via web search) to…
… generate the response
- Loading branch information
Showing
15 changed files
with
407 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) 2025 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/. | ||
|
||
export default function createSanitizedImageUrl(imageUrl: string) { | ||
return imageUrl | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2025 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/ui/webui/untrusted_sanitized_image_source.h" | ||
|
||
#include <string> | ||
#include <utility> | ||
|
||
#include "base/strings/strcat.h" | ||
#include "chrome/common/webui_url_constants.h" | ||
|
||
std::string UntrustedSanitizedImageSource::GetSource() { | ||
return base::StrCat({content::kChromeUIUntrustedScheme, | ||
url::kStandardSchemeSeparator, | ||
chrome::kChromeUIImageHost, "/"}); | ||
} | ||
|
||
void UntrustedSanitizedImageSource::StartDataRequest( | ||
const GURL& url, | ||
const content::WebContents::Getter& wc_getter, | ||
content::URLDataSource::GotDataCallback callback) { | ||
if (!url.is_valid() || !url.SchemeIs(content::kChromeUIUntrustedScheme)) { | ||
std::move(callback).Run(nullptr); | ||
return; | ||
} | ||
|
||
// Change scheme to ChromeUIScheme for base class | ||
GURL::Replacements replacements; | ||
replacements.SetSchemeStr(content::kChromeUIScheme); | ||
|
||
SanitizedImageSource::StartDataRequest(url.ReplaceComponents(replacements), | ||
wc_getter, std::move(callback)); | ||
} |
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,31 @@ | ||
// Copyright (c) 2025 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_UI_WEBUI_UNTRUSTED_SANITIZED_IMAGE_SOURCE_H_ | ||
#define BRAVE_BROWSER_UI_WEBUI_UNTRUSTED_SANITIZED_IMAGE_SOURCE_H_ | ||
|
||
#include <string> | ||
|
||
#include "chrome/browser/ui/webui/sanitized_image_source.h" | ||
#include "content/public/browser/web_contents.h" | ||
#include "url/gurl.h" | ||
|
||
// Uses SanitizedImageSource for chrome-untrusted:// WebUIs | ||
class UntrustedSanitizedImageSource : public SanitizedImageSource { | ||
public: | ||
using SanitizedImageSource::SanitizedImageSource; | ||
UntrustedSanitizedImageSource(const UntrustedSanitizedImageSource&) = delete; | ||
UntrustedSanitizedImageSource& operator=(const SanitizedImageSource&) = | ||
delete; | ||
|
||
// SanitizedImageSource: | ||
std::string GetSource() override; | ||
void StartDataRequest( | ||
const GURL& url, | ||
const content::WebContents::Getter& wc_getter, | ||
content::URLDataSource::GotDataCallback callback) override; | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_UI_WEBUI_UNTRUSTED_SANITIZED_IMAGE_SOURCE_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
Oops, something went wrong.