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

Unified Diff: chrome/browser/content_settings/tab_specific_content_settings.cc

Issue 2561673003: Handle per-tab AUTOMATIC_DOWNLOADS setting in DownloadRequestLimiter. (Closed)
Patch Set: Handle per-tab AUTOMATIC_DOWNLOADS setting in DownloadRequestLimiter. Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/content_settings/tab_specific_content_settings.cc
diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc
index 70c1b17591f3f4b426d1f8fd3fe9ed7440c4a998..fc58c9ae7f8aa416205f6eb6c8f291fb91b4d377 100644
--- a/chrome/browser/content_settings/tab_specific_content_settings.cc
+++ b/chrome/browser/content_settings/tab_specific_content_settings.cc
@@ -11,6 +11,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/browsing_data/browsing_data_appcache_helper.h"
#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
#include "chrome/browser/browsing_data/browsing_data_database_helper.h"
@@ -21,6 +22,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/chrome_content_settings_utils.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
+#include "chrome/browser/download/download_request_limiter.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
#include "chrome/browser/profiles/profile.h"
@@ -239,6 +241,12 @@ bool TabSpecificContentSettings::IsContentBlocked(
<< "Notifications settings handled by "
<< "ContentSettingsNotificationsImageModel";
+ // Automatic downloads are handled by DownloadRequestLimiter.
+ if (content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) {
Bernhard Bauer 2017/01/25 19:01:14 If you are now bypassing TabSpecificContentSetting
alshabalin 2017/02/07 16:16:29 Done.
+ return g_browser_process->download_request_limiter()->GetDownloadStatus(
+ web_contents()) == DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED;
+ }
+
if (content_type == CONTENT_SETTINGS_TYPE_IMAGES ||
content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT ||
content_type == CONTENT_SETTINGS_TYPE_PLUGINS ||
@@ -248,7 +256,6 @@ bool TabSpecificContentSettings::IsContentBlocked(
content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA ||
content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER ||
- content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS ||
content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
const auto& it = content_settings_status_.find(content_type);
if (it != content_settings_status_.end())
@@ -285,13 +292,18 @@ void TabSpecificContentSettings::SetSubresourceBlockageIndicated() {
bool TabSpecificContentSettings::IsContentAllowed(
ContentSettingsType content_type) const {
+ // Automatic downloads are handled by DownloadRequestLimiter.
+ if (content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) {
+ return g_browser_process->download_request_limiter()->GetDownloadStatus(
+ web_contents()) == DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS;
+ }
+
// This method currently only returns meaningful values for the content type
// cookies, media, PPAPI broker, downloads, and MIDI sysex.
if (content_type != CONTENT_SETTINGS_TYPE_COOKIES &&
content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC &&
content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA &&
content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER &&
- content_type != CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS &&
content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
return false;
}
@@ -696,18 +708,6 @@ void TabSpecificContentSettings::FlashDownloadBlocked() {
base::UTF8ToUTF16(content::kFlashPluginName));
}
-void TabSpecificContentSettings::SetDownloadsBlocked(bool blocked) {
- ContentSettingsStatus& status =
- content_settings_status_[CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS];
- status.blocked = blocked;
- status.allowed = !blocked;
- status.blockage_indicated_to_user = false;
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,
- content::Source<WebContents>(web_contents()),
- content::NotificationService::NoDetails());
-}
-
void TabSpecificContentSettings::SetPopupsBlocked(bool blocked) {
ContentSettingsStatus& status =
content_settings_status_[CONTENT_SETTINGS_TYPE_POPUPS];

Powered by Google App Engine
This is Rietveld 408576698