Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use precomputed caller in the file save dialog title. #26953

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading