From 9eafe8d679d288e669ccd29942c6124c4e9e06c9 Mon Sep 17 00:00:00 2001 From: brave-builds Date: Tue, 17 Dec 2024 06:56:50 +0000 Subject: [PATCH] Uplift of #26953 (squashed) to beta --- app/brave_generated_resources.grd | 4 ++-- browser/ui/brave_file_select_utils_unittest.cc | 12 ++++++------ .../browser/download/download_file_picker.cc | 17 ++++++++++------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index d5416f7954a9..cf3cfc2e7bca 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -1327,7 +1327,7 @@ Or change later at $2brave://settings/ext $1http://foo.com wants to open - An embedded page on $1http://foo.com wants to open + An embedded page at $1http://foo.com wants to open This page wants to open @@ -1339,7 +1339,7 @@ Or change later at $2brave://settings/ext $1http://foo.com wants to save - An embedded page on $1http://foo.com wants to save + An embedded page at $1http://foo.com wants to save This page wants to save diff --git a/browser/ui/brave_file_select_utils_unittest.cc b/browser/ui/brave_file_select_utils_unittest.cc index 5738960b4e28..06ec2d6222dd 100644 --- a/browser/ui/brave_file_select_utils_unittest.cc +++ b/browser/ui/brave_file_select_utils_unittest.cc @@ -127,7 +127,7 @@ TEST(BraveFileSelectUtilsUnitTest, GetSiteFrameTitleForFileSelect_Open) { "foo.com wants to open"}, // Subframe alert from a different origin. {"subframe different origin", "http://foo.com/", false, "http://bar.com/", - "An embedded page on bar.com wants to open"}, + "An embedded page at bar.com wants to open"}, // file: // - main frame: @@ -175,7 +175,7 @@ TEST(BraveFileSelectUtilsUnitTest, GetSiteFrameTitleForFileSelect_Open) { // - subframe: {"blob subframe", "http://bar.com/", false, "blob:http://foo.com/66666666-6666-6666-6666-666666666666", - "An embedded page on foo.com wants to open"}, + "An embedded page at foo.com wants to open"}, // filesystem: // - main frame: @@ -184,7 +184,7 @@ TEST(BraveFileSelectUtilsUnitTest, GetSiteFrameTitleForFileSelect_Open) { // - subframe: {"filesystem subframe", "http://bar.com/", false, "filesystem:http://foo.com/bar.html", - "An embedded page on foo.com wants to open"}, + "An embedded page at foo.com wants to open"}, }; brave_l10n::test::ScopedDefaultLocale scoped_locale("en-US"); @@ -230,7 +230,7 @@ TEST(BraveFileSelectUtilsUnitTest, GetSiteFrameTitleForFileSelect_Save) { "foo.com wants to save"}, // Subframe alert from a different origin. {"subframe different origin", "http://foo.com/", false, "http://bar.com/", - "An embedded page on bar.com wants to save"}, + "An embedded page at bar.com wants to save"}, // file: // - main frame: @@ -278,7 +278,7 @@ TEST(BraveFileSelectUtilsUnitTest, GetSiteFrameTitleForFileSelect_Save) { // - subframe: {"blob subframe", "http://bar.com/", false, "blob:http://foo.com/66666666-6666-6666-6666-666666666666", - "An embedded page on foo.com wants to save"}, + "An embedded page at foo.com wants to save"}, // filesystem: // - main frame: @@ -287,7 +287,7 @@ TEST(BraveFileSelectUtilsUnitTest, GetSiteFrameTitleForFileSelect_Save) { // - subframe: {"filesystem subframe", "http://bar.com/", false, "filesystem:http://foo.com/bar.html", - "An embedded page on foo.com wants to save"}, + "An embedded page at foo.com wants to save"}, }; brave_l10n::test::ScopedDefaultLocale scoped_locale("en-US"); diff --git a/chromium_src/chrome/browser/download/download_file_picker.cc b/chromium_src/chrome/browser/download/download_file_picker.cc index 0329cf5c5330..01fffc5c53f0 100644 --- a/chromium_src/chrome/browser/download/download_file_picker.cc +++ b/chromium_src/chrome/browser/download/download_file_picker.cc @@ -5,10 +5,12 @@ #include +#include "components/download/public/common/download_item.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h" #include "ui/shell_dialogs/select_file_dialog.h" +#include "url/origin.h" #if !BUILDFLAG(IS_ANDROID) #include "brave/browser/ui/brave_file_select_utils.h" @@ -17,27 +19,28 @@ namespace { std::u16string GetTitle(content::RenderFrameHost* render_frame_host, - const std::u16string& original_title) { + const std::u16string& original_title, + const GURL* caller) { #if BUILDFLAG(IS_ANDROID) return original_title; #else if (!render_frame_host) { return original_title; } + CHECK(caller); return brave::GetFileSelectTitle( content::WebContents::FromRenderFrameHost(render_frame_host), - render_frame_host->GetLastCommittedOrigin(), - brave::FileSelectTitleType::kSave); + url::Origin::Create(*caller), brave::FileSelectTitleType::kSave); #endif } } // namespace // Override title of the file select dialog for downloads. -#define SelectFile(type, title, default_path, file_types, file_type_index, \ - default_extension, owning_window, caller) \ - SelectFile(type, GetTitle(render_frame_host, title), default_path, \ - file_types, file_type_index, default_extension, owning_window, \ +#define SelectFile(type, title, default_path, file_types, file_type_index, \ + default_extension, owning_window, caller) \ + SelectFile(type, GetTitle(render_frame_host, title, caller), default_path, \ + file_types, file_type_index, default_extension, owning_window, \ caller) #include "src/chrome/browser/download/download_file_picker.cc"