Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: chrome/browser/ui/shell_dialogs.cc

Issue 7810002: Move infobar handling to a tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/shell_dialogs.h" 5 #include "chrome/browser/ui/shell_dialogs.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/infobars/infobar_tab_helper.h"
10 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" 12 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
13 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
14 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
16 17
17 SelectFileDialog::FileTypeInfo::FileTypeInfo() : include_all_files(false) {} 18 SelectFileDialog::FileTypeInfo::FileTypeInfo() : include_all_files(false) {}
18 19
19 SelectFileDialog::FileTypeInfo::~FileTypeInfo() {} 20 SelectFileDialog::FileTypeInfo::~FileTypeInfo() {}
(...skipping 25 matching lines...) Expand all
45 int file_type_index, 46 int file_type_index,
46 const FilePath::StringType& default_extension, 47 const FilePath::StringType& default_extension,
47 TabContents* source_contents, 48 TabContents* source_contents,
48 gfx::NativeWindow owning_window, 49 gfx::NativeWindow owning_window,
49 void* params) { 50 void* params) {
50 DCHECK(listener_); 51 DCHECK(listener_);
51 52
52 if (!CanOpenSelectFileDialog()) { 53 if (!CanOpenSelectFileDialog()) {
53 // Show the InfoBar saying that file-selection dialogs are disabled. 54 // Show the InfoBar saying that file-selection dialogs are disabled.
54 if (source_contents) { 55 if (source_contents) {
55 TabContentsWrapper* wrapper = 56 TabContentsWrapper* wrapper =
Peter Kasting 2011/08/31 18:47:32 Nit: Combine these two lines
56 TabContentsWrapper::GetCurrentWrapperForContents(source_contents); 57 TabContentsWrapper::GetCurrentWrapperForContents(source_contents);
57 wrapper->AddInfoBar(new SimpleAlertInfoBarDelegate( 58 wrapper->infobar_tab_helper()->AddInfoBar(new SimpleAlertInfoBarDelegate(
58 source_contents, 59 source_contents,
59 NULL, 60 NULL,
60 l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), 61 l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR),
61 true)); 62 true));
62 } else { 63 } else {
63 LOG(WARNING) << "File-selection dialogs are disabled but no TabContents " 64 LOG(WARNING) << "File-selection dialogs are disabled but no TabContents "
64 << "is given to display the InfoBar."; 65 << "is given to display the InfoBar.";
65 } 66 }
66 67
67 // Inform the listener that no file was selected. 68 // Inform the listener that no file was selected.
68 // Post a task rather than calling FileSelectionCanceled directly to ensure 69 // Post a task rather than calling FileSelectionCanceled directly to ensure
69 // that the listener is called asynchronously. 70 // that the listener is called asynchronously.
70 MessageLoop::current()->PostTask(FROM_HERE, 71 MessageLoop::current()->PostTask(FROM_HERE,
71 NewRunnableMethod( 72 NewRunnableMethod(
72 this, 73 this,
73 &SelectFileDialog::CancelFileSelection, 74 &SelectFileDialog::CancelFileSelection,
74 params)); 75 params));
75 return; 76 return;
76 } 77 }
77 // Call the platform specific implementation of the file selection dialog. 78 // Call the platform specific implementation of the file selection dialog.
78 SelectFileImpl(type, title, default_path, file_types, file_type_index, 79 SelectFileImpl(type, title, default_path, file_types, file_type_index,
79 default_extension, owning_window, params); 80 default_extension, owning_window, params);
80 } 81 }
81 82
82 void SelectFileDialog::CancelFileSelection(void* params) { 83 void SelectFileDialog::CancelFileSelection(void* params) {
83 if (listener_) 84 if (listener_)
84 listener_->FileSelectionCanceled(params); 85 listener_->FileSelectionCanceled(params);
85 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698