Skip to content

Commit

Permalink
Use download item origin in the file save dialog title.
Browse files Browse the repository at this point in the history
  • Loading branch information
goodov committed Dec 10, 2024
1 parent 9d3cf80 commit b19ef69
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions chromium_src/chrome/browser/download/download_file_picker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

#include <string>

#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"
Expand All @@ -17,7 +19,8 @@
namespace {

std::u16string GetTitle(content::RenderFrameHost* render_frame_host,
const std::u16string& original_title) {
const std::u16string& original_title,
download::DownloadItem* download_item) {
#if BUILDFLAG(IS_ANDROID)
return original_title;
#else
Expand All @@ -26,19 +29,19 @@ std::u16string GetTitle(content::RenderFrameHost* render_frame_host,
}
return brave::GetFileSelectTitle(
content::WebContents::FromRenderFrameHost(render_frame_host),
render_frame_host->GetLastCommittedOrigin(),
url::Origin::Create(download_item->GetURL()),
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, \
caller)
#define SelectFile(type, title, default_path, file_types, file_type_index, \
default_extension, owning_window, caller) \
SelectFile(type, GetTitle(render_frame_host, title, download_item_), \
default_path, file_types, file_type_index, default_extension, \
owning_window, caller)

#include "src/chrome/browser/download/download_file_picker.cc"

Expand Down

0 comments on commit b19ef69

Please sign in to comment.