diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-08 23:13:01 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-08 23:13:01 +0000 |
commit | 4d4c0b94960366979943dbe4e3c8880ce80dbdef (patch) | |
tree | 1c35f92b0ef05948a2ce13d410961813b5d26127 /chrome/browser/blocked_popup_container.cc | |
parent | b15fcc0b7c29054b67164b248122823dcf0a5a81 (diff) | |
download | chromium_src-4d4c0b94960366979943dbe4e3c8880ce80dbdef.zip chromium_src-4d4c0b94960366979943dbe4e3c8880ce80dbdef.tar.gz chromium_src-4d4c0b94960366979943dbe4e3c8880ce80dbdef.tar.bz2 |
Creates a BlockedPopupContainerView interface, and changes the current BlockedPopupContainerView class into a windows specific instance owned by the new BlockedPopupContainer.
http://crbug.com/12843
Review URL: http://codereview.chromium.org/118401
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17905 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/blocked_popup_container.cc')
-rw-r--r-- | chrome/browser/blocked_popup_container.cc | 61 |
1 files changed, 55 insertions, 6 deletions
diff --git a/chrome/browser/blocked_popup_container.cc b/chrome/browser/blocked_popup_container.cc index ad9c7c6..5c35c66 100644 --- a/chrome/browser/blocked_popup_container.cc +++ b/chrome/browser/blocked_popup_container.cc @@ -12,6 +12,23 @@ #include "chrome/common/notification_service.h" // static +BlockedPopupContainer* BlockedPopupContainer::Create( + TabContents* owner, Profile* profile) { + BlockedPopupContainer* container = + new BlockedPopupContainer(owner, profile->GetPrefs()); + + // TODO(erg): Add different defined(OS_??) as they get subclasses of + // BlockedPopupContainerView. +#if defined(OS_WIN) + BlockedPopupContainerView* view = + BlockedPopupContainerView::Create(container); + container->set_view(view); +#endif + + return container; +} + +// static void BlockedPopupContainer::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterListPref(prefs::kPopupWhitelistedHosts); } @@ -56,9 +73,8 @@ void BlockedPopupContainer::AddTabContents(TabContents* tab_contents, else DCHECK_EQ(whitelisted, i->second); - // Update UI. - UpdateLabel(); - ShowSelf(); + UpdateView(); + view_->ShowView(); owner_->PopupNotificationVisibilityChanged(true); } @@ -109,7 +125,7 @@ void BlockedPopupContainer::ToggleWhitelistingForHost(size_t index) { whitelist_pref->Append(new StringValue(host)); // Open the popups in order. - for (size_t j = 0; j < blocked_popups_.size(); ) { + for (size_t j = 0; j < blocked_popups_.size();) { if (blocked_popups_[j].host == host) LaunchPopupAtIndex(j); // This shifts the rest of the entries down. else @@ -151,6 +167,31 @@ void BlockedPopupContainer::CloseAll() { HideSelf(); } +void BlockedPopupContainer::Destroy() { + view_->Destroy(); + + ClearData(); + GetConstrainingContents(NULL)->WillCloseBlockedPopupContainer(this); + + delete this; +} + +void BlockedPopupContainer::RepositionBlockedPopupContainer() { + view_->SetPosition(); +} + +TabContents* BlockedPopupContainer::GetTabContentsAt(size_t index) { + return blocked_popups_[index].tab_contents; +} + +std::vector<std::string> BlockedPopupContainer::GetHosts() const { + std::vector<std::string> hosts; + for (PopupHosts::const_iterator i(popup_hosts_.begin()); + i != popup_hosts_.end(); ++i) + hosts.push_back(i->first); + return hosts; +} + // Overridden from TabContentsDelegate: void BlockedPopupContainer::OpenURLFromTab(TabContents* source, const GURL& url, @@ -209,6 +250,7 @@ ExtensionFunctionDispatcher* BlockedPopupContainer:: } void BlockedPopupContainer::HideSelf() { + view_->HideView(); owner_->PopupNotificationVisibilityChanged(false); } @@ -266,7 +308,7 @@ void BlockedPopupContainer::EraseDataForPopupAndUpdateUI( // Erase the popup and update the UI. blocked_popups_.erase(i); - UpdateLabel(); + UpdateView(); } void BlockedPopupContainer::EraseDataForPopupAndUpdateUI( @@ -301,7 +343,7 @@ void BlockedPopupContainer::EraseDataForPopupAndUpdateUI( // Erase the popup and update the UI. unblocked_popups_.erase(i); - UpdateLabel(); + UpdateView(); } @@ -326,6 +368,13 @@ BlockedPopupContainer::BlockedPopupContainer(TabContents* owner, } } +void BlockedPopupContainer::UpdateView() { + if (blocked_popups_.empty() && unblocked_popups_.empty()) + HideSelf(); + else + view_->UpdateLabel(); +} + void BlockedPopupContainer::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { |