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 fb38358
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,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"
Expand Down

0 comments on commit fb38358

Please sign in to comment.