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

Unified Diff: chrome/browser/download/download_request_limiter.h

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/download/download_request_limiter.h
diff --git a/chrome/browser/download/download_request_limiter.h b/chrome/browser/download/download_request_limiter.h
index 63d13c5fcdc4ff9add900a2159254adf6adaf158..02ecf11fcd30e0e2b12903f1b007062b0b251002 100644
--- a/chrome/browser/download/download_request_limiter.h
+++ b/chrome/browser/download/download_request_limiter.h
@@ -16,9 +16,9 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "base/scoped_observer.h"
+#include "components/content_settings/core/browser/content_settings_observer.h"
#include "components/content_settings/core/common/content_settings.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/browser/web_contents_observer.h"
@@ -74,7 +74,7 @@ class DownloadRequestLimiter
// TabDownloadState deletes itself (by invoking
// DownloadRequestLimiter::Remove) as necessary.
// TODO(gbillock): just make this class implement PermissionRequest.
- class TabDownloadState : public content::NotificationObserver,
+ class TabDownloadState : public content_settings::Observer,
public content::WebContentsObserver {
public:
// Creates a new TabDownloadState. |controller| is the controller the
@@ -89,9 +89,8 @@ class DownloadRequestLimiter
~TabDownloadState() override;
// Status of the download.
dominickn 2017/01/24 06:46:17 Nit: "Sets the current limiter state and the under
alshabalin 2017/02/07 16:16:29 Done.
- void set_download_status(DownloadRequestLimiter::DownloadStatus status) {
- status_ = status;
- }
+ void SetDownloadStatusAndNotify(
+ DownloadRequestLimiter::DownloadStatus status);
DownloadRequestLimiter::DownloadStatus download_status() const {
return status_;
}
@@ -136,17 +135,19 @@ class DownloadRequestLimiter
// given to the info bar delegate or permission bubble request.
bool is_showing_prompt() const;
- // content::NotificationObserver method.
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
+ // content_settings::Observer overrides.
+ void OnContentSettingChanged(
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
+ ContentSettingsType content_type,
+ std::string resource_identifier) 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);
+ // Returns false if it didn't notify all callbacks.
+ bool NotifyCallbacks(bool allow);
content::WebContents* web_contents_;
@@ -165,8 +166,8 @@ class DownloadRequestLimiter
// callbacks.
std::vector<DownloadRequestLimiter::Callback> callbacks_;
- // Used to remove observers installed on NavigationController.
- content::NotificationRegistrar registrar_;
+ ScopedObserver<HostContentSettingsMap, content_settings::Observer>
+ observer_;
// Weak pointer factory for generating a weak pointer to pass to the
// infobar. User responses to the throttling prompt will be returned

Powered by Google App Engine
This is Rietveld 408576698