summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/location_bar_view_mac.mm
diff options
context:
space:
mode:
authorandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-02 20:59:20 +0000
committerandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-02 20:59:20 +0000
commitfac15c494ac3cacfcd905e8bc186ef212ad943e3 (patch)
tree5d24e981bb9aec910946a1499e14a33b493502f3 /chrome/browser/cocoa/location_bar_view_mac.mm
parent8471424148c07642dee2796673feb2d66be75074 (diff)
downloadchromium_src-fac15c494ac3cacfcd905e8bc186ef212ad943e3.zip
chromium_src-fac15c494ac3cacfcd905e8bc186ef212ad943e3.tar.gz
chromium_src-fac15c494ac3cacfcd905e8bc186ef212ad943e3.tar.bz2
[Mac] Make the extension popup a singleton instance to avoid maintaining multiple pointer references to a class that, by design, can only have one popup open at a time.
The bug fixed in this change has to do with PageActionView having a dirty pointer to a popup if it was closed via losing its key state. Once a notification like EXTENSION_HOST_VIEW_SHOULD_CLOSE was fired, then the PageActionView would assume the pointer was valid and call on dirty memory. TEST=none BUG=29492,33590 Review URL: http://codereview.chromium.org/561013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37873 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/location_bar_view_mac.mm')
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm26
1 files changed, 10 insertions, 16 deletions
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index ec592cb..2547c27 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -562,7 +562,6 @@ LocationBarViewMac::PageActionImageView::PageActionImageView(
: owner_(owner),
profile_(profile),
page_action_(page_action),
- popup_controller_(nil),
current_tab_id_(-1),
preview_enabled_(false) {
Extension* extension = profile->GetExtensionsService()->GetExtensionById(
@@ -627,11 +626,10 @@ bool LocationBarViewMac::PageActionImageView::OnMousePressed(NSRect bounds) {
// Adjust the anchor point to be at the center of the page action icon.
arrowPoint.x += [GetImage() size].width / 2;
- popup_controller_ = [ExtensionPopupController
- showURL:page_action_->GetPopupUrl(current_tab_id_)
- inBrowser:BrowserList::GetLastActive()
- anchoredAt:arrowPoint
- arrowLocation:kTopRight];
+ [ExtensionPopupController showURL:page_action_->GetPopupUrl(current_tab_id_)
+ inBrowser:BrowserList::GetLastActive()
+ anchoredAt:arrowPoint
+ arrowLocation:kTopRight];
} else {
ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
profile_, page_action_->extension_id(), page_action_->id(),
@@ -738,23 +736,19 @@ void LocationBarViewMac::PageActionImageView::Observe(
const NotificationSource& source,
const NotificationDetails& details) {
switch (type.value) {
- case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE:
- if (popup_controller_ &&
- Details<ExtensionHost>([popup_controller_ host]) == details) {
- HidePopup();
- }
+ case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE: {
+ ExtensionPopupController* popup = [ExtensionPopupController popup];
+ if (popup && ![popup isClosing])
+ [popup close];
+
break;
+ }
default:
NOTREACHED() << "Unexpected notification";
break;
}
}
-void LocationBarViewMac::PageActionImageView::HidePopup() {
- [popup_controller_ close];
- popup_controller_ = nil;
-}
-
// PageActionViewList-----------------------------------------------------------
void LocationBarViewMac::PageActionViewList::DeleteAll() {