| 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-inl.h" | 7 #include "base/stl_util-inl.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/tab_contents/tab_util.h" | 9 #include "chrome/browser/tab_contents/tab_util.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 11 #include "content/browser/browser_thread.h" | 11 #include "content/browser/browser_thread.h" |
| 12 #include "content/browser/tab_contents/navigation_controller.h" | 12 #include "content/browser/tab_contents/navigation_controller.h" |
| 13 #include "content/browser/tab_contents/navigation_entry.h" | 13 #include "content/browser/tab_contents/navigation_entry.h" |
| 14 #include "content/browser/tab_contents/tab_contents.h" | 14 #include "content/browser/tab_contents/tab_contents.h" |
| 15 #include "content/browser/tab_contents/tab_contents_delegate.h" | 15 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 16 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 16 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 17 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.
h" | 17 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.
h" |
| 18 #include "chrome/browser/ui/download/download_tab_helper.h" | |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | |
| 20 #include "content/common/notification_source.h" | 18 #include "content/common/notification_source.h" |
| 21 | 19 |
| 22 // TabDownloadState ------------------------------------------------------------ | 20 // TabDownloadState ------------------------------------------------------------ |
| 23 | 21 |
| 24 DownloadRequestLimiter::TabDownloadState::TabDownloadState( | 22 DownloadRequestLimiter::TabDownloadState::TabDownloadState( |
| 25 DownloadRequestLimiter* host, | 23 DownloadRequestLimiter* host, |
| 26 NavigationController* controller, | 24 NavigationController* controller, |
| 27 NavigationController* originating_controller) | 25 NavigationController* originating_controller) |
| 28 : host_(host), | 26 : host_(host), |
| 29 controller_(controller), | 27 controller_(controller), |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 260 |
| 263 void DownloadRequestLimiter::CanDownloadImpl( | 261 void DownloadRequestLimiter::CanDownloadImpl( |
| 264 TabContentsWrapper* originating_tab, | 262 TabContentsWrapper* originating_tab, |
| 265 int request_id, | 263 int request_id, |
| 266 Callback* callback) { | 264 Callback* callback) { |
| 267 DCHECK(originating_tab); | 265 DCHECK(originating_tab); |
| 268 | 266 |
| 269 // FYI: Chrome Frame overrides CanDownload in ExternalTabContainer in order | 267 // FYI: Chrome Frame overrides CanDownload in ExternalTabContainer in order |
| 270 // to cancel the download operation in chrome and let the host browser | 268 // to cancel the download operation in chrome and let the host browser |
| 271 // take care of it. | 269 // take care of it. |
| 272 if (!originating_tab->download_tab_helper()->CanDownload(request_id)) { | 270 if (!originating_tab->CanDownload(request_id)) { |
| 273 ScheduleNotification(callback, false); | 271 ScheduleNotification(callback, false); |
| 274 return; | 272 return; |
| 275 } | 273 } |
| 276 | 274 |
| 277 // If the tab requesting the download is a constrained popup that is not | 275 // If the tab requesting the download is a constrained popup that is not |
| 278 // shown, treat the request as if it came from the parent. | 276 // shown, treat the request as if it came from the parent. |
| 279 TabContentsWrapper* effective_wrapper = originating_tab; | 277 TabContentsWrapper* effective_wrapper = originating_tab; |
| 280 if (effective_wrapper->blocked_content_tab_helper()->delegate()) { | 278 if (effective_wrapper->blocked_content_tab_helper()->delegate()) { |
| 281 effective_wrapper = effective_wrapper->blocked_content_tab_helper()-> | 279 effective_wrapper = effective_wrapper->blocked_content_tab_helper()-> |
| 282 delegate()->GetConstrainingContentsWrapper(effective_wrapper); | 280 delegate()->GetConstrainingContentsWrapper(effective_wrapper); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 329 |
| 332 void DownloadRequestLimiter::Remove(TabDownloadState* state) { | 330 void DownloadRequestLimiter::Remove(TabDownloadState* state) { |
| 333 DCHECK(ContainsKey(state_map_, state->controller())); | 331 DCHECK(ContainsKey(state_map_, state->controller())); |
| 334 state_map_.erase(state->controller()); | 332 state_map_.erase(state->controller()); |
| 335 delete state; | 333 delete state; |
| 336 } | 334 } |
| 337 | 335 |
| 338 // static | 336 // static |
| 339 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = | 337 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = |
| 340 NULL; | 338 NULL; |
| OLD | NEW |