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

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

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