OLD | NEW |
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 void DownloadRequestLimiter::TabDownloadState::Cancel() { | 112 void DownloadRequestLimiter::TabDownloadState::Cancel() { |
113 NotifyCallbacks(false); | 113 NotifyCallbacks(false); |
114 } | 114 } |
115 | 115 |
116 void DownloadRequestLimiter::TabDownloadState::Accept() { | 116 void DownloadRequestLimiter::TabDownloadState::Accept() { |
117 NotifyCallbacks(true); | 117 NotifyCallbacks(true); |
118 } | 118 } |
119 | 119 |
| 120 DownloadRequestLimiter::TabDownloadState::TabDownloadState() |
| 121 : host_(NULL), |
| 122 status_(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD), |
| 123 download_count_(0), |
| 124 infobar_(NULL) { |
| 125 } |
| 126 |
120 void DownloadRequestLimiter::TabDownloadState::Observe( | 127 void DownloadRequestLimiter::TabDownloadState::Observe( |
121 int type, | 128 int type, |
122 const content::NotificationSource& source, | 129 const content::NotificationSource& source, |
123 const content::NotificationDetails& details) { | 130 const content::NotificationDetails& details) { |
124 if (type != content::NOTIFICATION_NAV_ENTRY_PENDING && | 131 if (type != content::NOTIFICATION_NAV_ENTRY_PENDING && |
125 type != content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 132 type != content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
126 NOTREACHED(); | 133 NOTREACHED(); |
127 return; | 134 return; |
128 } | 135 } |
129 content::NavigationController* controller = &web_contents()->GetController(); | 136 content::NavigationController* controller = &web_contents()->GetController(); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 371 |
365 void DownloadRequestLimiter::Remove(TabDownloadState* state) { | 372 void DownloadRequestLimiter::Remove(TabDownloadState* state) { |
366 DCHECK(ContainsKey(state_map_, state->web_contents())); | 373 DCHECK(ContainsKey(state_map_, state->web_contents())); |
367 state_map_.erase(state->web_contents()); | 374 state_map_.erase(state->web_contents()); |
368 delete state; | 375 delete state; |
369 } | 376 } |
370 | 377 |
371 // static | 378 // static |
372 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = | 379 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = |
373 NULL; | 380 NULL; |
OLD | NEW |