| 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/select_file_dialog.h" | 5 #include "chrome/browser/ui/select_file_dialog.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/infobars/infobar_tab_helper.h" | 11 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" | 13 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" |
| 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "content/public/common/selected_file_info.h" | 16 #include "content/public/common/selected_file_info.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 | 19 |
| 20 using content::WebContents; | 20 using content::WebContents; |
| 21 | 21 |
| 22 SelectFileDialog::FileTypeInfo::FileTypeInfo() : include_all_files(false) {} | 22 SelectFileDialog::FileTypeInfo::FileTypeInfo() : include_all_files(false) {} |
| 23 | 23 |
| 24 SelectFileDialog::FileTypeInfo::~FileTypeInfo() {} | 24 SelectFileDialog::FileTypeInfo::~FileTypeInfo() {} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 int file_type_index, | 67 int file_type_index, |
| 68 const FilePath::StringType& default_extension, | 68 const FilePath::StringType& default_extension, |
| 69 WebContents* source_contents, | 69 WebContents* source_contents, |
| 70 gfx::NativeWindow owning_window, | 70 gfx::NativeWindow owning_window, |
| 71 void* params) { | 71 void* params) { |
| 72 DCHECK(listener_); | 72 DCHECK(listener_); |
| 73 | 73 |
| 74 if (!CanOpenSelectFileDialog()) { | 74 if (!CanOpenSelectFileDialog()) { |
| 75 // Show the InfoBar saying that file-selection dialogs are disabled. | 75 // Show the InfoBar saying that file-selection dialogs are disabled. |
| 76 if (source_contents) { | 76 if (source_contents) { |
| 77 TabContentsWrapper* wrapper = | 77 TabContents* tab_contents = TabContents::FromWebContents(source_contents); |
| 78 TabContentsWrapper::GetCurrentWrapperForContents(source_contents); | 78 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); |
| 79 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); | |
| 80 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( | 79 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( |
| 81 infobar_helper, | 80 infobar_helper, |
| 82 NULL, | 81 NULL, |
| 83 l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), | 82 l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), |
| 84 true)); | 83 true)); |
| 85 } else { | 84 } else { |
| 86 LOG(WARNING) << "File-selection dialogs are disabled but no WebContents " | 85 LOG(WARNING) << "File-selection dialogs are disabled but no WebContents " |
| 87 << "is given to display the InfoBar."; | 86 << "is given to display the InfoBar."; |
| 88 } | 87 } |
| 89 | 88 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 101 } | 100 } |
| 102 | 101 |
| 103 bool SelectFileDialog::HasMultipleFileTypeChoices() { | 102 bool SelectFileDialog::HasMultipleFileTypeChoices() { |
| 104 return HasMultipleFileTypeChoicesImpl(); | 103 return HasMultipleFileTypeChoicesImpl(); |
| 105 } | 104 } |
| 106 | 105 |
| 107 void SelectFileDialog::CancelFileSelection(void* params) { | 106 void SelectFileDialog::CancelFileSelection(void* params) { |
| 108 if (listener_) | 107 if (listener_) |
| 109 listener_->FileSelectionCanceled(params); | 108 listener_->FileSelectionCanceled(params); |
| 110 } | 109 } |
| OLD | NEW |