summaryrefslogtreecommitdiffstats
path: root/chrome/browser/blocked_popup_container.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/blocked_popup_container.cc')
-rw-r--r--chrome/browser/blocked_popup_container.cc32
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();