| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "chrome/browser/download/download_request_infobar_delegate.h" | 9 #include "chrome/browser/download/download_request_infobar_delegate.h" |
| 10 #include "chrome/browser/infobars/infobar_tab_helper.h" | 10 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // If the tab requesting the download is a constrained popup that is not | 280 // If the tab requesting the download is a constrained popup that is not |
| 281 // shown, treat the request as if it came from the parent. | 281 // shown, treat the request as if it came from the parent. |
| 282 TabContentsWrapper* effective_wrapper = originating_tab; | 282 TabContentsWrapper* effective_wrapper = originating_tab; |
| 283 if (effective_wrapper->blocked_content_tab_helper()->delegate()) { | 283 if (effective_wrapper->blocked_content_tab_helper()->delegate()) { |
| 284 effective_wrapper = effective_wrapper->blocked_content_tab_helper()-> | 284 effective_wrapper = effective_wrapper->blocked_content_tab_helper()-> |
| 285 delegate()->GetConstrainingContentsWrapper(effective_wrapper); | 285 delegate()->GetConstrainingContentsWrapper(effective_wrapper); |
| 286 } | 286 } |
| 287 | 287 |
| 288 TabDownloadState* state = GetDownloadState( | 288 TabDownloadState* state = GetDownloadState( |
| 289 &effective_wrapper->tab_contents()->controller(), | 289 &effective_wrapper->tab_contents()->controller(), |
| 290 &originating_tab->controller(), true); | 290 &originating_tab->tab_contents()->controller(), true); |
| 291 switch (state->download_status()) { | 291 switch (state->download_status()) { |
| 292 case ALLOW_ALL_DOWNLOADS: | 292 case ALLOW_ALL_DOWNLOADS: |
| 293 if (state->download_count() && !(state->download_count() % | 293 if (state->download_count() && !(state->download_count() % |
| 294 DownloadRequestLimiter::kMaxDownloadsAtOnce)) | 294 DownloadRequestLimiter::kMaxDownloadsAtOnce)) |
| 295 state->set_download_status(PROMPT_BEFORE_DOWNLOAD); | 295 state->set_download_status(PROMPT_BEFORE_DOWNLOAD); |
| 296 ScheduleNotification(callback, true); | 296 ScheduleNotification(callback, true); |
| 297 state->increment_download_count(); | 297 state->increment_download_count(); |
| 298 break; | 298 break; |
| 299 | 299 |
| 300 case ALLOW_ONE_DOWNLOAD: | 300 case ALLOW_ONE_DOWNLOAD: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 void DownloadRequestLimiter::Remove(TabDownloadState* state) { | 335 void DownloadRequestLimiter::Remove(TabDownloadState* state) { |
| 336 DCHECK(ContainsKey(state_map_, state->controller())); | 336 DCHECK(ContainsKey(state_map_, state->controller())); |
| 337 state_map_.erase(state->controller()); | 337 state_map_.erase(state->controller()); |
| 338 delete state; | 338 delete state; |
| 339 } | 339 } |
| 340 | 340 |
| 341 // static | 341 // static |
| 342 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = | 342 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = |
| 343 NULL; | 343 NULL; |
| OLD | NEW |