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

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

Issue 7035015: Revert 85504 - Move download stuff to download tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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
OLDNEW
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 "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
11 #include "content/browser/tab_contents/navigation_controller.h" 11 #include "content/browser/tab_contents/navigation_controller.h"
12 #include "content/browser/tab_contents/navigation_entry.h" 12 #include "content/browser/tab_contents/navigation_entry.h"
13 #include "content/browser/tab_contents/tab_contents.h" 13 #include "content/browser/tab_contents/tab_contents.h"
14 #include "content/browser/tab_contents/tab_contents_delegate.h" 14 #include "content/browser/tab_contents/tab_contents_delegate.h"
15 #include "chrome/browser/ui/download/download_tab_helper.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
17 #include "content/common/notification_source.h" 15 #include "content/common/notification_source.h"
18 16
19 // TabDownloadState ------------------------------------------------------------ 17 // TabDownloadState ------------------------------------------------------------
20 18
21 DownloadRequestLimiter::TabDownloadState::TabDownloadState( 19 DownloadRequestLimiter::TabDownloadState::TabDownloadState(
22 DownloadRequestLimiter* host, 20 DownloadRequestLimiter* host,
23 NavigationController* controller, 21 NavigationController* controller,
24 NavigationController* originating_controller) 22 NavigationController* originating_controller)
25 : host_(host), 23 : host_(host),
26 controller_(controller), 24 controller_(controller),
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 CanDownloadImpl(originating_tab, request_id, callback); 249 CanDownloadImpl(originating_tab, request_id, callback);
252 } 250 }
253 251
254 void DownloadRequestLimiter::CanDownloadImpl( 252 void DownloadRequestLimiter::CanDownloadImpl(
255 TabContents* originating_tab, 253 TabContents* originating_tab,
256 int request_id, 254 int request_id,
257 Callback* callback) { 255 Callback* callback) {
258 // FYI: Chrome Frame overrides CanDownload in ExternalTabContainer in order 256 // FYI: Chrome Frame overrides CanDownload in ExternalTabContainer in order
259 // to cancel the download operation in chrome and let the host browser 257 // to cancel the download operation in chrome and let the host browser
260 // take care of it. 258 // take care of it.
261 TabContentsWrapper* wrapper = 259 if (!originating_tab->CanDownload(request_id)) {
262 TabContentsWrapper::GetCurrentWrapperForContents(originating_tab);
263 if (!wrapper->download_tab_helper()->CanDownload(request_id)) {
264 ScheduleNotification(callback, false); 260 ScheduleNotification(callback, false);
265 return; 261 return;
266 } 262 }
267 263
268 // If the tab requesting the download is a constrained popup that is not 264 // If the tab requesting the download is a constrained popup that is not
269 // shown, treat the request as if it came from the parent. 265 // shown, treat the request as if it came from the parent.
270 TabContents* effective_tab = originating_tab; 266 TabContents* effective_tab = originating_tab;
271 if (effective_tab->delegate()) { 267 if (effective_tab->delegate()) {
272 effective_tab = 268 effective_tab =
273 effective_tab->delegate()->GetConstrainingContents(effective_tab); 269 effective_tab->delegate()->GetConstrainingContents(effective_tab);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 317
322 void DownloadRequestLimiter::Remove(TabDownloadState* state) { 318 void DownloadRequestLimiter::Remove(TabDownloadState* state) {
323 DCHECK(ContainsKey(state_map_, state->controller())); 319 DCHECK(ContainsKey(state_map_, state->controller()));
324 state_map_.erase(state->controller()); 320 state_map_.erase(state->controller());
325 delete state; 321 delete state;
326 } 322 }
327 323
328 // static 324 // static
329 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = 325 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ =
330 NULL; 326 NULL;
OLDNEW
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/download/download_request_limiter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698