Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2771)

Unified Diff: chrome/browser/cocoa/location_bar_view_mac.mm

Issue 500138: [Mac] Implements popups for Page Actions, plus fixes a leak within the Browse... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/location_bar_view_mac.mm
===================================================================
--- chrome/browser/cocoa/location_bar_view_mac.mm (revision 34960)
+++ chrome/browser/cocoa/location_bar_view_mac.mm (working copy)
@@ -17,6 +17,7 @@
#import "chrome/browser/cocoa/autocomplete_text_field.h"
#import "chrome/browser/cocoa/autocomplete_text_field_cell.h"
#include "chrome/browser/cocoa/event_utils.h"
+#import "chrome/browser/cocoa/extensions/extension_popup_controller.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/extensions/extension_browser_event_router.h"
#include "chrome/browser/extensions/extensions_service.h"
@@ -518,7 +519,22 @@
// popup depending on the Page Action.
bool LocationBarViewMac::PageActionImageView::OnMousePressed(NSRect bounds) {
if (page_action_->has_popup()) {
- NOTIMPLEMENTED();
+ AutocompleteTextField* textField = owner_->GetAutocompleteTextField();
+ NSWindow* window = [textField window];
+ NSRect relativeBounds = [[window contentView] convertRect:bounds
+ fromView:textField];
+ NSPoint arrowPoint = [window convertBaseToScreen:NSMakePoint(
+ NSMinX(relativeBounds),
+ NSMinY(relativeBounds))];
+
+ // Adjust the anchor point to be at the center of the page action icon.
+ arrowPoint.x += [GetImage() size].width / 2;
Mark Mentovai 2009/12/18 21:37:25 NSWidth([GetImage() size]) / 2 ?
+
+ popupController_ =
+ [ExtensionPopupController showURL:page_action_->popup_url()
+ inBrowser:BrowserList::GetLastActive()
+ anchoredAt:arrowPoint
+ arrowLocation:kTopRight];
} else {
ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
profile_, page_action_->extension_id(), page_action_->id(),
@@ -607,11 +623,10 @@
switch (type.value) {
case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE:
// If we aren't the host of the popup, then disregard the notification.
- //if (!popup_ || Details<ExtensionHost>(popup_->host()) != details)
- // return;
-
- //HidePopup();
- NOTIMPLEMENTED();
+ if (popupController_ &&
+ Details<ExtensionHost>([popupController_ host]) == details) {
+ HidePopup();
+ }
break;
default:
NOTREACHED() << "Unexpected notification";
@@ -619,6 +634,11 @@
}
}
+void LocationBarViewMac::PageActionImageView::HidePopup() {
+ [popupController_ close];
+ popupController_ = nil;
+}
+
// PageActionViewList-----------------------------------------------------------
void LocationBarViewMac::PageActionViewList::DeleteAll() {
« no previous file with comments | « chrome/browser/cocoa/location_bar_view_mac.h ('k') | chrome/browser/extensions/extension_browser_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698