| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/shell_dialogs/select_file_dialog.h" | 5 #include "ui/shell_dialogs/select_file_dialog.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/message_loop/message_loop.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 13 #include "ui/shell_dialogs/select_file_dialog_factory.h" | 15 #include "ui/shell_dialogs/select_file_dialog_factory.h" |
| 14 #include "ui/shell_dialogs/select_file_policy.h" | 16 #include "ui/shell_dialogs/select_file_policy.h" |
| 15 #include "ui/shell_dialogs/selected_file_info.h" | 17 #include "ui/shell_dialogs/selected_file_info.h" |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 // Optional dialog factory. Leaked. | 21 // Optional dialog factory. Leaked. |
| 20 ui::SelectFileDialogFactory* dialog_factory_ = NULL; | 22 ui::SelectFileDialogFactory* dialog_factory_ = NULL; |
| 21 | 23 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void* params) { | 85 void* params) { |
| 84 DCHECK(listener_); | 86 DCHECK(listener_); |
| 85 | 87 |
| 86 if (select_file_policy_.get() && | 88 if (select_file_policy_.get() && |
| 87 !select_file_policy_->CanOpenSelectFileDialog()) { | 89 !select_file_policy_->CanOpenSelectFileDialog()) { |
| 88 select_file_policy_->SelectFileDenied(); | 90 select_file_policy_->SelectFileDenied(); |
| 89 | 91 |
| 90 // Inform the listener that no file was selected. | 92 // Inform the listener that no file was selected. |
| 91 // Post a task rather than calling FileSelectionCanceled directly to ensure | 93 // Post a task rather than calling FileSelectionCanceled directly to ensure |
| 92 // that the listener is called asynchronously. | 94 // that the listener is called asynchronously. |
| 93 base::MessageLoop::current()->PostTask( | 95 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 94 FROM_HERE, | 96 FROM_HERE, |
| 95 base::Bind(&SelectFileDialog::CancelFileSelection, this, params)); | 97 base::Bind(&SelectFileDialog::CancelFileSelection, this, params)); |
| 96 return; | 98 return; |
| 97 } | 99 } |
| 98 | 100 |
| 99 // Call the platform specific implementation of the file selection dialog. | 101 // Call the platform specific implementation of the file selection dialog. |
| 100 SelectFileImpl(type, title, default_path, file_types, file_type_index, | 102 SelectFileImpl(type, title, default_path, file_types, file_type_index, |
| 101 default_extension, owning_window, params); | 103 default_extension, owning_window, params); |
| 102 } | 104 } |
| 103 | 105 |
| 104 bool SelectFileDialog::HasMultipleFileTypeChoices() { | 106 bool SelectFileDialog::HasMultipleFileTypeChoices() { |
| 105 return HasMultipleFileTypeChoicesImpl(); | 107 return HasMultipleFileTypeChoicesImpl(); |
| 106 } | 108 } |
| 107 | 109 |
| 108 SelectFileDialog::SelectFileDialog(Listener* listener, | 110 SelectFileDialog::SelectFileDialog(Listener* listener, |
| 109 ui::SelectFilePolicy* policy) | 111 ui::SelectFilePolicy* policy) |
| 110 : listener_(listener), | 112 : listener_(listener), |
| 111 select_file_policy_(policy) { | 113 select_file_policy_(policy) { |
| 112 DCHECK(listener_); | 114 DCHECK(listener_); |
| 113 } | 115 } |
| 114 | 116 |
| 115 SelectFileDialog::~SelectFileDialog() {} | 117 SelectFileDialog::~SelectFileDialog() {} |
| 116 | 118 |
| 117 void SelectFileDialog::CancelFileSelection(void* params) { | 119 void SelectFileDialog::CancelFileSelection(void* params) { |
| 118 if (listener_) | 120 if (listener_) |
| 119 listener_->FileSelectionCanceled(params); | 121 listener_->FileSelectionCanceled(params); |
| 120 } | 122 } |
| 121 | 123 |
| 122 } // namespace ui | 124 } // namespace ui |
| OLD | NEW |