| 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));
|
| }
|
|
|