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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
6 #include <map> | 6 #include <map> |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 class SelectFileDialogImplGTK : public ui::SelectFileDialogImpl { | 40 class SelectFileDialogImplGTK : public ui::SelectFileDialogImpl { |
41 public: | 41 public: |
42 explicit SelectFileDialogImplGTK(Listener* listener, | 42 explicit SelectFileDialogImplGTK(Listener* listener, |
43 ui::SelectFilePolicy* policy); | 43 ui::SelectFilePolicy* policy); |
44 | 44 |
45 protected: | 45 protected: |
46 virtual ~SelectFileDialogImplGTK(); | 46 virtual ~SelectFileDialogImplGTK(); |
47 | 47 |
48 // SelectFileDialog implementation. | 48 // SelectFileDialog implementation. |
49 // |params| is user data we pass back via the Listener interface. | 49 // |params| is user data we pass back via the Listener interface. |
50 virtual void SelectFileImpl(Type type, | 50 virtual void SelectFileImpl( |
51 const string16& title, | 51 Type type, |
52 const FilePath& default_path, | 52 const string16& title, |
53 const FileTypeInfo* file_types, | 53 const base::FilePath& default_path, |
54 int file_type_index, | 54 const FileTypeInfo* file_types, |
55 const FilePath::StringType& default_extension, | 55 int file_type_index, |
56 gfx::NativeWindow owning_window, | 56 const base::FilePath::StringType& default_extension, |
57 void* params) OVERRIDE; | 57 gfx::NativeWindow owning_window, |
| 58 void* params) OVERRIDE; |
58 | 59 |
59 private: | 60 private: |
60 virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE; | 61 virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE; |
61 | 62 |
62 // Add the filters from |file_types_| to |chooser|. | 63 // Add the filters from |file_types_| to |chooser|. |
63 void AddFilters(GtkFileChooser* chooser); | 64 void AddFilters(GtkFileChooser* chooser); |
64 | 65 |
65 // Notifies the listener that a single file was chosen. | 66 // Notifies the listener that a single file was chosen. |
66 void FileSelected(GtkWidget* dialog, const FilePath& path); | 67 void FileSelected(GtkWidget* dialog, const base::FilePath& path); |
67 | 68 |
68 // Notifies the listener that multiple files were chosen. | 69 // Notifies the listener that multiple files were chosen. |
69 void MultiFilesSelected(GtkWidget* dialog, | 70 void MultiFilesSelected(GtkWidget* dialog, |
70 const std::vector<FilePath>& files); | 71 const std::vector<base::FilePath>& files); |
71 | 72 |
72 // Notifies the listener that no file was chosen (the action was canceled). | 73 // Notifies the listener that no file was chosen (the action was canceled). |
73 // Dialog is passed so we can find that |params| pointer that was passed to | 74 // Dialog is passed so we can find that |params| pointer that was passed to |
74 // us when we were told to show the dialog. | 75 // us when we were told to show the dialog. |
75 void FileNotSelected(GtkWidget* dialog); | 76 void FileNotSelected(GtkWidget* dialog); |
76 | 77 |
77 GtkWidget* CreateSelectFolderDialog(const std::string& title, | 78 GtkWidget* CreateSelectFolderDialog(const std::string& title, |
78 const FilePath& default_path, gfx::NativeWindow parent); | 79 const base::FilePath& default_path, gfx::NativeWindow parent); |
79 | 80 |
80 GtkWidget* CreateFileOpenDialog(const std::string& title, | 81 GtkWidget* CreateFileOpenDialog(const std::string& title, |
81 const FilePath& default_path, gfx::NativeWindow parent); | 82 const base::FilePath& default_path, gfx::NativeWindow parent); |
82 | 83 |
83 GtkWidget* CreateMultiFileOpenDialog(const std::string& title, | 84 GtkWidget* CreateMultiFileOpenDialog(const std::string& title, |
84 const FilePath& default_path, gfx::NativeWindow parent); | 85 const base::FilePath& default_path, gfx::NativeWindow parent); |
85 | 86 |
86 GtkWidget* CreateSaveAsDialog(const std::string& title, | 87 GtkWidget* CreateSaveAsDialog(const std::string& title, |
87 const FilePath& default_path, gfx::NativeWindow parent); | 88 const base::FilePath& default_path, gfx::NativeWindow parent); |
88 | 89 |
89 // Removes and returns the |params| associated with |dialog| from | 90 // Removes and returns the |params| associated with |dialog| from |
90 // |params_map_|. | 91 // |params_map_|. |
91 void* PopParamsForDialog(GtkWidget* dialog); | 92 void* PopParamsForDialog(GtkWidget* dialog); |
92 | 93 |
93 // Take care of internal data structures when a file dialog is destroyed. | 94 // Take care of internal data structures when a file dialog is destroyed. |
94 void FileDialogDestroyed(GtkWidget* dialog); | 95 void FileDialogDestroyed(GtkWidget* dialog); |
95 | 96 |
96 // Check whether response_id corresponds to the user cancelling/closing the | 97 // Check whether response_id corresponds to the user cancelling/closing the |
97 // dialog. Used as a helper for the below callbacks. | 98 // dialog. Used as a helper for the below callbacks. |
98 bool IsCancelResponse(gint response_id); | 99 bool IsCancelResponse(gint response_id); |
99 | 100 |
100 // Common function for OnSelectSingleFileDialogResponse and | 101 // Common function for OnSelectSingleFileDialogResponse and |
101 // OnSelectSingleFolderDialogResponse. | 102 // OnSelectSingleFolderDialogResponse. |
102 void SelectSingleFileHelper(GtkWidget* dialog, | 103 void SelectSingleFileHelper(GtkWidget* dialog, |
103 gint response_id, | 104 gint response_id, |
104 bool allow_folder); | 105 bool allow_folder); |
105 | 106 |
106 // Common function for CreateFileOpenDialog and CreateMultiFileOpenDialog. | 107 // Common function for CreateFileOpenDialog and CreateMultiFileOpenDialog. |
107 GtkWidget* CreateFileOpenHelper(const std::string& title, | 108 GtkWidget* CreateFileOpenHelper(const std::string& title, |
108 const FilePath& default_path, | 109 const base::FilePath& default_path, |
109 gfx::NativeWindow parent); | 110 gfx::NativeWindow parent); |
110 | 111 |
111 // Callback for when the user responds to a Save As or Open File dialog. | 112 // Callback for when the user responds to a Save As or Open File dialog. |
112 CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void, | 113 CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void, |
113 OnSelectSingleFileDialogResponse, int); | 114 OnSelectSingleFileDialogResponse, int); |
114 | 115 |
115 // Callback for when the user responds to a Select Folder dialog. | 116 // Callback for when the user responds to a Select Folder dialog. |
116 CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void, | 117 CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void, |
117 OnSelectSingleFolderDialogResponse, int); | 118 OnSelectSingleFolderDialogResponse, int); |
118 | 119 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 160 } |
160 | 161 |
161 bool SelectFileDialogImplGTK::HasMultipleFileTypeChoicesImpl() { | 162 bool SelectFileDialogImplGTK::HasMultipleFileTypeChoicesImpl() { |
162 return file_types_.extensions.size() > 1; | 163 return file_types_.extensions.size() > 1; |
163 } | 164 } |
164 | 165 |
165 // We ignore |default_extension|. | 166 // We ignore |default_extension|. |
166 void SelectFileDialogImplGTK::SelectFileImpl( | 167 void SelectFileDialogImplGTK::SelectFileImpl( |
167 Type type, | 168 Type type, |
168 const string16& title, | 169 const string16& title, |
169 const FilePath& default_path, | 170 const base::FilePath& default_path, |
170 const FileTypeInfo* file_types, | 171 const FileTypeInfo* file_types, |
171 int file_type_index, | 172 int file_type_index, |
172 const FilePath::StringType& default_extension, | 173 const base::FilePath::StringType& default_extension, |
173 gfx::NativeWindow owning_window, | 174 gfx::NativeWindow owning_window, |
174 void* params) { | 175 void* params) { |
175 type_ = type; | 176 type_ = type; |
176 // |owning_window| can be null when user right-clicks on a downloadable item | 177 // |owning_window| can be null when user right-clicks on a downloadable item |
177 // and chooses 'Open Link in New Tab' when 'Ask where to save each file | 178 // and chooses 'Open Link in New Tab' when 'Ask where to save each file |
178 // before downloading.' preference is turned on. (http://crbug.com/29213) | 179 // before downloading.' preference is turned on. (http://crbug.com/29213) |
179 if (owning_window) | 180 if (owning_window) |
180 parents_.insert(owning_window); | 181 parents_.insert(owning_window); |
181 | 182 |
182 std::string title_string = UTF16ToUTF8(title); | 183 std::string title_string = UTF16ToUTF8(title); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 if (file_types_.include_all_files && !file_types_.extensions.empty()) { | 279 if (file_types_.include_all_files && !file_types_.extensions.empty()) { |
279 GtkFileFilter* filter = gtk_file_filter_new(); | 280 GtkFileFilter* filter = gtk_file_filter_new(); |
280 gtk_file_filter_add_pattern(filter, "*"); | 281 gtk_file_filter_add_pattern(filter, "*"); |
281 gtk_file_filter_set_name(filter, | 282 gtk_file_filter_set_name(filter, |
282 l10n_util::GetStringUTF8(IDS_SAVEAS_ALL_FILES).c_str()); | 283 l10n_util::GetStringUTF8(IDS_SAVEAS_ALL_FILES).c_str()); |
283 gtk_file_chooser_add_filter(chooser, filter); | 284 gtk_file_chooser_add_filter(chooser, filter); |
284 } | 285 } |
285 } | 286 } |
286 | 287 |
287 void SelectFileDialogImplGTK::FileSelected(GtkWidget* dialog, | 288 void SelectFileDialogImplGTK::FileSelected(GtkWidget* dialog, |
288 const FilePath& path) { | 289 const base::FilePath& path) { |
289 if (type_ == SELECT_SAVEAS_FILE) | 290 if (type_ == SELECT_SAVEAS_FILE) |
290 *last_saved_path_ = path.DirName(); | 291 *last_saved_path_ = path.DirName(); |
291 else if (type_ == SELECT_OPEN_FILE || type_ == SELECT_FOLDER) | 292 else if (type_ == SELECT_OPEN_FILE || type_ == SELECT_FOLDER) |
292 *last_opened_path_ = path.DirName(); | 293 *last_opened_path_ = path.DirName(); |
293 else | 294 else |
294 NOTREACHED(); | 295 NOTREACHED(); |
295 | 296 |
296 if (listener_) { | 297 if (listener_) { |
297 GtkFileFilter* selected_filter = | 298 GtkFileFilter* selected_filter = |
298 gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(dialog)); | 299 gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(dialog)); |
299 GSList* filters = gtk_file_chooser_list_filters(GTK_FILE_CHOOSER(dialog)); | 300 GSList* filters = gtk_file_chooser_list_filters(GTK_FILE_CHOOSER(dialog)); |
300 int idx = g_slist_index(filters, selected_filter); | 301 int idx = g_slist_index(filters, selected_filter); |
301 g_slist_free(filters); | 302 g_slist_free(filters); |
302 listener_->FileSelected(path, idx + 1, PopParamsForDialog(dialog)); | 303 listener_->FileSelected(path, idx + 1, PopParamsForDialog(dialog)); |
303 } | 304 } |
304 gtk_widget_destroy(dialog); | 305 gtk_widget_destroy(dialog); |
305 } | 306 } |
306 | 307 |
307 void SelectFileDialogImplGTK::MultiFilesSelected(GtkWidget* dialog, | 308 void SelectFileDialogImplGTK::MultiFilesSelected(GtkWidget* dialog, |
308 const std::vector<FilePath>& files) { | 309 const std::vector<base::FilePath>& files) { |
309 *last_opened_path_ = files[0].DirName(); | 310 *last_opened_path_ = files[0].DirName(); |
310 | 311 |
311 if (listener_) | 312 if (listener_) |
312 listener_->MultiFilesSelected(files, PopParamsForDialog(dialog)); | 313 listener_->MultiFilesSelected(files, PopParamsForDialog(dialog)); |
313 gtk_widget_destroy(dialog); | 314 gtk_widget_destroy(dialog); |
314 } | 315 } |
315 | 316 |
316 void SelectFileDialogImplGTK::FileNotSelected(GtkWidget* dialog) { | 317 void SelectFileDialogImplGTK::FileNotSelected(GtkWidget* dialog) { |
317 void* params = PopParamsForDialog(dialog); | 318 void* params = PopParamsForDialog(dialog); |
318 if (listener_) | 319 if (listener_) |
319 listener_->FileSelectionCanceled(params); | 320 listener_->FileSelectionCanceled(params); |
320 gtk_widget_destroy(dialog); | 321 gtk_widget_destroy(dialog); |
321 } | 322 } |
322 | 323 |
323 GtkWidget* SelectFileDialogImplGTK::CreateFileOpenHelper( | 324 GtkWidget* SelectFileDialogImplGTK::CreateFileOpenHelper( |
324 const std::string& title, | 325 const std::string& title, |
325 const FilePath& default_path, | 326 const base::FilePath& default_path, |
326 gfx::NativeWindow parent) { | 327 gfx::NativeWindow parent) { |
327 GtkWidget* dialog = | 328 GtkWidget* dialog = |
328 gtk_file_chooser_dialog_new(title.c_str(), parent, | 329 gtk_file_chooser_dialog_new(title.c_str(), parent, |
329 GTK_FILE_CHOOSER_ACTION_OPEN, | 330 GTK_FILE_CHOOSER_ACTION_OPEN, |
330 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | 331 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
331 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, | 332 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, |
332 NULL); | 333 NULL); |
333 AddFilters(GTK_FILE_CHOOSER(dialog)); | 334 AddFilters(GTK_FILE_CHOOSER(dialog)); |
334 | 335 |
335 if (!default_path.empty()) { | 336 if (!default_path.empty()) { |
336 if (CallDirectoryExistsOnUIThread(default_path)) { | 337 if (CallDirectoryExistsOnUIThread(default_path)) { |
337 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | 338 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
338 default_path.value().c_str()); | 339 default_path.value().c_str()); |
339 } else { | 340 } else { |
340 // If the file doesn't exist, this will just switch to the correct | 341 // If the file doesn't exist, this will just switch to the correct |
341 // directory. That's good enough. | 342 // directory. That's good enough. |
342 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | 343 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), |
343 default_path.value().c_str()); | 344 default_path.value().c_str()); |
344 } | 345 } |
345 } else if (!last_opened_path_->empty()) { | 346 } else if (!last_opened_path_->empty()) { |
346 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | 347 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
347 last_opened_path_->value().c_str()); | 348 last_opened_path_->value().c_str()); |
348 } | 349 } |
349 return dialog; | 350 return dialog; |
350 } | 351 } |
351 | 352 |
352 GtkWidget* SelectFileDialogImplGTK::CreateSelectFolderDialog( | 353 GtkWidget* SelectFileDialogImplGTK::CreateSelectFolderDialog( |
353 const std::string& title, | 354 const std::string& title, |
354 const FilePath& default_path, | 355 const base::FilePath& default_path, |
355 gfx::NativeWindow parent) { | 356 gfx::NativeWindow parent) { |
356 std::string title_string = !title.empty() ? title : | 357 std::string title_string = !title.empty() ? title : |
357 l10n_util::GetStringUTF8(IDS_SELECT_FOLDER_DIALOG_TITLE); | 358 l10n_util::GetStringUTF8(IDS_SELECT_FOLDER_DIALOG_TITLE); |
358 | 359 |
359 GtkWidget* dialog = | 360 GtkWidget* dialog = |
360 gtk_file_chooser_dialog_new(title_string.c_str(), parent, | 361 gtk_file_chooser_dialog_new(title_string.c_str(), parent, |
361 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, | 362 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, |
362 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | 363 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
363 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, | 364 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, |
364 NULL); | 365 NULL); |
365 | 366 |
366 if (!default_path.empty()) { | 367 if (!default_path.empty()) { |
367 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | 368 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), |
368 default_path.value().c_str()); | 369 default_path.value().c_str()); |
369 } else if (!last_opened_path_->empty()) { | 370 } else if (!last_opened_path_->empty()) { |
370 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | 371 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
371 last_opened_path_->value().c_str()); | 372 last_opened_path_->value().c_str()); |
372 } | 373 } |
373 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); | 374 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); |
374 g_signal_connect(dialog, "response", | 375 g_signal_connect(dialog, "response", |
375 G_CALLBACK(OnSelectSingleFolderDialogResponseThunk), this); | 376 G_CALLBACK(OnSelectSingleFolderDialogResponseThunk), this); |
376 return dialog; | 377 return dialog; |
377 } | 378 } |
378 | 379 |
379 GtkWidget* SelectFileDialogImplGTK::CreateFileOpenDialog( | 380 GtkWidget* SelectFileDialogImplGTK::CreateFileOpenDialog( |
380 const std::string& title, | 381 const std::string& title, |
381 const FilePath& default_path, | 382 const base::FilePath& default_path, |
382 gfx::NativeWindow parent) { | 383 gfx::NativeWindow parent) { |
383 std::string title_string = !title.empty() ? title : | 384 std::string title_string = !title.empty() ? title : |
384 l10n_util::GetStringUTF8(IDS_OPEN_FILE_DIALOG_TITLE); | 385 l10n_util::GetStringUTF8(IDS_OPEN_FILE_DIALOG_TITLE); |
385 | 386 |
386 GtkWidget* dialog = CreateFileOpenHelper(title_string, default_path, parent); | 387 GtkWidget* dialog = CreateFileOpenHelper(title_string, default_path, parent); |
387 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); | 388 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); |
388 g_signal_connect(dialog, "response", | 389 g_signal_connect(dialog, "response", |
389 G_CALLBACK(OnSelectSingleFileDialogResponseThunk), this); | 390 G_CALLBACK(OnSelectSingleFileDialogResponseThunk), this); |
390 return dialog; | 391 return dialog; |
391 } | 392 } |
392 | 393 |
393 GtkWidget* SelectFileDialogImplGTK::CreateMultiFileOpenDialog( | 394 GtkWidget* SelectFileDialogImplGTK::CreateMultiFileOpenDialog( |
394 const std::string& title, | 395 const std::string& title, |
395 const FilePath& default_path, | 396 const base::FilePath& default_path, |
396 gfx::NativeWindow parent) { | 397 gfx::NativeWindow parent) { |
397 std::string title_string = !title.empty() ? title : | 398 std::string title_string = !title.empty() ? title : |
398 l10n_util::GetStringUTF8(IDS_OPEN_FILES_DIALOG_TITLE); | 399 l10n_util::GetStringUTF8(IDS_OPEN_FILES_DIALOG_TITLE); |
399 | 400 |
400 GtkWidget* dialog = CreateFileOpenHelper(title_string, default_path, parent); | 401 GtkWidget* dialog = CreateFileOpenHelper(title_string, default_path, parent); |
401 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); | 402 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); |
402 g_signal_connect(dialog, "response", | 403 g_signal_connect(dialog, "response", |
403 G_CALLBACK(OnSelectMultiFileDialogResponseThunk), this); | 404 G_CALLBACK(OnSelectMultiFileDialogResponseThunk), this); |
404 return dialog; | 405 return dialog; |
405 } | 406 } |
406 | 407 |
407 GtkWidget* SelectFileDialogImplGTK::CreateSaveAsDialog(const std::string& title, | 408 GtkWidget* SelectFileDialogImplGTK::CreateSaveAsDialog(const std::string& title, |
408 const FilePath& default_path, gfx::NativeWindow parent) { | 409 const base::FilePath& default_path, gfx::NativeWindow parent) { |
409 std::string title_string = !title.empty() ? title : | 410 std::string title_string = !title.empty() ? title : |
410 l10n_util::GetStringUTF8(IDS_SAVE_AS_DIALOG_TITLE); | 411 l10n_util::GetStringUTF8(IDS_SAVE_AS_DIALOG_TITLE); |
411 | 412 |
412 GtkWidget* dialog = | 413 GtkWidget* dialog = |
413 gtk_file_chooser_dialog_new(title_string.c_str(), parent, | 414 gtk_file_chooser_dialog_new(title_string.c_str(), parent, |
414 GTK_FILE_CHOOSER_ACTION_SAVE, | 415 GTK_FILE_CHOOSER_ACTION_SAVE, |
415 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | 416 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
416 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, | 417 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
417 NULL); | 418 NULL); |
418 | 419 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 FileNotSelected(dialog); | 487 FileNotSelected(dialog); |
487 return; | 488 return; |
488 } | 489 } |
489 | 490 |
490 gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | 491 gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
491 if (!filename) { | 492 if (!filename) { |
492 FileNotSelected(dialog); | 493 FileNotSelected(dialog); |
493 return; | 494 return; |
494 } | 495 } |
495 | 496 |
496 FilePath path(filename); | 497 base::FilePath path(filename); |
497 g_free(filename); | 498 g_free(filename); |
498 | 499 |
499 if (allow_folder) { | 500 if (allow_folder) { |
500 FileSelected(dialog, path); | 501 FileSelected(dialog, path); |
501 return; | 502 return; |
502 } | 503 } |
503 | 504 |
504 if (CallDirectoryExistsOnUIThread(path)) | 505 if (CallDirectoryExistsOnUIThread(path)) |
505 FileNotSelected(dialog); | 506 FileNotSelected(dialog); |
506 else | 507 else |
(...skipping 16 matching lines...) Expand all Loading... |
523 FileNotSelected(dialog); | 524 FileNotSelected(dialog); |
524 return; | 525 return; |
525 } | 526 } |
526 | 527 |
527 GSList* filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); | 528 GSList* filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); |
528 if (!filenames) { | 529 if (!filenames) { |
529 FileNotSelected(dialog); | 530 FileNotSelected(dialog); |
530 return; | 531 return; |
531 } | 532 } |
532 | 533 |
533 std::vector<FilePath> filenames_fp; | 534 std::vector<base::FilePath> filenames_fp; |
534 for (GSList* iter = filenames; iter != NULL; iter = g_slist_next(iter)) { | 535 for (GSList* iter = filenames; iter != NULL; iter = g_slist_next(iter)) { |
535 FilePath path(static_cast<char*>(iter->data)); | 536 base::FilePath path(static_cast<char*>(iter->data)); |
536 g_free(iter->data); | 537 g_free(iter->data); |
537 if (CallDirectoryExistsOnUIThread(path)) | 538 if (CallDirectoryExistsOnUIThread(path)) |
538 continue; | 539 continue; |
539 filenames_fp.push_back(path); | 540 filenames_fp.push_back(path); |
540 } | 541 } |
541 g_slist_free(filenames); | 542 g_slist_free(filenames); |
542 | 543 |
543 if (filenames_fp.empty()) { | 544 if (filenames_fp.empty()) { |
544 FileNotSelected(dialog); | 545 FileNotSelected(dialog); |
545 return; | 546 return; |
(...skipping 25 matching lines...) Expand all Loading... |
571 } // namespace | 572 } // namespace |
572 | 573 |
573 namespace ui { | 574 namespace ui { |
574 | 575 |
575 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplGTK( | 576 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplGTK( |
576 Listener* listener, ui::SelectFilePolicy* policy) { | 577 Listener* listener, ui::SelectFilePolicy* policy) { |
577 return new SelectFileDialogImplGTK(listener, policy); | 578 return new SelectFileDialogImplGTK(listener, policy); |
578 } | 579 } |
579 | 580 |
580 } // namespace ui | 581 } // namespace ui |
OLD | NEW |