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 2009b48
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 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,
const GURL& caller) {
#if BUILDFLAG(IS_ANDROID)
return original_title;
#else
Expand All @@ -26,18 +29,17 @@ std::u16string GetTitle(content::RenderFrameHost* render_frame_host,
}
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 2009b48

Please sign in to comment.