OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_permission_request.h" | 5 #include "chrome/browser/download/download_permission_request.h" |
6 | 6 |
| 7 #include "content/public/browser/web_contents.h" |
7 #include "grit/generated_resources.h" | 8 #include "grit/generated_resources.h" |
8 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
9 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
10 | 11 |
11 DownloadPermissionRequest::DownloadPermissionRequest( | 12 DownloadPermissionRequest::DownloadPermissionRequest( |
12 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) | 13 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) |
13 : host_(host) {} | 14 : host_(host) {} |
14 | 15 |
15 DownloadPermissionRequest::~DownloadPermissionRequest() {} | 16 DownloadPermissionRequest::~DownloadPermissionRequest() {} |
16 | 17 |
| 18 int DownloadPermissionRequest::GetIconID() const { |
| 19 return IDR_INFOBAR_MULTIPLE_DOWNLOADS; |
| 20 } |
| 21 |
17 base::string16 DownloadPermissionRequest::GetMessageText() const { | 22 base::string16 DownloadPermissionRequest::GetMessageText() const { |
18 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); | 23 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); |
19 } | 24 } |
20 | 25 |
21 base::string16 DownloadPermissionRequest::GetMessageTextFragment() const { | 26 base::string16 DownloadPermissionRequest::GetMessageTextFragment() const { |
22 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_PERMISSION_FRAGMENT); | 27 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_PERMISSION_FRAGMENT); |
23 } | 28 } |
24 | 29 |
25 base::string16 DownloadPermissionRequest::GetAlternateAcceptButtonText() const { | 30 bool DownloadPermissionRequest::HasUserGesture() const { |
26 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING_ALLOW); | 31 // TODO(gbillock): user gesture for multiple downloads is difficult to |
| 32 // propagate, and the normal thing is that it is background. |
| 33 return false; |
27 } | 34 } |
28 | 35 |
29 base::string16 DownloadPermissionRequest::GetAlternateDenyButtonText() const { | 36 GURL DownloadPermissionRequest::GetRequestingHostname() const { |
30 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING_DENY); | 37 const content::WebContents* web_contents = host_->web_contents(); |
| 38 if (web_contents) { |
| 39 return web_contents->GetURL(); |
| 40 } |
| 41 return GURL(); |
31 } | 42 } |
32 | 43 |
33 void DownloadPermissionRequest::PermissionGranted() { | 44 void DownloadPermissionRequest::PermissionGranted() { |
34 if (host_) { | 45 if (host_) { |
35 // This may invalidate |host_|. | 46 // This may invalidate |host_|. |
36 host_->Accept(); | 47 host_->Accept(); |
37 } | 48 } |
38 } | 49 } |
39 | 50 |
40 void DownloadPermissionRequest::PermissionDenied() { | 51 void DownloadPermissionRequest::PermissionDenied() { |
41 if (host_) { | 52 if (host_) { |
42 // This may invalidate |host_|. | 53 // This may invalidate |host_|. |
43 host_->Cancel(); | 54 host_->Cancel(); |
44 } | 55 } |
45 } | 56 } |
46 | 57 |
47 void DownloadPermissionRequest::Cancelled() { | 58 void DownloadPermissionRequest::Cancelled() { |
48 // TODO(gbillock): There's currently no suitable method for telling the host | 59 // TODO(gbillock): There's currently no suitable method for telling the host |
49 // that a request is cancelled. | 60 // that a request is cancelled. |
50 } | 61 } |
51 | 62 |
52 void DownloadPermissionRequest::RequestFinished() { | 63 void DownloadPermissionRequest::RequestFinished() { |
53 delete this; | 64 delete this; |
54 } | 65 } |
OLD | NEW |