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

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

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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) 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/chrome_select_file_policy.h" 5 #include "chrome/browser/ui/chrome_select_file_policy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/api/infobars/infobar_service.h" 10 #include "chrome/browser/api/infobars/infobar_service.h"
(...skipping 11 matching lines...) Expand all
22 22
23 ChromeSelectFilePolicy::~ChromeSelectFilePolicy() {} 23 ChromeSelectFilePolicy::~ChromeSelectFilePolicy() {}
24 24
25 bool ChromeSelectFilePolicy::CanOpenSelectFileDialog() { 25 bool ChromeSelectFilePolicy::CanOpenSelectFileDialog() {
26 return FileSelectDialogsAllowed(); 26 return FileSelectDialogsAllowed();
27 } 27 }
28 28
29 void ChromeSelectFilePolicy::SelectFileDenied() { 29 void ChromeSelectFilePolicy::SelectFileDenied() {
30 // Show the InfoBar saying that file-selection dialogs are disabled. 30 // Show the InfoBar saying that file-selection dialogs are disabled.
31 if (source_contents_) { 31 if (source_contents_) {
32 InfoBarService* infobar_service = 32 SimpleAlertInfoBarDelegate::Create(
33 InfoBarService::FromWebContents(source_contents_); 33 InfoBarService::FromWebContents(source_contents_), NULL,
34 DCHECK(infobar_service); 34 l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), true);
35 infobar_service->AddInfoBar(new SimpleAlertInfoBarDelegate(
36 infobar_service,
37 NULL,
38 l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR),
39 true));
40 } else { 35 } else {
41 LOG(WARNING) << "File-selection dialogs are disabled but no WebContents " 36 LOG(WARNING) << "File-selection dialogs are disabled but no WebContents "
42 << "is given to display the InfoBar."; 37 << "is given to display the InfoBar.";
43 } 38 }
44 } 39 }
45 40
46 // static 41 // static
47 bool ChromeSelectFilePolicy::FileSelectDialogsAllowed() { 42 bool ChromeSelectFilePolicy::FileSelectDialogsAllowed() {
48 DCHECK(g_browser_process); 43 DCHECK(g_browser_process);
49 44
50 // local_state() can return NULL for tests. 45 // local_state() can return NULL for tests.
51 if (!g_browser_process->local_state()) 46 if (!g_browser_process->local_state())
52 return false; 47 return false;
53 48
54 return !g_browser_process->local_state()->FindPreference( 49 return !g_browser_process->local_state()->FindPreference(
55 prefs::kAllowFileSelectionDialogs) || 50 prefs::kAllowFileSelectionDialogs) ||
56 g_browser_process->local_state()->GetBoolean( 51 g_browser_process->local_state()->GetBoolean(
57 prefs::kAllowFileSelectionDialogs); 52 prefs::kAllowFileSelectionDialogs);
58 } 53 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698