| 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/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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 317 |
| 318 // If the tab requesting the download is a constrained popup that is not | 318 // If the tab requesting the download is a constrained popup that is not |
| 319 // shown, treat the request as if it came from the parent. | 319 // shown, treat the request as if it came from the parent. |
| 320 WebContents* effective_contents = originating_contents; | 320 WebContents* effective_contents = originating_contents; |
| 321 TabContents* originating_tab_contents = | 321 TabContents* originating_tab_contents = |
| 322 TabContents::GetOwningTabContentsForWebContents(originating_contents); | 322 TabContents::GetOwningTabContentsForWebContents(originating_contents); |
| 323 if (originating_tab_contents && | 323 if (originating_tab_contents && |
| 324 originating_tab_contents->blocked_content_tab_helper()->delegate()) { | 324 originating_tab_contents->blocked_content_tab_helper()->delegate()) { |
| 325 effective_contents = | 325 effective_contents = |
| 326 originating_tab_contents->blocked_content_tab_helper()->delegate()-> | 326 originating_tab_contents->blocked_content_tab_helper()->delegate()-> |
| 327 GetConstrainingContentsWrapper(originating_tab_contents)-> | 327 GetConstrainingTabContents(originating_tab_contents)-> |
| 328 web_contents(); | 328 web_contents(); |
| 329 } | 329 } |
| 330 | 330 |
| 331 TabDownloadState* state = GetDownloadState( | 331 TabDownloadState* state = GetDownloadState( |
| 332 effective_contents, originating_contents, true); | 332 effective_contents, originating_contents, true); |
| 333 switch (state->download_status()) { | 333 switch (state->download_status()) { |
| 334 case ALLOW_ALL_DOWNLOADS: | 334 case ALLOW_ALL_DOWNLOADS: |
| 335 if (state->download_count() && !(state->download_count() % | 335 if (state->download_count() && !(state->download_count() % |
| 336 DownloadRequestLimiter::kMaxDownloadsAtOnce)) | 336 DownloadRequestLimiter::kMaxDownloadsAtOnce)) |
| 337 state->set_download_status(PROMPT_BEFORE_DOWNLOAD); | 337 state->set_download_status(PROMPT_BEFORE_DOWNLOAD); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 366 | 366 |
| 367 void DownloadRequestLimiter::Remove(TabDownloadState* state) { | 367 void DownloadRequestLimiter::Remove(TabDownloadState* state) { |
| 368 DCHECK(ContainsKey(state_map_, state->web_contents())); | 368 DCHECK(ContainsKey(state_map_, state->web_contents())); |
| 369 state_map_.erase(state->web_contents()); | 369 state_map_.erase(state->web_contents()); |
| 370 delete state; | 370 delete state; |
| 371 } | 371 } |
| 372 | 372 |
| 373 // static | 373 // static |
| 374 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = | 374 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = |
| 375 NULL; | 375 NULL; |
| OLD | NEW |