| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 // Notifies the listener that multiple files were chosen. | 114 // Notifies the listener that multiple files were chosen. |
| 115 void MultiFilesSelected(const std::vector<base::FilePath>& files, | 115 void MultiFilesSelected(const std::vector<base::FilePath>& files, |
| 116 void* params); | 116 void* params); |
| 117 | 117 |
| 118 // Notifies the listener that no file was chosen (the action was canceled). | 118 // Notifies the listener that no file was chosen (the action was canceled). |
| 119 // Dialog is passed so we can find that |params| pointer that was passed to | 119 // Dialog is passed so we can find that |params| pointer that was passed to |
| 120 // us when we were told to show the dialog. | 120 // us when we were told to show the dialog. |
| 121 void FileNotSelected(void *params); | 121 void FileNotSelected(void *params); |
| 122 | 122 |
| 123 void CreateSelectFolderDialog(const std::string& title, | 123 void CreateSelectFolderDialog(Type type, |
| 124 const std::string& title, |
| 124 const base::FilePath& default_path, | 125 const base::FilePath& default_path, |
| 125 gfx::NativeWindow parent, void* params); | 126 gfx::NativeWindow parent, void* params); |
| 126 | 127 |
| 127 void CreateFileOpenDialog(const std::string& title, | 128 void CreateFileOpenDialog(const std::string& title, |
| 128 const base::FilePath& default_path, | 129 const base::FilePath& default_path, |
| 129 gfx::NativeWindow parent, void* params); | 130 gfx::NativeWindow parent, void* params); |
| 130 | 131 |
| 131 void CreateMultiFileOpenDialog(const std::string& title, | 132 void CreateMultiFileOpenDialog(const std::string& title, |
| 132 const base::FilePath& default_path, | 133 const base::FilePath& default_path, |
| 133 gfx::NativeWindow parent, void* params); | 134 gfx::NativeWindow parent, void* params); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 std::string title_string = UTF16ToUTF8(title); | 188 std::string title_string = UTF16ToUTF8(title); |
| 188 | 189 |
| 189 file_type_index_ = file_type_index; | 190 file_type_index_ = file_type_index; |
| 190 if (file_types) | 191 if (file_types) |
| 191 file_types_ = *file_types; | 192 file_types_ = *file_types; |
| 192 else | 193 else |
| 193 file_types_.include_all_files = true; | 194 file_types_.include_all_files = true; |
| 194 | 195 |
| 195 switch (type) { | 196 switch (type) { |
| 196 case SELECT_FOLDER: | 197 case SELECT_FOLDER: |
| 197 CreateSelectFolderDialog(title_string, default_path, | 198 case SELECT_UPLOAD_FOLDER: |
| 199 CreateSelectFolderDialog(type, title_string, default_path, |
| 198 owning_window, params); | 200 owning_window, params); |
| 199 return; | 201 return; |
| 200 case SELECT_OPEN_FILE: | 202 case SELECT_OPEN_FILE: |
| 201 CreateFileOpenDialog(title_string, default_path, owning_window, | 203 CreateFileOpenDialog(title_string, default_path, owning_window, |
| 202 params); | 204 params); |
| 203 return; | 205 return; |
| 204 case SELECT_OPEN_MULTI_FILE: | 206 case SELECT_OPEN_MULTI_FILE: |
| 205 CreateMultiFileOpenDialog(title_string, default_path, | 207 CreateMultiFileOpenDialog(title_string, default_path, |
| 206 owning_window, params); | 208 owning_window, params); |
| 207 return; | 209 return; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 if (listener_) | 326 if (listener_) |
| 325 listener_->MultiFilesSelected(files, params); | 327 listener_->MultiFilesSelected(files, params); |
| 326 } | 328 } |
| 327 | 329 |
| 328 void SelectFileDialogImplKDE::FileNotSelected(void* params) { | 330 void SelectFileDialogImplKDE::FileNotSelected(void* params) { |
| 329 if (listener_) | 331 if (listener_) |
| 330 listener_->FileSelectionCanceled(params); | 332 listener_->FileSelectionCanceled(params); |
| 331 } | 333 } |
| 332 | 334 |
| 333 void SelectFileDialogImplKDE::CreateSelectFolderDialog( | 335 void SelectFileDialogImplKDE::CreateSelectFolderDialog( |
| 334 const std::string& title, const base::FilePath& default_path, | 336 Type type, const std::string& title, const base::FilePath& default_path, |
| 335 gfx::NativeWindow parent, void *params) { | 337 gfx::NativeWindow parent, void *params) { |
| 338 int title_message_id = (type == SELECT_UPLOAD_FOLDER) ? |
| 339 IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE : |
| 340 IDS_SELECT_FOLDER_DIALOG_TITLE; |
| 336 base::WorkerPool::PostTask(FROM_HERE, | 341 base::WorkerPool::PostTask(FROM_HERE, |
| 337 base::Bind( | 342 base::Bind( |
| 338 &SelectFileDialogImplKDE::CallKDialogOutput, | 343 &SelectFileDialogImplKDE::CallKDialogOutput, |
| 339 this, | 344 this, |
| 340 KDialogParams( | 345 KDialogParams( |
| 341 "--getexistingdirectory", | 346 "--getexistingdirectory", |
| 342 GetTitle(title, IDS_SELECT_FOLDER_DIALOG_TITLE), | 347 GetTitle(title, title_message_id), |
| 343 default_path.empty() ? *last_opened_path_ : default_path, | 348 default_path.empty() ? *last_opened_path_ : default_path, |
| 344 parent, false, false, params, | 349 parent, false, false, params, |
| 345 &SelectFileDialogImplKDE::OnSelectSingleFolderDialogResponse)), | 350 &SelectFileDialogImplKDE::OnSelectSingleFolderDialogResponse)), |
| 346 true); | 351 true); |
| 347 } | 352 } |
| 348 | 353 |
| 349 void SelectFileDialogImplKDE::CreateFileOpenDialog( | 354 void SelectFileDialogImplKDE::CreateFileOpenDialog( |
| 350 const std::string& title, const base::FilePath& default_path, | 355 const std::string& title, const base::FilePath& default_path, |
| 351 gfx::NativeWindow parent, void* params) { | 356 gfx::NativeWindow parent, void* params) { |
| 352 base::WorkerPool::PostTask(FROM_HERE, | 357 base::WorkerPool::PostTask(FROM_HERE, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 | 476 |
| 472 // static | 477 // static |
| 473 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplKDE( | 478 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplKDE( |
| 474 Listener* listener, | 479 Listener* listener, |
| 475 ui::SelectFilePolicy* policy, | 480 ui::SelectFilePolicy* policy, |
| 476 base::nix::DesktopEnvironment desktop) { | 481 base::nix::DesktopEnvironment desktop) { |
| 477 return new SelectFileDialogImplKDE(listener, policy, desktop); | 482 return new SelectFileDialogImplKDE(listener, policy, desktop); |
| 478 } | 483 } |
| 479 | 484 |
| 480 } // namespace ui | 485 } // namespace ui |
| 481 | |
| OLD | NEW |