| 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 "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h" | 5 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 void SelectFileDialogImplGTK::SelectFileImpl( | 109 void SelectFileDialogImplGTK::SelectFileImpl( |
| 110 Type type, | 110 Type type, |
| 111 const base::string16& title, | 111 const base::string16& title, |
| 112 const base::FilePath& default_path, | 112 const base::FilePath& default_path, |
| 113 const FileTypeInfo* file_types, | 113 const FileTypeInfo* file_types, |
| 114 int file_type_index, | 114 int file_type_index, |
| 115 const base::FilePath::StringType& default_extension, | 115 const base::FilePath::StringType& default_extension, |
| 116 gfx::NativeWindow owning_window, | 116 gfx::NativeWindow owning_window, |
| 117 void* params) { | 117 void* params) { |
| 118 type_ = type; | 118 type_ = type; |
| 119 // |owning_window| can be null when user right-clicks on a downloadable item | |
| 120 // and chooses 'Open Link in New Tab' when 'Ask where to save each file | |
| 121 // before downloading.' preference is turned on. (http://crbug.com/29213) | |
| 122 if (owning_window) { | 119 if (owning_window) { |
| 123 owning_window->AddObserver(this); | 120 owning_window->AddObserver(this); |
| 124 parents_.insert(owning_window); | 121 parents_.insert(owning_window); |
| 125 } | 122 } |
| 126 | 123 |
| 127 std::string title_string = base::UTF16ToUTF8(title); | 124 std::string title_string = base::UTF16ToUTF8(title); |
| 128 | 125 |
| 129 file_type_index_ = file_type_index; | 126 file_type_index_ = file_type_index; |
| 130 if (file_types) | 127 if (file_types) |
| 131 file_types_ = *file_types; | 128 file_types_ = *file_types; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 std::map<GtkWidget*, void*>::iterator iter = params_map_.find(dialog); | 407 std::map<GtkWidget*, void*>::iterator iter = params_map_.find(dialog); |
| 411 DCHECK(iter != params_map_.end()); | 408 DCHECK(iter != params_map_.end()); |
| 412 void* params = iter->second; | 409 void* params = iter->second; |
| 413 params_map_.erase(iter); | 410 params_map_.erase(iter); |
| 414 return params; | 411 return params; |
| 415 } | 412 } |
| 416 | 413 |
| 417 void SelectFileDialogImplGTK::FileDialogDestroyed(GtkWidget* dialog) { | 414 void SelectFileDialogImplGTK::FileDialogDestroyed(GtkWidget* dialog) { |
| 418 dialogs_.erase(dialog); | 415 dialogs_.erase(dialog); |
| 419 | 416 |
| 420 // Parent may be NULL in a few cases: 1) on shutdown when | 417 // |parent| can be NULL when closing the host window |
| 421 // AllBrowsersClosed() trigger this handler after all the browser | 418 // while opening the file-picker. |
| 422 // windows got destroyed, or 2) when the parent tab has been opened by | |
| 423 // 'Open Link in New Tab' context menu on a downloadable item and | |
| 424 // the tab has no content (see the comment in SelectFile as well). | |
| 425 aura::Window* parent = GetAuraTransientParent(dialog); | 419 aura::Window* parent = GetAuraTransientParent(dialog); |
| 426 if (!parent) | 420 if (!parent) |
| 427 return; | 421 return; |
| 428 std::set<aura::Window*>::iterator iter = parents_.find(parent); | 422 std::set<aura::Window*>::iterator iter = parents_.find(parent); |
| 429 if (iter != parents_.end()) { | 423 if (iter != parents_.end()) { |
| 430 (*iter)->RemoveObserver(this); | 424 (*iter)->RemoveObserver(this); |
| 431 parents_.erase(iter); | 425 parents_.erase(iter); |
| 432 } else { | 426 } else { |
| 433 NOTREACHED(); | 427 NOTREACHED(); |
| 434 } | 428 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 g_free(filename); | 535 g_free(filename); |
| 542 if (pixbuf) { | 536 if (pixbuf) { |
| 543 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); | 537 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); |
| 544 g_object_unref(pixbuf); | 538 g_object_unref(pixbuf); |
| 545 } | 539 } |
| 546 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), | 540 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), |
| 547 pixbuf ? TRUE : FALSE); | 541 pixbuf ? TRUE : FALSE); |
| 548 } | 542 } |
| 549 | 543 |
| 550 } // namespace libgtk2ui | 544 } // namespace libgtk2ui |
| OLD | NEW |