summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/download_request_limiter.h
diff options
context:
space:
mode:
authorbenjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 23:02:08 +0000
committerbenjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 23:02:08 +0000
commit62167c1b6c2777d451f4b92eef4e5ddabdbbfce4 (patch)
tree28a9356095ae97fcfbc2d71e1f3a89c8eff6bf56 /chrome/browser/download/download_request_limiter.h
parent28b05ef0bb80c9d2598585fd9d623432620252a0 (diff)
downloadchromium_src-62167c1b6c2777d451f4b92eef4e5ddabdbbfce4.zip
chromium_src-62167c1b6c2777d451f4b92eef4e5ddabdbbfce4.tar.gz
chromium_src-62167c1b6c2777d451f4b92eef4e5ddabdbbfce4.tar.bz2
Create a content setting for the multiple automatic downloads infobar
Clicking Allow on the infobar sets the content setting for that origin (protocol+host) to ALLOW; Deny sets it to BLOCK. Blocked/Allowed origins may be changed/cleared in chrome://settings > Show Advanced Settings > Privacy > Content Settings > Multiple Automatic Downloads Closing the infobar without clicking Allow or Deny cancels all pending automatic downloads without setting the content setting to BLOCK. Origins that are set to BLOCK are allowed one automatic download then no more, and the infobar is not shown. A button+label does appear in the location bar reading "Download blocked"; clicking on this button opens a popup containing radio buttons and link to chrome://settings/contentExceptions The default value of the content setting can be changed from ASK (which triggers the infobar) to ALLOW or BLOCK in chrome://settings/content Test url (Google-only): http://www/~benjhayden/multi.html BUG=166335 Review URL: https://chromiumcodereview.appspot.com/12476007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210954 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/download_request_limiter.h')
-rw-r--r--chrome/browser/download/download_request_limiter.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/chrome/browser/download/download_request_limiter.h b/chrome/browser/download/download_request_limiter.h
index 05b3b73..23165ff 100644
--- a/chrome/browser/download/download_request_limiter.h
+++ b/chrome/browser/download/download_request_limiter.h
@@ -13,10 +13,12 @@
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "chrome/common/content_settings.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_observer.h"
+class HostContentSettingsMap;
class DownloadRequestInfoBarDelegate;
namespace content {
@@ -115,12 +117,12 @@ class DownloadRequestLimiter
// See description above CanDownloadOnIOThread for details on lifetime of
// callback.
void PromptUserForDownload(
- content::WebContents* tab,
const DownloadRequestLimiter::Callback& callback);
// Invoked from DownloadRequestDialogDelegate. Notifies the delegates and
// changes the status appropriately. Virtual for testing.
virtual void Cancel();
+ virtual void CancelOnce();
virtual void Accept();
protected:
@@ -138,10 +140,15 @@ class DownloadRequestLimiter
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+ // Remember to either block or allow automatic downloads from this origin.
+ void SetContentSetting(ContentSetting setting);
+
// Notifies the callbacks as to whether the download is allowed or not.
// Updates status_ appropriately.
void NotifyCallbacks(bool allow);
+ content::WebContents* web_contents_;
+
DownloadRequestLimiter* host_;
// Host of the first page the download started on. This may be empty.
@@ -169,6 +176,8 @@ class DownloadRequestLimiter
DISALLOW_COPY_AND_ASSIGN(TabDownloadState);
};
+ static void SetContentSettingsForTesting(HostContentSettingsMap* settings);
+
DownloadRequestLimiter();
// Returns the download status for a page. This does not change the state in
@@ -235,6 +244,10 @@ class DownloadRequestLimiter
// ALLOW_ONE_DOWNLOAD.
void Remove(TabDownloadState* state);
+ static HostContentSettingsMap* content_settings_;
+ static HostContentSettingsMap* GetContentSettings(
+ content::WebContents* contents);
+
// Maps from tab to download state. The download state for a tab only exists
// if the state is other than ALLOW_ONE_DOWNLOAD. Similarly once the state
// transitions from anything but ALLOW_ONE_DOWNLOAD back to ALLOW_ONE_DOWNLOAD