summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/extensions/browser_actions_controller.mm10
-rw-r--r--chrome/browser/cocoa/extensions/extension_popup_controller.mm6
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.h3
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm12
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-----------------------------------------------------------