OLD | NEW |
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" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // NOTE: resetting state on a pending navigate isn't ideal. In particular | 107 // NOTE: resetting state on a pending navigate isn't ideal. In particular |
108 // it is possible that queued up downloads for the page before the | 108 // it is possible that queued up downloads for the page before the |
109 // pending navigate will be delivered to us after we process this | 109 // pending navigate will be delivered to us after we process this |
110 // request. If this happens we may let a download through that we | 110 // request. If this happens we may let a download through that we |
111 // shouldn't have. But this is rather rare, and it is difficult to get | 111 // shouldn't have. But this is rather rare, and it is difficult to get |
112 // 100% right, so we don't deal with it. | 112 // 100% right, so we don't deal with it. |
113 NavigationEntry* entry = controller_->pending_entry(); | 113 NavigationEntry* entry = controller_->pending_entry(); |
114 if (!entry) | 114 if (!entry) |
115 return; | 115 return; |
116 | 116 |
117 if (PageTransition::IsRedirect(entry->transition_type())) { | 117 if (content::PageTransitionIsRedirect(entry->transition_type())) { |
118 // Redirects don't count. | 118 // Redirects don't count. |
119 return; | 119 return; |
120 } | 120 } |
121 | 121 |
122 if (status_ == DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS || | 122 if (status_ == DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS || |
123 status_ == DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED) { | 123 status_ == DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED) { |
124 // User has either allowed all downloads or canceled all downloads. Only | 124 // User has either allowed all downloads or canceled all downloads. Only |
125 // reset the download state if the user is navigating to a different | 125 // reset the download state if the user is navigating to a different |
126 // host (or host is empty). | 126 // host (or host is empty). |
127 if (!initial_page_host_.empty() && !entry->url().host().empty() && | 127 if (!initial_page_host_.empty() && !entry->url().host().empty() && |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 331 |
332 void DownloadRequestLimiter::Remove(TabDownloadState* state) { | 332 void DownloadRequestLimiter::Remove(TabDownloadState* state) { |
333 DCHECK(ContainsKey(state_map_, state->controller())); | 333 DCHECK(ContainsKey(state_map_, state->controller())); |
334 state_map_.erase(state->controller()); | 334 state_map_.erase(state->controller()); |
335 delete state; | 335 delete state; |
336 } | 336 } |
337 | 337 |
338 // static | 338 // static |
339 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = | 339 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = |
340 NULL; | 340 NULL; |
OLD | NEW |