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

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

Issue 8956059: Rename NavigationController to NavigationControllerImpl and put it into the content namespace. Al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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/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"
11 #include "chrome/browser/tab_contents/tab_util.h" 11 #include "chrome/browser/tab_contents/tab_util.h"
12 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 12 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
13 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h" 13 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "content/browser/tab_contents/navigation_controller.h" 15 #include "content/browser/tab_contents/navigation_controller.h"
16 #include "content/browser/tab_contents/tab_contents.h" 16 #include "content/browser/tab_contents/tab_contents.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
20 #include "content/public/browser/notification_types.h" 20 #include "content/public/browser/notification_types.h"
21 #include "content/public/browser/web_contents_delegate.h" 21 #include "content/public/browser/web_contents_delegate.h"
22 22
23 using content::BrowserThread; 23 using content::BrowserThread;
24 using content::NavigationEntry;
24 using content::WebContents; 25 using content::WebContents;
25 26
26 // TabDownloadState ------------------------------------------------------------ 27 // TabDownloadState ------------------------------------------------------------
27 28
28 DownloadRequestLimiter::TabDownloadState::TabDownloadState( 29 DownloadRequestLimiter::TabDownloadState::TabDownloadState(
29 DownloadRequestLimiter* host, 30 DownloadRequestLimiter* host,
30 NavigationController* controller, 31 NavigationController* controller,
31 NavigationController* originating_controller) 32 NavigationController* originating_controller)
32 : host_(host), 33 : host_(host),
33 controller_(controller), 34 controller_(controller),
34 status_(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD), 35 status_(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD),
35 download_count_(0), 36 download_count_(0),
36 infobar_(NULL) { 37 infobar_(NULL) {
37 content::Source<NavigationController> notification_source(controller); 38 content::Source<NavigationController> notification_source(controller);
38 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 39 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
39 notification_source); 40 notification_source);
40 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, notification_source); 41 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, notification_source);
41 42
42 content::NavigationEntry* active_entry = originating_controller ? 43 NavigationEntry* active_entry = originating_controller ?
43 originating_controller->GetActiveEntry() : controller->GetActiveEntry(); 44 originating_controller->GetActiveEntry() : controller->GetActiveEntry();
44 if (active_entry) 45 if (active_entry)
45 initial_page_host_ = active_entry->GetURL().host(); 46 initial_page_host_ = active_entry->GetURL().host();
46 } 47 }
47 48
48 DownloadRequestLimiter::TabDownloadState::~TabDownloadState() { 49 DownloadRequestLimiter::TabDownloadState::~TabDownloadState() {
49 // We should only be destroyed after the callbacks have been notified. 50 // We should only be destroyed after the callbacks have been notified.
50 DCHECK(callbacks_.empty()); 51 DCHECK(callbacks_.empty());
51 52
52 // And we should have closed the infobar. 53 // And we should have closed the infobar.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 108 }
108 109
109 switch (type) { 110 switch (type) {
110 case content::NOTIFICATION_NAV_ENTRY_PENDING: { 111 case content::NOTIFICATION_NAV_ENTRY_PENDING: {
111 // NOTE: resetting state on a pending navigate isn't ideal. In particular 112 // NOTE: resetting state on a pending navigate isn't ideal. In particular
112 // it is possible that queued up downloads for the page before the 113 // it is possible that queued up downloads for the page before the
113 // pending navigate will be delivered to us after we process this 114 // pending navigate will be delivered to us after we process this
114 // request. If this happens we may let a download through that we 115 // request. If this happens we may let a download through that we
115 // shouldn't have. But this is rather rare, and it is difficult to get 116 // shouldn't have. But this is rather rare, and it is difficult to get
116 // 100% right, so we don't deal with it. 117 // 100% right, so we don't deal with it.
117 content::NavigationEntry* entry = controller_->GetPendingEntry(); 118 NavigationEntry* entry = controller_->GetPendingEntry();
118 if (!entry) 119 if (!entry)
119 return; 120 return;
120 121
121 if (content::PageTransitionIsRedirect(entry->GetTransitionType())) { 122 if (content::PageTransitionIsRedirect(entry->GetTransitionType())) {
122 // Redirects don't count. 123 // Redirects don't count.
123 return; 124 return;
124 } 125 }
125 126
126 if (status_ == DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS || 127 if (status_ == DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS ||
127 status_ == DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED) { 128 status_ == DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 338
338 void DownloadRequestLimiter::Remove(TabDownloadState* state) { 339 void DownloadRequestLimiter::Remove(TabDownloadState* state) {
339 DCHECK(ContainsKey(state_map_, state->controller())); 340 DCHECK(ContainsKey(state_map_, state->controller()));
340 state_map_.erase(state->controller()); 341 state_map_.erase(state->controller());
341 delete state; 342 delete state;
342 } 343 }
343 344
344 // static 345 // static
345 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = 346 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ =
346 NULL; 347 NULL;
OLDNEW
« no previous file with comments | « chrome/browser/debugger/devtools_window.cc ('k') | chrome/browser/extensions/extension_navigation_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698