OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/mime_util.h" | 13 #include "base/mime_util.h" |
14 #include "base/thread.h" | 14 #include "base/thread.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/sys_string_conversions.h" | 16 #include "base/sys_string_conversions.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/chrome_thread.h" |
18 #include "chrome/browser/shell_dialogs.h" | 19 #include "chrome/browser/shell_dialogs.h" |
19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
20 | 21 |
21 // The size of the preview we display for selected image files. We set height | 22 // The size of the preview we display for selected image files. We set height |
22 // larger than width because generally there is more free space vertically | 23 // larger than width because generally there is more free space vertically |
23 // than horiztonally (setting the preview image will alway expand the width of | 24 // than horiztonally (setting the preview image will alway expand the width of |
24 // the dialog, but usually not the height). The image's aspect ratio will always | 25 // the dialog, but usually not the height). The image's aspect ratio will always |
25 // be preserved. | 26 // be preserved. |
26 static const int kPreviewWidth = 256; | 27 static const int kPreviewWidth = 256; |
27 static const int kPreviewHeight = 512; | 28 static const int kPreviewHeight = 512; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 std::set<GtkWidget*> dialogs_; | 142 std::set<GtkWidget*> dialogs_; |
142 | 143 |
143 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl); | 144 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl); |
144 }; | 145 }; |
145 | 146 |
146 FilePath* SelectFileDialogImpl::last_saved_path_ = NULL; | 147 FilePath* SelectFileDialogImpl::last_saved_path_ = NULL; |
147 FilePath* SelectFileDialogImpl::last_opened_path_ = NULL; | 148 FilePath* SelectFileDialogImpl::last_opened_path_ = NULL; |
148 | 149 |
149 // static | 150 // static |
150 SelectFileDialog* SelectFileDialog::Create(Listener* listener) { | 151 SelectFileDialog* SelectFileDialog::Create(Listener* listener) { |
151 DCHECK(MessageLoop::current() != | 152 DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::IO)); |
152 g_browser_process->io_thread()->message_loop()); | 153 DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::FILE)); |
153 DCHECK(MessageLoop::current() != | |
154 g_browser_process->file_thread()->message_loop()); | |
155 return new SelectFileDialogImpl(listener); | 154 return new SelectFileDialogImpl(listener); |
156 } | 155 } |
157 | 156 |
158 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener) | 157 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener) |
159 : listener_(listener) { | 158 : listener_(listener) { |
160 if (!last_saved_path_) { | 159 if (!last_saved_path_) { |
161 last_saved_path_ = new FilePath(); | 160 last_saved_path_ = new FilePath(); |
162 last_opened_path_ = new FilePath(); | 161 last_opened_path_ = new FilePath(); |
163 } | 162 } |
164 } | 163 } |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 // This will preserve the image's aspect ratio. | 560 // This will preserve the image's aspect ratio. |
562 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_size(filename, kPreviewWidth, | 561 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_size(filename, kPreviewWidth, |
563 kPreviewHeight, NULL); | 562 kPreviewHeight, NULL); |
564 g_free(filename); | 563 g_free(filename); |
565 if (pixbuf) { | 564 if (pixbuf) { |
566 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->preview_), pixbuf); | 565 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->preview_), pixbuf); |
567 g_object_unref(pixbuf); | 566 g_object_unref(pixbuf); |
568 } | 567 } |
569 gtk_file_chooser_set_preview_widget_active(chooser, pixbuf ? TRUE : FALSE); | 568 gtk_file_chooser_set_preview_widget_active(chooser, pixbuf ? TRUE : FALSE); |
570 } | 569 } |
OLD | NEW |