diff options
author | idanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 22:37:24 +0000 |
---|---|---|
committer | idanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 22:37:24 +0000 |
commit | 4a13ee3a5cba3ff0fbe3bf9f513335566c571d1c (patch) | |
tree | f31827d6bb4618758a8f0be0b809318f2c1fee50 /chrome/browser/blocked_popup_container.cc | |
parent | 6bc080954611da13cfba38879e96792c079d1a95 (diff) | |
download | chromium_src-4a13ee3a5cba3ff0fbe3bf9f513335566c571d1c.zip chromium_src-4a13ee3a5cba3ff0fbe3bf9f513335566c571d1c.tar.gz chromium_src-4a13ee3a5cba3ff0fbe3bf9f513335566c571d1c.tar.bz2 |
Added notice for blocked items to the popup container
Left a TODO to rename the class to something more general but
it is preferable to do a rename separate from code changes, it
will make things easier to sync and be quicker since that change
is relatively trivial.
The exact look may be changed later but I'll attach screenshots
to this issue to show the initial implementation.
Also left as future enhancement is the possibility of limiting
the size of the notification list in cases where a lot of hosts
are affected. The most extreme example I found was some Gizmodo
page with 36 domains using cookies.
BUG=16932
TEST=none
Review URL: http://codereview.chromium.org/179013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24822 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/blocked_popup_container.cc')
-rw-r--r-- | chrome/browser/blocked_popup_container.cc | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/chrome/browser/blocked_popup_container.cc b/chrome/browser/blocked_popup_container.cc index 4df5bef..c82998b 100644 --- a/chrome/browser/blocked_popup_container.cc +++ b/chrome/browser/blocked_popup_container.cc @@ -107,13 +107,40 @@ void BlockedPopupContainer::LaunchPopupAtIndex(size_t index) { void BlockedPopupContainer::AddBlockedNotice(const GURL& url, const string16& reason) { - // TODO(idanan): Implement this. See header for description. + // Nothing to show after we have been dismissed. + if (has_been_dismissed_) + return; + + // Don't notify for hosts which are already shown. Too much noise otherwise. + // TODO(idanan): Figure out what to do for multiple reasons of blocking the + // same host. + if (notice_hosts_.find(url.host()) != notice_hosts_.end()) + return; + + notice_hosts_.insert(url.host()); + blocked_notices_.push_back(BlockedNotice(url, reason)); + + UpdateView(); + view_->ShowView(); + owner_->PopupNotificationVisibilityChanged(true); +} + +void BlockedPopupContainer::GetHostAndReasonForNotice( + size_t index, std::string* host, string16* reason) const { + DCHECK(host); + DCHECK(reason); + *host = blocked_notices_[index].url_.host(); + *reason = blocked_notices_[index].reason_; } size_t BlockedPopupContainer::GetBlockedPopupCount() const { return blocked_popups_.size(); } +size_t BlockedPopupContainer::GetBlockedNoticeCount() const { + return blocked_notices_.size(); +} + bool BlockedPopupContainer::IsHostWhitelisted(size_t index) const { PopupHosts::const_iterator i(ConvertHostIndexToIterator(index)); return (i == popup_hosts_.end()) ? false : i->second; @@ -372,7 +399,8 @@ BlockedPopupContainer::BlockedPopupContainer(TabContents* owner, } void BlockedPopupContainer::UpdateView() { - if (blocked_popups_.empty() && unblocked_popups_.empty()) + if (blocked_popups_.empty() && unblocked_popups_.empty() && + blocked_notices_.empty()) HideSelf(); else view_->UpdateLabel(); |