| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/blocked_popup_container.h" | 5 #include "chrome/browser/blocked_popup_container.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 7 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
| 9 #include "chrome/browser/tab_contents/tab_contents.h" | 9 #include "chrome/browser/tab_contents/tab_contents.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 #include "chrome/common/pref_service.h" | 11 #include "chrome/common/pref_service.h" |
| 12 #include "chrome/common/notification_service.h" | 12 #include "chrome/common/notification_service.h" |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 BlockedPopupContainer* BlockedPopupContainer::Create( | 15 BlockedPopupContainer* BlockedPopupContainer::Create( |
| 16 TabContents* owner, Profile* profile) { | 16 TabContents* owner, Profile* profile) { |
| 17 BlockedPopupContainer* container = | 17 BlockedPopupContainer* container = |
| 18 new BlockedPopupContainer(owner, profile->GetPrefs()); | 18 new BlockedPopupContainer(owner, profile->GetPrefs()); |
| 19 | 19 |
| 20 // TODO(erg): Add different defined(OS_??) as they get subclasses of | 20 // TODO(port): This ifdef goes away once Mac peeps write a Cocoa |
| 21 // BlockedPopupContainerView. | 21 // implementation of BlockedPopupContainerView. |
| 22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) || defined(OS_LINUX) |
| 23 BlockedPopupContainerView* view = | 23 BlockedPopupContainerView* view = |
| 24 BlockedPopupContainerView::Create(container); | 24 BlockedPopupContainerView::Create(container); |
| 25 container->set_view(view); | 25 container->set_view(view); |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 return container; | 28 return container; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // static | 31 // static |
| 32 void BlockedPopupContainer::RegisterUserPrefs(PrefService* prefs) { | 32 void BlockedPopupContainer::RegisterUserPrefs(PrefService* prefs) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 ClearData(); | 173 ClearData(); |
| 174 GetConstrainingContents(NULL)->WillCloseBlockedPopupContainer(this); | 174 GetConstrainingContents(NULL)->WillCloseBlockedPopupContainer(this); |
| 175 | 175 |
| 176 delete this; | 176 delete this; |
| 177 } | 177 } |
| 178 | 178 |
| 179 void BlockedPopupContainer::RepositionBlockedPopupContainer() { | 179 void BlockedPopupContainer::RepositionBlockedPopupContainer() { |
| 180 view_->SetPosition(); | 180 view_->SetPosition(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 TabContents* BlockedPopupContainer::GetTabContentsAt(size_t index) { | 183 TabContents* BlockedPopupContainer::GetTabContentsAt(size_t index) const { |
| 184 return blocked_popups_[index].tab_contents; | 184 return blocked_popups_[index].tab_contents; |
| 185 } | 185 } |
| 186 | 186 |
| 187 std::vector<std::string> BlockedPopupContainer::GetHosts() const { | 187 std::vector<std::string> BlockedPopupContainer::GetHosts() const { |
| 188 std::vector<std::string> hosts; | 188 std::vector<std::string> hosts; |
| 189 for (PopupHosts::const_iterator i(popup_hosts_.begin()); | 189 for (PopupHosts::const_iterator i(popup_hosts_.begin()); |
| 190 i != popup_hosts_.end(); ++i) | 190 i != popup_hosts_.end(); ++i) |
| 191 hosts.push_back(i->first); | 191 hosts.push_back(i->first); |
| 192 return hosts; | 192 return hosts; |
| 193 } | 193 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 377 |
| 378 void BlockedPopupContainer::Observe(NotificationType type, | 378 void BlockedPopupContainer::Observe(NotificationType type, |
| 379 const NotificationSource& source, | 379 const NotificationSource& source, |
| 380 const NotificationDetails& details) { | 380 const NotificationDetails& details) { |
| 381 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); | 381 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); |
| 382 TabContents* tab_contents = Source<TabContents>(source).ptr(); | 382 TabContents* tab_contents = Source<TabContents>(source).ptr(); |
| 383 UnblockedPopups::iterator i(unblocked_popups_.find(tab_contents)); | 383 UnblockedPopups::iterator i(unblocked_popups_.find(tab_contents)); |
| 384 DCHECK(i != unblocked_popups_.end()); | 384 DCHECK(i != unblocked_popups_.end()); |
| 385 EraseDataForPopupAndUpdateUI(i); | 385 EraseDataForPopupAndUpdateUI(i); |
| 386 } | 386 } |
| OLD | NEW |