| Index: chrome/browser/privacy_blacklist/blacklist_ui.cc
|
| diff --git a/chrome/browser/privacy_blacklist/blacklist_ui.cc b/chrome/browser/privacy_blacklist/blacklist_ui.cc
|
| index 6d2327ec700c0a0e4aa79e741044079bcb7c656a..846ddb93e838b472194cc5ebdc9e0b44cc5f6473 100644
|
| --- a/chrome/browser/privacy_blacklist/blacklist_ui.cc
|
| +++ b/chrome/browser/privacy_blacklist/blacklist_ui.cc
|
| @@ -10,6 +10,8 @@
|
| #include "chrome/browser/blocked_popup_container.h"
|
| #include "chrome/browser/chrome_thread.h"
|
| #include "chrome/browser/privacy_blacklist/blacklist.h"
|
| +#include "chrome/browser/privacy_blacklist/blacklist_manager.h"
|
| +#include "chrome/browser/privacy_blacklist/blacklist_request_info.h"
|
| #include "chrome/browser/renderer_host/render_view_host.h"
|
| #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
|
| #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
|
| @@ -19,40 +21,42 @@
|
| // Displays more info why some content has been blocked.
|
| class DisplayBlockedContentNoticeTask : public Task {
|
| public:
|
| - DisplayBlockedContentNoticeTask(const GURL& gurl,
|
| + DisplayBlockedContentNoticeTask(const GURL& url,
|
| const Blacklist::Match* match,
|
| const ResourceDispatcherHostRequestInfo* info)
|
| - : gurl_(gurl),
|
| - match_(match),
|
| + : url_(url),
|
| 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) {
|
| + if (match->attributes() & Blacklist::kDontStoreCookies) {
|
| // No cookies stored.
|
| - reason = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_COOKIES);
|
| - } else if (match_->attributes() & Blacklist::kDontSendCookies) {
|
| + details_ = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_COOKIES);
|
| + } else if (match->attributes() & Blacklist::kDontSendCookies) {
|
| // No cookies sent.
|
| - reason = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_COOKIES);
|
| - } else if (match_->attributes() & Blacklist::kDontSendReferrer) {
|
| + details_ = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_COOKIES);
|
| + } else if (match->attributes() & Blacklist::kDontSendReferrer) {
|
| // No referrer sent.
|
| - reason = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_REFERRER);
|
| + details_ = l10n_util::GetStringUTF16(IDS_BLACKLIST_BLOCKED_REFERRER);
|
| } else {
|
| NOTREACHED();
|
| }
|
| + }
|
|
|
| - view->delegate()->AddBlockedNotice(gurl_, reason);
|
| + 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(url_, details_);
|
| }
|
|
|
| private:
|
| - const GURL gurl_;
|
| - const Blacklist::Match* match_;
|
| + // URL for which we blocked content.
|
| + const GURL url_;
|
| +
|
| + // More detailed info what has been blocked.
|
| + string16 details_;
|
| +
|
| + // Information that allows us to identify the right tab to display the notice.
|
| const int child_id_;
|
| const int route_id_;
|
|
|
| @@ -63,15 +67,17 @@ class DisplayBlockedContentNoticeTask : public Task {
|
| 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);
|
| + BlacklistRequestInfo* request_info =
|
| + BlacklistRequestInfo::FromURLRequest(request);
|
| + const BlacklistManager* blacklist_manager =
|
| + request_info->GetBlacklistManager();
|
| + const Blacklist* blacklist = blacklist_manager->GetCompiledBlacklist();
|
| + scoped_ptr<Blacklist::Match> match(blacklist->findMatch(request->url()));
|
| const ResourceDispatcherHostRequestInfo* info =
|
| ResourceDispatcherHost::InfoForRequest(request);
|
| - const GURL& gurl = request->url();
|
|
|
| // Notify the UI that something non-visual has been blocked.
|
| ChromeThread::PostTask(
|
| ChromeThread::UI, FROM_HERE,
|
| - new DisplayBlockedContentNoticeTask(gurl, match, info));
|
| + new DisplayBlockedContentNoticeTask(request->url(), match.get(), info));
|
| }
|
|
|