summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/location_bar_view_mac.mm
diff options
context:
space:
mode:
authorskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-27 17:13:15 +0000
committerskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-27 17:13:15 +0000
commita388c4842c880e6e38b0dcfa19d7f6ce33813e2f (patch)
treea1f6f8decb369c778304346319dfa4a9b59ccfb2 /chrome/browser/cocoa/location_bar_view_mac.mm
parentaef0f2d59ae0b1ab954907e53c8ba145e2cd1e1b (diff)
downloadchromium_src-a388c4842c880e6e38b0dcfa19d7f6ce33813e2f.zip
chromium_src-a388c4842c880e6e38b0dcfa19d7f6ce33813e2f.tar.gz
chromium_src-a388c4842c880e6e38b0dcfa19d7f6ce33813e2f.tar.bz2
Page actions should be able to change the popup on a per-tab basis.
This change is a prerequisite to change 545068. BUG=27526 TEST=Added unit tests, manual testing on mac, linux, windows. Review URL: http://codereview.chromium.org/543176 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37257 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.mm29
1 files changed, 18 insertions, 11 deletions
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index aa1b080..f206bda 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -543,7 +543,14 @@ LocationBarViewMac::PageActionImageView::~PageActionImageView() {
// Overridden from LocationBarImageView. Either notify listeners or show a
// popup depending on the Page Action.
bool LocationBarViewMac::PageActionImageView::OnMousePressed(NSRect bounds) {
- if (page_action_->has_popup()) {
+ if (current_tab_id_ < 0) {
+ NOTREACHED() << "No current tab.";
+ // We don't want other code to try and handle this click. Returning true
+ // prevents this by indicating that we handled it.
+ return true;
+ }
+
+ if (page_action_->HasPopup(current_tab_id_)) {
AutocompleteTextField* textField = owner_->GetAutocompleteTextField();
NSWindow* window = [textField window];
NSRect relativeBounds = [[window contentView] convertRect:bounds
@@ -555,16 +562,16 @@ 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_->popup_url()
- inBrowser:BrowserList::GetLastActive()
- anchoredAt:arrowPoint
- arrowLocation:kTopRight];
- } else {
- ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
- profile_, page_action_->extension_id(), page_action_->id(),
- current_tab_id_, current_url_.spec(),
- 1); // TODO(pamg): Add support for middle and right buttons.
+ popup_controller_ = [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(),
+ current_tab_id_, current_url_.spec(),
+ 1);
}
return true;
}