Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: chrome/browser/download/download_request_limiter.cc

Issue 10938033: Switch BlockedContentTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/instant/instant_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 originating_contents->GetRenderViewHost(), 294 originating_contents->GetRenderViewHost(),
295 request_id, 295 request_id,
296 request_method)) { 296 request_method)) {
297 ScheduleNotification(callback, false); 297 ScheduleNotification(callback, false);
298 return; 298 return;
299 } 299 }
300 300
301 // If the tab requesting the download is a constrained popup that is not 301 // If the tab requesting the download is a constrained popup that is not
302 // shown, treat the request as if it came from the parent. 302 // shown, treat the request as if it came from the parent.
303 WebContents* effective_contents = originating_contents; 303 WebContents* effective_contents = originating_contents;
304 TabContents* originating_tab_contents = 304 BlockedContentTabHelper* blocked_content_tab_helper =
305 TabContents::FromWebContents(originating_contents); 305 BlockedContentTabHelper::FromWebContents(originating_contents);
306 if (originating_tab_contents && 306 if (blocked_content_tab_helper &&
307 originating_tab_contents->blocked_content_tab_helper()->delegate()) { 307 blocked_content_tab_helper->delegate()) {
308 effective_contents = 308 effective_contents = blocked_content_tab_helper->delegate()->
309 originating_tab_contents->blocked_content_tab_helper()->delegate()-> 309 GetConstrainingWebContents(originating_contents);
310 GetConstrainingTabContents(originating_tab_contents)->
311 web_contents();
312 } 310 }
313 311
314 TabDownloadState* state = GetDownloadState( 312 TabDownloadState* state = GetDownloadState(
315 effective_contents, originating_contents, true); 313 effective_contents, originating_contents, true);
316 switch (state->download_status()) { 314 switch (state->download_status()) {
317 case ALLOW_ALL_DOWNLOADS: 315 case ALLOW_ALL_DOWNLOADS:
318 if (state->download_count() && !(state->download_count() % 316 if (state->download_count() && !(state->download_count() %
319 DownloadRequestLimiter::kMaxDownloadsAtOnce)) 317 DownloadRequestLimiter::kMaxDownloadsAtOnce))
320 state->set_download_status(PROMPT_BEFORE_DOWNLOAD); 318 state->set_download_status(PROMPT_BEFORE_DOWNLOAD);
321 ScheduleNotification(callback, true); 319 ScheduleNotification(callback, true);
(...skipping 27 matching lines...) Expand all
349 347
350 void DownloadRequestLimiter::Remove(TabDownloadState* state) { 348 void DownloadRequestLimiter::Remove(TabDownloadState* state) {
351 DCHECK(ContainsKey(state_map_, state->web_contents())); 349 DCHECK(ContainsKey(state_map_, state->web_contents()));
352 state_map_.erase(state->web_contents()); 350 state_map_.erase(state->web_contents());
353 delete state; 351 delete state;
354 } 352 }
355 353
356 // static 354 // static
357 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = 355 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ =
358 NULL; 356 NULL;
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/instant/instant_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698