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

Side by Side Diff: chrome/browser/download/download_request_infobar_delegate_android.cc

Issue 1392023004: Rename android only infobars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try again Created 5 years, 2 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
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/download/download_request_infobar_delegate.h" 5 #include "chrome/browser/download/download_request_infobar_delegate_android.h"
6 6
7 #include "chrome/browser/infobars/infobar_service.h" 7 #include "chrome/browser/infobars/infobar_service.h"
8 #include "chrome/grit/generated_resources.h" 8 #include "chrome/grit/generated_resources.h"
9 #include "components/infobars/core/infobar.h" 9 #include "components/infobars/core/infobar.h"
10 #include "grit/theme_resources.h" 10 #include "grit/theme_resources.h"
11 #include "ui/base/l10n/l10n_util.h" 11 #include "ui/base/l10n/l10n_util.h"
12 12
13 DownloadRequestInfoBarDelegate::FakeCreateCallback* 13 DownloadRequestInfoBarDelegateAndroid::FakeCreateCallback*
14 DownloadRequestInfoBarDelegate::callback_ = NULL; 14 DownloadRequestInfoBarDelegateAndroid::callback_ = NULL;
15 15
16 DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() { 16 DownloadRequestInfoBarDelegateAndroid::
17 ~DownloadRequestInfoBarDelegateAndroid() {
17 if (!responded_ && host_) 18 if (!responded_ && host_)
18 host_->CancelOnce(); 19 host_->CancelOnce();
19 } 20 }
20 21
21 // static 22 // static
22 void DownloadRequestInfoBarDelegate::Create( 23 void DownloadRequestInfoBarDelegateAndroid::Create(
23 InfoBarService* infobar_service, 24 InfoBarService* infobar_service,
24 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) { 25 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) {
25 if (DownloadRequestInfoBarDelegate::callback_ && 26 if (DownloadRequestInfoBarDelegateAndroid::callback_ &&
26 !DownloadRequestInfoBarDelegate::callback_->is_null()) { 27 !DownloadRequestInfoBarDelegateAndroid::callback_->is_null()) {
27 DownloadRequestInfoBarDelegate::callback_->Run(infobar_service, host); 28 DownloadRequestInfoBarDelegateAndroid::callback_->Run(infobar_service,
29 host);
28 } else if (!infobar_service) { 30 } else if (!infobar_service) {
29 // |web_contents| may not have a InfoBarService if it's actually a 31 // |web_contents| may not have a InfoBarService if it's actually a
30 // WebContents like those used for extension popups/bubbles and hosted apps 32 // WebContents like those used for extension popups/bubbles and hosted apps
31 // etc. 33 // etc.
32 // TODO(benjhayden): If this is an automatic download from an extension, 34 // TODO(benjhayden): If this is an automatic download from an extension,
33 // it would be convenient for the extension author if we send a message to 35 // it would be convenient for the extension author if we send a message to
34 // the extension's DevTools console (as we do for CSP) about how 36 // the extension's DevTools console (as we do for CSP) about how
35 // extensions should use chrome.downloads.download() (requires the 37 // extensions should use chrome.downloads.download() (requires the
36 // "downloads" permission) to automatically download >1 files. 38 // "downloads" permission) to automatically download >1 files.
37 host->Cancel(); 39 host->Cancel();
38 } else { 40 } else {
39 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( 41 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
40 scoped_ptr<ConfirmInfoBarDelegate>( 42 scoped_ptr<ConfirmInfoBarDelegate>(
41 new DownloadRequestInfoBarDelegate(host)))); 43 new DownloadRequestInfoBarDelegateAndroid(host))));
42 } 44 }
43 } 45 }
44 46
45 // static 47 // static
46 void DownloadRequestInfoBarDelegate::SetCallbackForTesting( 48 void DownloadRequestInfoBarDelegateAndroid::SetCallbackForTesting(
47 FakeCreateCallback* callback) { 49 FakeCreateCallback* callback) {
48 DownloadRequestInfoBarDelegate::callback_ = callback; 50 DownloadRequestInfoBarDelegateAndroid::callback_ = callback;
49 } 51 }
50 52
51 DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate( 53 DownloadRequestInfoBarDelegateAndroid::DownloadRequestInfoBarDelegateAndroid(
52 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) 54 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host)
53 : ConfirmInfoBarDelegate(), 55 : ConfirmInfoBarDelegate(), responded_(false), host_(host) {}
54 responded_(false),
55 host_(host) {
56 }
57 56
58 int DownloadRequestInfoBarDelegate::GetIconId() const { 57 int DownloadRequestInfoBarDelegateAndroid::GetIconId() const {
59 return IDR_INFOBAR_MULTIPLE_DOWNLOADS; 58 return IDR_INFOBAR_MULTIPLE_DOWNLOADS;
60 } 59 }
61 60
62 base::string16 DownloadRequestInfoBarDelegate::GetMessageText() const { 61 base::string16 DownloadRequestInfoBarDelegateAndroid::GetMessageText() const {
63 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); 62 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING);
64 } 63 }
65 64
66 base::string16 DownloadRequestInfoBarDelegate::GetButtonLabel( 65 base::string16 DownloadRequestInfoBarDelegateAndroid::GetButtonLabel(
67 InfoBarButton button) const { 66 InfoBarButton button) const {
68 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 67 return l10n_util::GetStringUTF16((button == BUTTON_OK)
69 IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_BLOCK); 68 ? IDS_MULTI_DOWNLOAD_WARNING_ALLOW
69 : IDS_MULTI_DOWNLOAD_WARNING_BLOCK);
70 } 70 }
71 71
72 bool DownloadRequestInfoBarDelegate::Accept() { 72 bool DownloadRequestInfoBarDelegateAndroid::Accept() {
73 DCHECK(!responded_); 73 DCHECK(!responded_);
74 responded_ = true; 74 responded_ = true;
75 if (host_) { 75 if (host_) {
76 // This may invalidate |host_|. 76 // This may invalidate |host_|.
77 host_->Accept(); 77 host_->Accept();
78 } 78 }
79 return !host_; 79 return !host_;
80 } 80 }
81 81
82 bool DownloadRequestInfoBarDelegate::Cancel() { 82 bool DownloadRequestInfoBarDelegateAndroid::Cancel() {
83 DCHECK(!responded_); 83 DCHECK(!responded_);
84 responded_ = true; 84 responded_ = true;
85 if (host_) { 85 if (host_) {
86 // This may invalidate |host_|. 86 // This may invalidate |host_|.
87 host_->Cancel(); 87 host_->Cancel();
88 } 88 }
89 return !host_; 89 return !host_;
90 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698