0

ui: remove SelectFileDialog impl params

This change removes params from all the implementations of
SelectFileDialog::SelectFileImpl. The next and final CL in this chain
will remove the parameter from SelectFileDialog::SelectFile() at every
call site.

Bug: 340178601
Change-Id: I1f76776330113601a9d50d1f946f58223f5b2e35
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5709097
Commit-Queue: Elly FJ <ellyjones@chromium.org>
Reviewed-by: Eric Seckler <eseckler@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1328917}
This commit is contained in:
Elly
2024-07-17 16:23:21 +00:00
committed by Chromium LUCI CQ
parent afd1dc78ac
commit 7b09c54dd5
36 changed files with 11 additions and 65 deletions

@ -76,7 +76,6 @@ class FakeFolderSelectionDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
dialog_widget_ = views::UniqueWidgetPtr(std::make_unique<views::Widget>());
views::Widget::InitParams widget_params(

@ -105,7 +105,6 @@ class TestSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
if (selected_path_.empty()) {
listener_->FileSelectionCanceled();

@ -58,7 +58,6 @@ class TestSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
if (selected_path_.empty()) {
listener_->FileSelectionCanceled();

@ -164,7 +164,6 @@ class TestSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
if (selected_path_.empty()) {
listener_->FileSelectionCanceled();

@ -72,7 +72,6 @@ class TestSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
listener_->FileSelected(ui::SelectedFileInfo(forced_path_),
file_type_index);
@ -128,7 +127,6 @@ class FakeCancellingSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
listener_->FileSelectionCanceled();
}

@ -24,7 +24,6 @@ void SelectPredeterminedFileDialog::SelectFileImpl(
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) {
if (result_.size() == 1) {
listener_->FileSelected(ui::SelectedFileInfo(result_[0]), 0);

@ -26,7 +26,6 @@ class SelectPredeterminedFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override;
bool IsRunning(gfx::NativeWindow owning_window) const override;

@ -521,7 +521,6 @@ void SelectFileDialogExtension::SelectFileImpl(
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owner_window,
void* /* params */,
const GURL* caller) {
// |default_extension| is ignored.
Owner owner;

@ -125,7 +125,6 @@ class SelectFileDialogExtension : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override;
bool HasMultipleFileTypeChoicesImpl() override;

@ -287,7 +287,7 @@ class BaseSelectFileDialogExtensionBrowserTest
ui::SelectFileDialog::SELECT_OPEN_FILE, std::u16string() /* title */,
base::FilePath() /* default_path */, nullptr /* file_types */,
0 /* file_type_index */, FILE_PATH_LITERAL("") /* default_extension */,
owning_window, this /* params */);
owning_window, nullptr /* params */);
}
void ClickJsButton(content::RenderFrameHost* frame_host,

@ -124,7 +124,6 @@ class FakeSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
// Check that the extensions we expect match the actual extensions passed
// from the CupsPrintersHandler.

@ -94,7 +94,6 @@ class TestSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
if (auto_cancel_) {
listener_->FileSelectionCanceled();

@ -34,7 +34,6 @@ class PPAPITestSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
switch (mode_) {
case PPAPITestSelectFileDialogFactory::RESPOND_WITH_FILE_LIST:

@ -43,7 +43,6 @@ class HeadlessSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
if (callback_) {
std::move(callback_).Run(type);

@ -28,7 +28,6 @@ class CancellingSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
if (out_params_) {
out_params_->type = type;
@ -87,7 +86,6 @@ class FakeSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
if (out_params_) {
out_params_->type = type;

@ -1581,7 +1581,6 @@ class FakeSelectFileDialog : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) override {
listener_->FileSelected(ui::SelectedFileInfo(result_), 0);
}

@ -235,7 +235,6 @@ void SelectFileDialogLinuxGtk::SelectFileImpl(
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) {
set_type(type);

@ -42,7 +42,6 @@ class SelectFileDialogLinuxGtk : public ui::SelectFileDialogLinux,
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override;
private:

@ -65,7 +65,6 @@ void FakeSelectFileDialog::SelectFileImpl(
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) {
title_ = title;
if (file_types)

@ -75,7 +75,6 @@ class FakeSelectFileDialog : public SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override;
bool HasMultipleFileTypeChoicesImpl() override;
bool IsRunning(gfx::NativeWindow owning_window) const override;

@ -132,6 +132,7 @@ void SelectFileDialog::SelectFile(
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) {
CHECK(!params);
DCHECK(listener_);
if (select_file_policy_.get() &&
@ -151,7 +152,7 @@ void SelectFileDialog::SelectFile(
// Call the platform specific implementation of the file selection dialog.
SelectFileImpl(type, title, path, file_types, file_type_index,
default_extension, owning_window, params, caller);
default_extension, owning_window, caller);
}
bool SelectFileDialog::HasMultipleFileTypeChoices() {

@ -60,20 +60,18 @@ class SHELL_DIALOGS_EXPORT SelectFileDialog
class SHELL_DIALOGS_EXPORT Listener {
public:
// Notifies the Listener that a file/folder selection has been made. The
// file/folder path is in |file|. |params| is the contextual value passed to
// SelectFile. |index| specifies the index of the filter passed to the
// initial call to SelectFile.
// file/folder path is in |file|. |index| specifies the index of the filter
// passed to the initial call to SelectFile.
virtual void FileSelected(const SelectedFileInfo& file, int index) {}
// Notifies the Listener that many files have been selected. The files are
// in |files|. |params| is the contextual value passed to SelectFile.
// in |files|.
// Implementing this method is optional if no multi-file selection is ever
// made, as the default implementation will call NOTREACHED.
virtual void MultiFilesSelected(const std::vector<SelectedFileInfo>& files);
// Notifies the Listener that the file/folder selection was canceled (via
// the user canceling or closing the selection dialog box, for example).
// |params| is the contextual value passed to SelectFile.
virtual void FileSelectionCanceled() {}
protected:
@ -207,8 +205,7 @@ class SHELL_DIALOGS_EXPORT SelectFileDialog
// you specify this you must also specify |file_types|.
// |owning_window| is the window the dialog is modal to, or NULL for a
// modeless dialog.
// |params| is data from the calling context which will be passed through to
// the listener. Can be NULL. Non-NULL values of |params| are deprecated.
// |params| must be nullptr and is otherwise ignored.
// |caller| is the URL of the dialog caller which can be used to check further
// policy restrictions, when applicable. Can be NULL. Non-NULL values of
// |caller| are deprecated - store the state in the calling object directly.
@ -244,7 +241,6 @@ class SHELL_DIALOGS_EXPORT SelectFileDialog
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) = 0;
// The listener to be notified of selection completion.

@ -116,7 +116,6 @@ void SelectFileDialogImpl::SelectFileImpl(
int file_type_index,
const std::string& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) {
JNIEnv* env = base::android::AttachCurrentThread();

@ -43,8 +43,6 @@ class SelectFileDialogImpl : public SelectFileDialog {
void SetUseMediaCapture(bool use_media_capture) override;
// Called when it is time to display the file picker.
// params is expected to be a vector<string16> with accept_types first and
// the capture value as the last element of the vector.
void SelectFileImpl(SelectFileDialog::Type type,
const std::u16string& title,
const base::FilePath& default_path,
@ -52,7 +50,6 @@ class SelectFileDialogImpl : public SelectFileDialog {
int file_type_index,
const std::string& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override;
protected:

@ -31,8 +31,7 @@ class SelectFileDialogImpl : public SelectFileDialog {
bool IsRunning(gfx::NativeWindow parent_window) const override;
void ListenerDestroyed() override;
void FileWasSelected(void* params,
bool is_multi,
void FileWasSelected(bool is_multi,
bool was_cancelled,
const std::vector<base::FilePath>& files,
int index);
@ -46,7 +45,6 @@ class SelectFileDialogImpl : public SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override;
bool HasMultipleFileTypeChoicesImpl() override;

@ -21,7 +21,6 @@
base::WeakPtr<ui::SelectFileDialogImpl> _dialog;
UIViewController* __weak _viewController;
bool _allowMultipleFiles;
void* _params;
UIDocumentPickerViewController* __strong _documentPickerController;
NSArray<UTType*>* __strong _fileUTTypeLists;
bool _allowsOtherFileTypes;
@ -30,7 +29,6 @@
- (instancetype)initWithDialog:(base::WeakPtr<ui::SelectFileDialogImpl>)dialog
viewController:(UIViewController*)viewController
allowMultipleFiles:(bool)allowMultipleFiles
params:(void*)params
fileUTTypeLists:(NSArray<UTType*>*)fileUTTypeLists
allowsOtherFileTypes:(bool)allowsOtherFileTypes;
- (void)dealloc;
@ -45,7 +43,6 @@
- (instancetype)initWithDialog:(base::WeakPtr<ui::SelectFileDialogImpl>)dialog
viewController:(UIViewController*)viewController
allowMultipleFiles:(bool)allowMultipleFiles
params:(void*)params
fileUTTypeLists:(NSArray<UTType*>*)fileUTTypeLists
allowsOtherFileTypes:(bool)allowsOtherFileTypes {
if (!(self = [super init])) {
@ -54,7 +51,6 @@
_dialog = dialog;
_viewController = viewController;
_allowMultipleFiles = allowMultipleFiles;
_params = params;
_fileUTTypeLists = fileUTTypeLists;
_allowsOtherFileTypes = allowsOtherFileTypes;
return self;
@ -94,7 +90,7 @@
NSString* path = url.path;
paths.push_back(base::apple::NSStringToFilePath(path));
}
_dialog->FileWasSelected(_params, _allowMultipleFiles, false, paths, 0);
_dialog->FileWasSelected(_allowMultipleFiles, false, paths, 0);
}
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController*)controller {
@ -102,7 +98,7 @@
return;
}
std::vector<base::FilePath> paths;
_dialog->FileWasSelected(_params, _allowMultipleFiles, true, paths, 0);
_dialog->FileWasSelected(_allowMultipleFiles, true, paths, 0);
}
@end
@ -123,7 +119,6 @@ void SelectFileDialogImpl::ListenerDestroyed() {
}
void SelectFileDialogImpl::FileWasSelected(
void* params,
bool is_multi,
bool was_cancelled,
const std::vector<base::FilePath>& files,
@ -151,7 +146,6 @@ void SelectFileDialogImpl::SelectFileImpl(
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow gfx_window,
void* params,
const GURL* caller) {
has_multiple_file_type_choices_ =
SelectFileDialog::SELECT_OPEN_MULTI_FILE == type;
@ -180,7 +174,6 @@ void SelectFileDialogImpl::SelectFileImpl(
[[NativeFileDialog alloc] initWithDialog:weak_factory_.GetWeakPtr()
viewController:controller
allowMultipleFiles:has_multiple_file_type_choices_
params:params
fileUTTypeLists:file_uttype_lists
allowsOtherFileTypes:allows_other_file_types];
[native_file_dialog_ showFilePickerMenu:directory];

@ -119,7 +119,6 @@ void SelectFileDialogLacros::SelectFileImpl(
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) {
crosapi::mojom::SelectFileOptionsPtr options =
crosapi::mojom::SelectFileOptions::New();

@ -46,7 +46,6 @@ class SHELL_DIALOGS_EXPORT SelectFileDialogLacros : public SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override;
bool HasMultipleFileTypeChoicesImpl() override;
bool IsRunning(gfx::NativeWindow owning_window) const override;

@ -39,7 +39,6 @@ class SHELL_DIALOGS_EXPORT SelectFileDialogLinux : public SelectFileDialog {
~SelectFileDialogLinux() override;
// SelectFileDialog implementation.
// |params| is user data we pass back via the Listener interface.
void SelectFileImpl(Type type,
const std::u16string& title,
const base::FilePath& default_path,
@ -47,7 +46,6 @@ class SHELL_DIALOGS_EXPORT SelectFileDialogLinux : public SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override = 0;
// Wrapper for base::DirectoryExists() that allow access on the UI

@ -68,7 +68,6 @@ class SelectFileDialogLinuxKde : public SelectFileDialogLinux {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override;
private:
@ -125,8 +124,6 @@ class SelectFileDialogLinuxKde : public SelectFileDialogLinux {
void MultiFilesSelected(const std::vector<base::FilePath>& files);
// Notifies the listener that no file was chosen (the action was canceled).
// Dialog is passed so we can find that |params| pointer that was passed to
// us when we were told to show the dialog.
void FileNotSelected();
void CreateSelectFolderDialog(Type type,
@ -253,7 +250,6 @@ void SelectFileDialogLinuxKde::SelectFileImpl(
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
set_type(type);

@ -206,7 +206,6 @@ void SelectFileDialogLinuxPortal::SelectFileImpl(
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) {
info_ = base::MakeRefCounted<DialogInfo>(
base::BindOnce(&SelectFileDialogLinuxPortal::DialogCreatedOnMainThread,

@ -54,7 +54,6 @@ class SelectFileDialogLinuxPortal : public SelectFileDialogLinux {
bool IsRunning(gfx::NativeWindow parent_window) const override;
// SelectFileDialog implementation.
// |params| is user data we pass back via the Listener interface.
void SelectFileImpl(Type type,
const std::u16string& title,
const base::FilePath& default_path,
@ -62,7 +61,6 @@ class SelectFileDialogLinuxPortal : public SelectFileDialogLinux {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override;
bool HasMultipleFileTypeChoicesImpl() override;

@ -40,7 +40,6 @@ class SHELL_DIALOGS_EXPORT SelectFileDialogImpl : public ui::SelectFileDialog {
protected:
// SelectFileDialog implementation.
// |params| is user data we pass back via the Listener interface.
void SelectFileImpl(Type type,
const std::u16string& title,
const base::FilePath& default_path,
@ -48,7 +47,6 @@ class SHELL_DIALOGS_EXPORT SelectFileDialogImpl : public ui::SelectFileDialog {
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override;
private:

@ -82,7 +82,6 @@ void SelectFileDialogImpl::SelectFileImpl(
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow gfx_window,
void* /* params */,
const GURL* caller) {
DCHECK(type == SELECT_FOLDER || type == SELECT_UPLOAD_FOLDER ||
type == SELECT_EXISTING_FOLDER || type == SELECT_OPEN_FILE ||

@ -68,7 +68,6 @@ class SelectFileDialogMacTest : public PlatformTest,
raw_ptr<SelectFileDialog::FileTypeInfo> file_types = nullptr;
int file_type_index = 0;
base::FilePath::StringType default_extension;
raw_ptr<void> params = nullptr;
};
// Helper method to create a dialog with the given `args`. Returns the created
@ -84,7 +83,7 @@ class SelectFileDialogMacTest : public PlatformTest,
dialog_->SelectFile(args.type, args.title, args.default_path,
args.file_types, args.file_type_index,
args.default_extension, parent_window, args.params);
args.default_extension, parent_window, nullptr);
// At this point, the Mojo IPC to show the dialog is queued up. Spin the
// message loop to get the Mojo IPC to happen.

@ -176,7 +176,6 @@ class SelectFileDialogImpl : public ui::SelectFileDialog,
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params,
const GURL* caller) override;
private:
@ -244,7 +243,6 @@ void SelectFileDialogImpl::SelectFileImpl(
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* /* params */,
const GURL* caller) {
has_multiple_file_type_choices_ =
file_types ? file_types->extensions.size() > 1 : true;