OLD | NEW |
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_limiter.h" | 5 #include "chrome/browser/download/download_request_limiter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "chrome/browser/api/infobars/infobar_service.h" | 9 #include "chrome/browser/api/infobars/infobar_service.h" |
10 #include "chrome/browser/download/download_request_infobar_delegate.h" | 10 #include "chrome/browser/download/download_request_infobar_delegate.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // WebContents like those used for extension popups/bubbles and hosted apps | 99 // WebContents like those used for extension popups/bubbles and hosted apps |
100 // etc. | 100 // etc. |
101 // TODO(benjhayden): If this is an automatic download from an extension, | 101 // TODO(benjhayden): If this is an automatic download from an extension, |
102 // it would be convenient for the extension author if we send a message to | 102 // it would be convenient for the extension author if we send a message to |
103 // the extension's DevTools console (as we do for CSP) about how | 103 // the extension's DevTools console (as we do for CSP) about how |
104 // extensions should use chrome.downloads.download() (requires the | 104 // extensions should use chrome.downloads.download() (requires the |
105 // "downloads" permission) to automatically download >1 files. | 105 // "downloads" permission) to automatically download >1 files. |
106 Cancel(); | 106 Cancel(); |
107 return; | 107 return; |
108 } | 108 } |
109 infobar_ = new DownloadRequestInfoBarDelegate(infobar_service, this); | 109 DownloadRequestInfoBarDelegate::Create(infobar_service, this); |
110 infobar_service->AddInfoBar(infobar_); | |
111 } | 110 } |
112 | 111 |
113 void DownloadRequestLimiter::TabDownloadState::Cancel() { | 112 void DownloadRequestLimiter::TabDownloadState::Cancel() { |
114 NotifyCallbacks(false); | 113 NotifyCallbacks(false); |
115 } | 114 } |
116 | 115 |
117 void DownloadRequestLimiter::TabDownloadState::Accept() { | 116 void DownloadRequestLimiter::TabDownloadState::Accept() { |
118 NotifyCallbacks(true); | 117 NotifyCallbacks(true); |
119 } | 118 } |
120 | 119 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 347 |
349 void DownloadRequestLimiter::Remove(TabDownloadState* state) { | 348 void DownloadRequestLimiter::Remove(TabDownloadState* state) { |
350 DCHECK(ContainsKey(state_map_, state->web_contents())); | 349 DCHECK(ContainsKey(state_map_, state->web_contents())); |
351 state_map_.erase(state->web_contents()); | 350 state_map_.erase(state->web_contents()); |
352 delete state; | 351 delete state; |
353 } | 352 } |
354 | 353 |
355 // static | 354 // static |
356 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = | 355 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = |
357 NULL; | 356 NULL; |
OLD | NEW |