| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 const ui::SelectedFileInfo& file, | 48 const ui::SelectedFileInfo& file, |
| 49 int index, | 49 int index, |
| 50 void* params) { | 50 void* params) { |
| 51 // Most of the dialogs need actual local path, so default to it. | 51 // Most of the dialogs need actual local path, so default to it. |
| 52 FileSelected(file.local_path, index, params); | 52 FileSelected(file.local_path, index, params); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void SelectFileDialog::Listener::MultiFilesSelectedWithExtraInfo( | 55 void SelectFileDialog::Listener::MultiFilesSelectedWithExtraInfo( |
| 56 const std::vector<ui::SelectedFileInfo>& files, | 56 const std::vector<ui::SelectedFileInfo>& files, |
| 57 void* params) { | 57 void* params) { |
| 58 std::vector<FilePath> file_paths; | 58 std::vector<base::FilePath> file_paths; |
| 59 for (size_t i = 0; i < files.size(); ++i) | 59 for (size_t i = 0; i < files.size(); ++i) |
| 60 file_paths.push_back(files[i].local_path); | 60 file_paths.push_back(files[i].local_path); |
| 61 | 61 |
| 62 MultiFilesSelected(file_paths, params); | 62 MultiFilesSelected(file_paths, params); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // static | 65 // static |
| 66 void SelectFileDialog::SetFactory(ui::SelectFileDialogFactory* factory) { | 66 void SelectFileDialog::SetFactory(ui::SelectFileDialogFactory* factory) { |
| 67 delete dialog_factory_; | 67 delete dialog_factory_; |
| 68 dialog_factory_ = factory; | 68 dialog_factory_ = factory; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 92 return CreateMacSelectFileDialog(listener, policy); | 92 return CreateMacSelectFileDialog(listener, policy); |
| 93 #elif defined(TOOLKIT_GTK) | 93 #elif defined(TOOLKIT_GTK) |
| 94 return CreateLinuxSelectFileDialog(listener, policy); | 94 return CreateLinuxSelectFileDialog(listener, policy); |
| 95 #elif defined(OS_ANDROID) | 95 #elif defined(OS_ANDROID) |
| 96 return CreateAndroidSelectFileDialog(listener, policy); | 96 return CreateAndroidSelectFileDialog(listener, policy); |
| 97 #endif | 97 #endif |
| 98 | 98 |
| 99 return NULL; | 99 return NULL; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void SelectFileDialog::SelectFile(Type type, | 102 void SelectFileDialog::SelectFile( |
| 103 const string16& title, | 103 Type type, |
| 104 const FilePath& default_path, | 104 const string16& title, |
| 105 const FileTypeInfo* file_types, | 105 const base::FilePath& default_path, |
| 106 int file_type_index, | 106 const FileTypeInfo* file_types, |
| 107 const FilePath::StringType& default_extension, | 107 int file_type_index, |
| 108 gfx::NativeWindow owning_window, | 108 const base::FilePath::StringType& default_extension, |
| 109 void* params) { | 109 gfx::NativeWindow owning_window, |
| 110 void* params) { |
| 110 DCHECK(listener_); | 111 DCHECK(listener_); |
| 111 | 112 |
| 112 if (select_file_policy_.get() && | 113 if (select_file_policy_.get() && |
| 113 !select_file_policy_->CanOpenSelectFileDialog()) { | 114 !select_file_policy_->CanOpenSelectFileDialog()) { |
| 114 select_file_policy_->SelectFileDenied(); | 115 select_file_policy_->SelectFileDenied(); |
| 115 | 116 |
| 116 // Inform the listener that no file was selected. | 117 // Inform the listener that no file was selected. |
| 117 // Post a task rather than calling FileSelectionCanceled directly to ensure | 118 // Post a task rather than calling FileSelectionCanceled directly to ensure |
| 118 // that the listener is called asynchronously. | 119 // that the listener is called asynchronously. |
| 119 MessageLoop::current()->PostTask( | 120 MessageLoop::current()->PostTask( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 148 void SelectFileDialog::CancelFileSelection(void* params) { | 149 void SelectFileDialog::CancelFileSelection(void* params) { |
| 149 if (listener_) | 150 if (listener_) |
| 150 listener_->FileSelectionCanceled(params); | 151 listener_->FileSelectionCanceled(params); |
| 151 } | 152 } |
| 152 | 153 |
| 153 ShellDialogsDelegate* SelectFileDialog::GetShellDialogsDelegate() { | 154 ShellDialogsDelegate* SelectFileDialog::GetShellDialogsDelegate() { |
| 154 return g_shell_dialogs_delegate_; | 155 return g_shell_dialogs_delegate_; |
| 155 } | 156 } |
| 156 | 157 |
| 157 } // namespace ui | 158 } // namespace ui |
| OLD | NEW |