| Index: chrome/browser/ui/select_file_dialog.cc
|
| diff --git a/chrome/browser/ui/select_file_dialog.cc b/chrome/browser/ui/select_file_dialog.cc
|
| index 6cb8f7c2289a5d3988449da15e085795450b5cc5..bd2ea9450f195f1adc86435aab5edbff6a35c1f7 100644
|
| --- a/chrome/browser/ui/select_file_dialog.cc
|
| +++ b/chrome/browser/ui/select_file_dialog.cc
|
| @@ -15,6 +15,7 @@
|
| #include "chrome/common/pref_names.h"
|
| #include "grit/generated_resources.h"
|
| #include "ui/base/dialogs/selected_file_info.h"
|
| +#include "ui/base/dialogs/select_file_policy.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
|
|
| using content::WebContents;
|
| @@ -40,51 +41,28 @@ void SelectFileDialog::Listener::MultiFilesSelectedWithExtraInfo(
|
| MultiFilesSelected(file_paths, params);
|
| }
|
|
|
| -SelectFileDialog::SelectFileDialog(Listener* listener)
|
| - : listener_(listener) {
|
| +SelectFileDialog::SelectFileDialog(Listener* listener,
|
| + ui::SelectFilePolicy* policy)
|
| + : listener_(listener),
|
| + select_file_policy_(policy) {
|
| DCHECK(listener_);
|
| }
|
|
|
| SelectFileDialog::~SelectFileDialog() {}
|
|
|
| -bool SelectFileDialog::CanOpenSelectFileDialog() {
|
| - DCHECK(g_browser_process);
|
| -
|
| - // local_state() can return NULL for tests.
|
| - if (!g_browser_process->local_state())
|
| - return false;
|
| -
|
| - return !g_browser_process->local_state()->FindPreference(
|
| - prefs::kAllowFileSelectionDialogs) ||
|
| - g_browser_process->local_state()->GetBoolean(
|
| - prefs::kAllowFileSelectionDialogs);
|
| -}
|
| -
|
| void SelectFileDialog::SelectFile(Type type,
|
| const string16& title,
|
| const FilePath& default_path,
|
| const FileTypeInfo* file_types,
|
| int file_type_index,
|
| const FilePath::StringType& default_extension,
|
| - WebContents* source_contents,
|
| gfx::NativeWindow owning_window,
|
| void* params) {
|
| DCHECK(listener_);
|
|
|
| - if (!CanOpenSelectFileDialog()) {
|
| - // Show the InfoBar saying that file-selection dialogs are disabled.
|
| - if (source_contents) {
|
| - TabContents* tab_contents = TabContents::FromWebContents(source_contents);
|
| - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper();
|
| - infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate(
|
| - infobar_helper,
|
| - NULL,
|
| - l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR),
|
| - true));
|
| - } else {
|
| - LOG(WARNING) << "File-selection dialogs are disabled but no WebContents "
|
| - << "is given to display the InfoBar.";
|
| - }
|
| + if (select_file_policy_.get() &&
|
| + !select_file_policy_->CanOpenSelectFileDialog()) {
|
| + select_file_policy_->SelectFileDenied();
|
|
|
| // Inform the listener that no file was selected.
|
| // Post a task rather than calling FileSelectionCanceled directly to ensure
|
| @@ -94,6 +72,7 @@ void SelectFileDialog::SelectFile(Type type,
|
| params));
|
| return;
|
| }
|
| +
|
| // Call the platform specific implementation of the file selection dialog.
|
| SelectFileImpl(type, title, default_path, file_types, file_type_index,
|
| default_extension, owning_window, params);
|
|
|