diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-21 21:55:36 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-21 21:55:36 +0000 |
commit | 7101d7b13c6a3318e573c3f358853a0d67d5adc9 (patch) | |
tree | 4c93e45ae0121241eee17605f1e091584bae9215 /chrome | |
parent | c916426ad0439af17dfb864d7731bfff11badaac (diff) | |
download | chromium_src-7101d7b13c6a3318e573c3f358853a0d67d5adc9.zip chromium_src-7101d7b13c6a3318e573c3f358853a0d67d5adc9.tar.gz chromium_src-7101d7b13c6a3318e573c3f358853a0d67d5adc9.tar.bz2 |
[Mac] Fixes a bug where an ExtensionPopupController object's pointer was never being nil'd out when it resigned its key state, leading to a obj_msgSend from a dirty pointer. Also makes sure that other areas of Page Action code are properly using nil instead of NULL where necessary.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/508010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35109 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
4 files changed, 19 insertions, 12 deletions
diff --git a/chrome/browser/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/cocoa/extensions/browser_actions_controller.mm index 66b0d5b..ac6ae70 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_controller.mm +++ b/chrome/browser/cocoa/extensions/browser_actions_controller.mm @@ -281,11 +281,13 @@ class ExtensionsServiceObserverBridge : public NotificationObserver { [owner_ browserActionVisibilityHasChanged]; break; } - case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE: - if (Details<ExtensionHost>([[owner_ popup] host]) != details) - return; - [owner_ hidePopup]; + case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE: { + ExtensionPopupController* popup = [owner_ popup]; + if (popup && Details<ExtensionHost>([popup host]) == details) + [owner_ hidePopup]; + break; + } default: NOTREACHED() << L"Unexpected notification"; } diff --git a/chrome/browser/cocoa/extensions/extension_popup_controller.mm b/chrome/browser/cocoa/extensions/extension_popup_controller.mm index b2bc489..204c755 100644 --- a/chrome/browser/cocoa/extensions/extension_popup_controller.mm +++ b/chrome/browser/cocoa/extensions/extension_popup_controller.mm @@ -13,6 +13,7 @@ #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/profile.h" +#include "chrome/common/notification_service.h" // The minimum/maximum dimensions of the popup. // The minimum is just a little larger than the size of the button itself. @@ -95,7 +96,10 @@ const NSTimeInterval kAnimationDuration = 0.2; - (void)windowDidResignKey:(NSNotification *)notification { DCHECK_EQ([notification object], [self window]); - [self close]; + NotificationService::current()->Notify( + NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, + Source<Profile>(host_->profile()), + Details<ExtensionHost>(host_.get())); } - (void)close { diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h index c2af2dd..f39978f 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.h +++ b/chrome/browser/cocoa/location_bar_view_mac.h @@ -200,6 +200,7 @@ class LocationBarViewMac : public AutocompleteEditController, PageActionImageView() : owner_(NULL), profile_(NULL), page_action_(NULL), + popup_controller_(nil), tracker_(NULL), current_tab_id_(-1), preview_enabled_(false) {} @@ -226,7 +227,7 @@ class LocationBarViewMac : public AutocompleteEditController, PageActionMap page_action_icons_; // The controller for the popup displayed if a page action has one. Weak. - ExtensionPopupController* popupController_; + ExtensionPopupController* popup_controller_; // The object that is waiting for the image loading to complete // asynchronously. diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm index ced4a82..4828cba 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar_view_mac.mm @@ -486,6 +486,7 @@ 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( @@ -530,7 +531,7 @@ 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; - popupController_ = + popup_controller_ = [ExtensionPopupController showURL:page_action_->popup_url() inBrowser:BrowserList::GetLastActive() anchoredAt:arrowPoint @@ -622,9 +623,8 @@ void LocationBarViewMac::PageActionImageView::Observe( const NotificationDetails& details) { switch (type.value) { case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE: - // If we aren't the host of the popup, then disregard the notification. - if (popupController_ && - Details<ExtensionHost>([popupController_ host]) == details) { + if (popup_controller_ && + Details<ExtensionHost>([popup_controller_ host]) == details) { HidePopup(); } break; @@ -635,8 +635,8 @@ void LocationBarViewMac::PageActionImageView::Observe( } void LocationBarViewMac::PageActionImageView::HidePopup() { - [popupController_ close]; - popupController_ = nil; + [popup_controller_ close]; + popup_controller_ = nil; } // PageActionViewList----------------------------------------------------------- |