Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/download/download_request_limiter.h" | 5 #include "chrome/browser/download/download_request_limiter.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "chrome/browser/download/download_request_infobar_delegate.h" | 8 #include "chrome/browser/download/download_request_infobar_delegate.h" |
| 9 #include "chrome/browser/infobars/infobar_tab_helper.h" | |
| 9 #include "chrome/browser/tab_contents/tab_util.h" | 10 #include "chrome/browser/tab_contents/tab_util.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 11 #include "content/browser/browser_thread.h" | 12 #include "content/browser/browser_thread.h" |
| 12 #include "content/browser/tab_contents/navigation_controller.h" | 13 #include "content/browser/tab_contents/navigation_controller.h" |
| 13 #include "content/browser/tab_contents/navigation_entry.h" | 14 #include "content/browser/tab_contents/navigation_entry.h" |
| 14 #include "content/browser/tab_contents/tab_contents.h" | 15 #include "content/browser/tab_contents/tab_contents.h" |
| 15 #include "content/browser/tab_contents/tab_contents_delegate.h" | 16 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 16 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 17 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 17 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h" | 18 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h" |
| 18 #include "content/common/notification_source.h" | 19 #include "content/common/notification_source.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 DownloadRequestLimiter::Callback* callback) { | 68 DownloadRequestLimiter::Callback* callback) { |
| 68 callbacks_.push_back(callback); | 69 callbacks_.push_back(callback); |
| 69 | 70 |
| 70 if (is_showing_prompt()) | 71 if (is_showing_prompt()) |
| 71 return; // Already showing prompt. | 72 return; // Already showing prompt. |
| 72 | 73 |
| 73 if (DownloadRequestLimiter::delegate_) { | 74 if (DownloadRequestLimiter::delegate_) { |
| 74 NotifyCallbacks(DownloadRequestLimiter::delegate_->ShouldAllowDownload()); | 75 NotifyCallbacks(DownloadRequestLimiter::delegate_->ShouldAllowDownload()); |
| 75 } else { | 76 } else { |
| 76 infobar_ = new DownloadRequestInfoBarDelegate(tab, this); | 77 infobar_ = new DownloadRequestInfoBarDelegate(tab, this); |
| 77 TabContentsWrapper* wrapper = | 78 TabContentsWrapper* wrapper = |
|
Peter Kasting
2011/08/31 18:47:32
Nit: Just collapse these two lines together
| |
| 78 TabContentsWrapper::GetCurrentWrapperForContents(tab); | 79 TabContentsWrapper::GetCurrentWrapperForContents(tab); |
| 79 wrapper->AddInfoBar(infobar_); | 80 wrapper->infobar_tab_helper()->AddInfoBar(infobar_); |
| 80 } | 81 } |
| 81 } | 82 } |
| 82 | 83 |
| 83 void DownloadRequestLimiter::TabDownloadState::Cancel() { | 84 void DownloadRequestLimiter::TabDownloadState::Cancel() { |
| 84 NotifyCallbacks(false); | 85 NotifyCallbacks(false); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void DownloadRequestLimiter::TabDownloadState::Accept() { | 88 void DownloadRequestLimiter::TabDownloadState::Accept() { |
| 88 NotifyCallbacks(true); | 89 NotifyCallbacks(true); |
| 89 } | 90 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 | 330 |
| 330 void DownloadRequestLimiter::Remove(TabDownloadState* state) { | 331 void DownloadRequestLimiter::Remove(TabDownloadState* state) { |
| 331 DCHECK(ContainsKey(state_map_, state->controller())); | 332 DCHECK(ContainsKey(state_map_, state->controller())); |
| 332 state_map_.erase(state->controller()); | 333 state_map_.erase(state->controller()); |
| 333 delete state; | 334 delete state; |
| 334 } | 335 } |
| 335 | 336 |
| 336 // static | 337 // static |
| 337 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = | 338 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = |
| 338 NULL; | 339 NULL; |
| OLD | NEW |