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

Unified Diff: chrome/browser/privacy_blacklist/blacklist_ui.cc

Issue 371063: Integrate BlacklistManager with Profile. (Closed)
Patch Set: trybot fixes Created 11 years, 1 month 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
« no previous file with comments | « chrome/browser/privacy_blacklist/blacklist_ui.h ('k') | chrome/browser/profile.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/privacy_blacklist/blacklist_ui.cc
diff --git a/chrome/browser/privacy_blacklist/blacklist_observer.cc b/chrome/browser/privacy_blacklist/blacklist_ui.cc
similarity index 65%
rename from chrome/browser/privacy_blacklist/blacklist_observer.cc
rename to chrome/browser/privacy_blacklist/blacklist_ui.cc
index b62d0c8cb028a69a9085d142454b2915170bec33..6d2327ec700c0a0e4aa79e741044079bcb7c656a 100644
--- a/chrome/browser/privacy_blacklist/blacklist_observer.cc
+++ b/chrome/browser/privacy_blacklist/blacklist_ui.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/privacy_blacklist/blacklist_observer.h"
+#include "chrome/browser/privacy_blacklist/blacklist_ui.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
@@ -14,38 +14,40 @@
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/common/notification_details.h"
-#include "chrome/common/notification_service.h"
-#include "chrome/common/notification_type.h"
#include "grit/generated_resources.h"
-class BlockedContentNotice : public Task {
+// Displays more info why some content has been blocked.
+class DisplayBlockedContentNoticeTask : public Task {
public:
- BlockedContentNotice(const GURL& gurl,
- const Blacklist::Match* match,
- const ResourceDispatcherHostRequestInfo* info)
+ DisplayBlockedContentNoticeTask(const GURL& gurl,
+ const Blacklist::Match* match,
+ const ResourceDispatcherHostRequestInfo* info)
: gurl_(gurl),
match_(match),
child_id_(info->child_id()),
route_id_(info->route_id()) {
+ }
+
+ virtual void Run() {
+ RenderViewHost* view = RenderViewHost::FromID(child_id_, route_id_);
+ if (!view)
+ return; // The view may be gone by the time we get here.
+
+ string16 reason;
if (match_->attributes() & Blacklist::kDontStoreCookies) {
// No cookies stored.
- reason_ = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_COOKIES);
+ reason = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_COOKIES);
} else if (match_->attributes() & Blacklist::kDontSendCookies) {
// No cookies sent.
- reason_ = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_COOKIES);
+ reason = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_COOKIES);
} else if (match_->attributes() & Blacklist::kDontSendReferrer) {
// No referrer sent.
- reason_ = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_REFERRER);
+ reason = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_REFERRER);
+ } else {
+ NOTREACHED();
}
- }
- virtual void Run() {
- RenderViewHost* view = RenderViewHost::FromID(child_id_, route_id_);
- if (!view)
- return; // The view may be gone by the time we get here.
-
- view->delegate()->AddBlockedNotice(gurl_, reason_);
+ view->delegate()->AddBlockedNotice(gurl_, reason);
}
private:
@@ -54,10 +56,13 @@ class BlockedContentNotice : public Task {
const int child_id_;
const int route_id_;
- string16 reason_;
+ DISALLOW_COPY_AND_ASSIGN(DisplayBlockedContentNoticeTask);
};
-void BlacklistObserver::ContentBlocked(const URLRequest* request) {
+// static
+void BlacklistUI::OnNonvisualContentBlocked(const URLRequest* request) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+
const URLRequest::UserData* d =
request->GetUserData(&Blacklist::kRequestDataKey);
const Blacklist::Match* match = static_cast<const Blacklist::Match*>(d);
@@ -68,5 +73,5 @@ void BlacklistObserver::ContentBlocked(const URLRequest* request) {
// Notify the UI that something non-visual has been blocked.
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE,
- new BlockedContentNotice(gurl, match, info));
+ new DisplayBlockedContentNoticeTask(gurl, match, info));
}
« no previous file with comments | « chrome/browser/privacy_blacklist/blacklist_ui.h ('k') | chrome/browser/profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698