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 <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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 // Notifies the listener that multiple files were chosen. | 107 // Notifies the listener that multiple files were chosen. |
108 void MultiFilesSelected(const std::vector<base::FilePath>& files, | 108 void MultiFilesSelected(const std::vector<base::FilePath>& files, |
109 void* params); | 109 void* params); |
110 | 110 |
111 // Notifies the listener that no file was chosen (the action was canceled). | 111 // Notifies the listener that no file was chosen (the action was canceled). |
112 // Dialog is passed so we can find that |params| pointer that was passed to | 112 // Dialog is passed so we can find that |params| pointer that was passed to |
113 // us when we were told to show the dialog. | 113 // us when we were told to show the dialog. |
114 void FileNotSelected(void *params); | 114 void FileNotSelected(void *params); |
115 | 115 |
116 void CreateSelectFolderDialog(const std::string& title, | 116 void CreateSelectFolderDialog(Type type, |
| 117 const std::string& title, |
117 const base::FilePath& default_path, | 118 const base::FilePath& default_path, |
118 gfx::NativeWindow parent, void* params); | 119 gfx::NativeWindow parent, void* params); |
119 | 120 |
120 void CreateFileOpenDialog(const std::string& title, | 121 void CreateFileOpenDialog(const std::string& title, |
121 const base::FilePath& default_path, | 122 const base::FilePath& default_path, |
122 gfx::NativeWindow parent, void* params); | 123 gfx::NativeWindow parent, void* params); |
123 | 124 |
124 void CreateMultiFileOpenDialog(const std::string& title, | 125 void CreateMultiFileOpenDialog(const std::string& title, |
125 const base::FilePath& default_path, | 126 const base::FilePath& default_path, |
126 gfx::NativeWindow parent, void* params); | 127 gfx::NativeWindow parent, void* params); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 std::string title_string = UTF16ToUTF8(title); | 203 std::string title_string = UTF16ToUTF8(title); |
203 | 204 |
204 file_type_index_ = file_type_index; | 205 file_type_index_ = file_type_index; |
205 if (file_types) | 206 if (file_types) |
206 file_types_ = *file_types; | 207 file_types_ = *file_types; |
207 else | 208 else |
208 file_types_.include_all_files = true; | 209 file_types_.include_all_files = true; |
209 | 210 |
210 switch (type) { | 211 switch (type) { |
211 case SELECT_FOLDER: | 212 case SELECT_FOLDER: |
212 CreateSelectFolderDialog(title_string, default_path, | 213 case SELECT_UPLOAD_FOLDER: |
| 214 CreateSelectFolderDialog(type, title_string, default_path, |
213 owning_window, params); | 215 owning_window, params); |
214 return; | 216 return; |
215 case SELECT_OPEN_FILE: | 217 case SELECT_OPEN_FILE: |
216 CreateFileOpenDialog(title_string, default_path, owning_window, | 218 CreateFileOpenDialog(title_string, default_path, owning_window, |
217 params); | 219 params); |
218 return; | 220 return; |
219 case SELECT_OPEN_MULTI_FILE: | 221 case SELECT_OPEN_MULTI_FILE: |
220 CreateMultiFileOpenDialog(title_string, default_path, | 222 CreateMultiFileOpenDialog(title_string, default_path, |
221 owning_window, params); | 223 owning_window, params); |
222 return; | 224 return; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 if (listener_) | 346 if (listener_) |
345 listener_->MultiFilesSelected(files, params); | 347 listener_->MultiFilesSelected(files, params); |
346 } | 348 } |
347 | 349 |
348 void SelectFileDialogImplKDE::FileNotSelected(void* params) { | 350 void SelectFileDialogImplKDE::FileNotSelected(void* params) { |
349 if (listener_) | 351 if (listener_) |
350 listener_->FileSelectionCanceled(params); | 352 listener_->FileSelectionCanceled(params); |
351 } | 353 } |
352 | 354 |
353 void SelectFileDialogImplKDE::CreateSelectFolderDialog( | 355 void SelectFileDialogImplKDE::CreateSelectFolderDialog( |
354 const std::string& title, const base::FilePath& default_path, | 356 Type type, const std::string& title, const base::FilePath& default_path, |
355 gfx::NativeWindow parent, void *params) { | 357 gfx::NativeWindow parent, void *params) { |
| 358 int title_message_id = (type == SELECT_UPLOAD_FOLDER) |
| 359 ? IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE |
| 360 : IDS_SELECT_FOLDER_DIALOG_TITLE; |
356 BrowserThread::PostTask( | 361 BrowserThread::PostTask( |
357 BrowserThread::FILE, FROM_HERE, | 362 BrowserThread::FILE, FROM_HERE, |
358 base::Bind( | 363 base::Bind( |
359 &SelectFileDialogImplKDE::CallKDialogOutput, | 364 &SelectFileDialogImplKDE::CallKDialogOutput, |
360 this, | 365 this, |
361 KDialogParams( | 366 KDialogParams( |
362 "--getexistingdirectory", | 367 "--getexistingdirectory", |
363 GetTitle(title, IDS_SELECT_FOLDER_DIALOG_TITLE), | 368 GetTitle(title, title_message_id), |
364 default_path.empty() ? *last_opened_path_ : default_path, | 369 default_path.empty() ? *last_opened_path_ : default_path, |
365 parent, false, false, params, | 370 parent, false, false, params, |
366 &SelectFileDialogImplKDE::OnSelectSingleFolderDialogResponse))); | 371 &SelectFileDialogImplKDE::OnSelectSingleFolderDialogResponse))); |
367 } | 372 } |
368 | 373 |
369 void SelectFileDialogImplKDE::CreateFileOpenDialog( | 374 void SelectFileDialogImplKDE::CreateFileOpenDialog( |
370 const std::string& title, const base::FilePath& default_path, | 375 const std::string& title, const base::FilePath& default_path, |
371 gfx::NativeWindow parent, void* params) { | 376 gfx::NativeWindow parent, void* params) { |
372 BrowserThread::PostTask( | 377 BrowserThread::PostTask( |
373 BrowserThread::FILE, FROM_HERE, | 378 BrowserThread::FILE, FROM_HERE, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 } | 473 } |
469 | 474 |
470 if (filenames_fp.empty()) { | 475 if (filenames_fp.empty()) { |
471 FileNotSelected(params); | 476 FileNotSelected(params); |
472 return; | 477 return; |
473 } | 478 } |
474 MultiFilesSelected(filenames_fp, params); | 479 MultiFilesSelected(filenames_fp, params); |
475 } | 480 } |
476 | 481 |
477 } // namespace libgtk2ui | 482 } // namespace libgtk2ui |
OLD | NEW |