Chromium Code Reviews| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 ContentSetting setting) { | 184 ContentSetting setting) { |
| 185 if (!web_contents_) | 185 if (!web_contents_) |
| 186 return; | 186 return; |
| 187 HostContentSettingsMap* settings = | 187 HostContentSettingsMap* settings = |
| 188 DownloadRequestLimiter::GetContentSettings(web_contents_); | 188 DownloadRequestLimiter::GetContentSettings(web_contents_); |
| 189 if (!settings) | 189 if (!settings) |
| 190 return; | 190 return; |
| 191 settings->SetContentSettingDefaultScope( | 191 settings->SetContentSettingDefaultScope( |
| 192 web_contents_->GetURL(), GURL(), | 192 web_contents_->GetURL(), GURL(), |
| 193 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, std::string(), setting); | 193 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, std::string(), setting); |
| 194 TabSpecificContentSettings* tab_settings = | |
| 195 TabSpecificContentSettings::FromWebContents(web_contents_); | |
| 196 if (tab_settings) { | |
|
alshabalin
2016/12/08 11:39:06
This is called right after permission prompt decis
| |
| 197 switch (setting) { | |
| 198 case CONTENT_SETTING_BLOCK: | |
| 199 tab_settings->SetDownloadsBlocked(true); | |
| 200 break; | |
| 201 case CONTENT_SETTING_ALLOW: | |
| 202 tab_settings->SetDownloadsBlocked(false); | |
| 203 break; | |
| 204 default: | |
| 205 // Nothing to do. | |
| 206 break; | |
| 207 } | |
| 208 } | |
| 194 } | 209 } |
| 195 | 210 |
| 196 void DownloadRequestLimiter::TabDownloadState::Cancel() { | 211 void DownloadRequestLimiter::TabDownloadState::Cancel() { |
| 197 SetContentSetting(CONTENT_SETTING_BLOCK); | 212 SetContentSetting(CONTENT_SETTING_BLOCK); |
| 198 NotifyCallbacks(false); | 213 NotifyCallbacks(false); |
| 199 } | 214 } |
| 200 | 215 |
| 201 void DownloadRequestLimiter::TabDownloadState::CancelOnce() { | 216 void DownloadRequestLimiter::TabDownloadState::CancelOnce() { |
| 202 NotifyCallbacks(false); | 217 NotifyCallbacks(false); |
| 203 } | 218 } |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 NOTREACHED(); | 481 NOTREACHED(); |
| 467 } | 482 } |
| 468 } | 483 } |
| 469 | 484 |
| 470 void DownloadRequestLimiter::Remove(TabDownloadState* state, | 485 void DownloadRequestLimiter::Remove(TabDownloadState* state, |
| 471 content::WebContents* contents) { | 486 content::WebContents* contents) { |
| 472 DCHECK(base::ContainsKey(state_map_, contents)); | 487 DCHECK(base::ContainsKey(state_map_, contents)); |
| 473 state_map_.erase(contents); | 488 state_map_.erase(contents); |
| 474 delete state; | 489 delete state; |
| 475 } | 490 } |
| OLD | NEW |