| 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/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 factory_(this) {} | 215 factory_(this) {} |
| 216 | 216 |
| 217 bool DownloadRequestLimiter::TabDownloadState::is_showing_prompt() const { | 217 bool DownloadRequestLimiter::TabDownloadState::is_showing_prompt() const { |
| 218 return factory_.HasWeakPtrs(); | 218 return factory_.HasWeakPtrs(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void DownloadRequestLimiter::TabDownloadState::Observe( | 221 void DownloadRequestLimiter::TabDownloadState::Observe( |
| 222 int type, | 222 int type, |
| 223 const content::NotificationSource& source, | 223 const content::NotificationSource& source, |
| 224 const content::NotificationDetails& details) { | 224 const content::NotificationDetails& details) { |
| 225 DCHECK(type == chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED); | 225 DCHECK_EQ(chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, type); |
| 226 | 226 |
| 227 // Content settings have been updated for our web contents, e.g. via the OIB | 227 // Content settings have been updated for our web contents, e.g. via the OIB |
| 228 // or the settings page. Check to see if the automatic downloads setting is | 228 // or the settings page. Check to see if the automatic downloads setting is |
| 229 // different to our internal state, and update the internal state to match if | 229 // different to our internal state, and update the internal state to match if |
| 230 // necessary. If there is no content setting persisted, then retain the | 230 // necessary. If there is no content setting persisted, then retain the |
| 231 // current state and do nothing. | 231 // current state and do nothing. |
| 232 // | 232 // |
| 233 // NotifyCallbacks is not called as this notification should be triggered when | 233 // NotifyCallbacks is not called as this notification should be triggered when |
| 234 // a download is not pending. | 234 // a download is not pending. |
| 235 content::WebContents* contents = | 235 content::WebContents* contents = |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 NOTREACHED(); | 466 NOTREACHED(); |
| 467 } | 467 } |
| 468 } | 468 } |
| 469 | 469 |
| 470 void DownloadRequestLimiter::Remove(TabDownloadState* state, | 470 void DownloadRequestLimiter::Remove(TabDownloadState* state, |
| 471 content::WebContents* contents) { | 471 content::WebContents* contents) { |
| 472 DCHECK(ContainsKey(state_map_, contents)); | 472 DCHECK(ContainsKey(state_map_, contents)); |
| 473 state_map_.erase(contents); | 473 state_map_.erase(contents); |
| 474 delete state; | 474 delete state; |
| 475 } | 475 } |
| OLD | NEW |