OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/select_file_dialog.h" | 5 #include "chrome/browser/ui/select_file_dialog.h" |
6 | 6 |
| 7 #include "base/bind.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/infobars/infobar_tab_helper.h" | 11 #include "chrome/browser/infobars/infobar_tab_helper.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" | 13 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), | 63 l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), |
63 true)); | 64 true)); |
64 } else { | 65 } else { |
65 LOG(WARNING) << "File-selection dialogs are disabled but no TabContents " | 66 LOG(WARNING) << "File-selection dialogs are disabled but no TabContents " |
66 << "is given to display the InfoBar."; | 67 << "is given to display the InfoBar."; |
67 } | 68 } |
68 | 69 |
69 // Inform the listener that no file was selected. | 70 // Inform the listener that no file was selected. |
70 // Post a task rather than calling FileSelectionCanceled directly to ensure | 71 // Post a task rather than calling FileSelectionCanceled directly to ensure |
71 // that the listener is called asynchronously. | 72 // that the listener is called asynchronously. |
72 MessageLoop::current()->PostTask(FROM_HERE, | 73 MessageLoop::current()->PostTask( |
73 NewRunnableMethod( | 74 FROM_HERE, base::Bind(&SelectFileDialog::CancelFileSelection, this, |
74 this, | 75 params)); |
75 &SelectFileDialog::CancelFileSelection, | |
76 params)); | |
77 return; | 76 return; |
78 } | 77 } |
79 // Call the platform specific implementation of the file selection dialog. | 78 // Call the platform specific implementation of the file selection dialog. |
80 SelectFileImpl(type, title, default_path, file_types, file_type_index, | 79 SelectFileImpl(type, title, default_path, file_types, file_type_index, |
81 default_extension, owning_window, params); | 80 default_extension, owning_window, params); |
82 } | 81 } |
83 | 82 |
84 bool SelectFileDialog::HasMultipleFileTypeChoices() { | 83 bool SelectFileDialog::HasMultipleFileTypeChoices() { |
85 return HasMultipleFileTypeChoicesImpl(); | 84 return HasMultipleFileTypeChoicesImpl(); |
86 } | 85 } |
87 | 86 |
88 void SelectFileDialog::CancelFileSelection(void* params) { | 87 void SelectFileDialog::CancelFileSelection(void* params) { |
89 if (listener_) | 88 if (listener_) |
90 listener_->FileSelectionCanceled(params); | 89 listener_->FileSelectionCanceled(params); |
91 } | 90 } |
OLD | NEW |