Commit 86f44680 authored by skerner@chromium.org's avatar skerner@chromium.org

Ensure that a browser action is never passed to a function which expects a page action.

(Changed review name, because the solution has changed)

BUG=53041
TEST=On a mac, install a browser action and a page action, right click on each icon, select "Inspect Popup".

Review URL: http://codereview.chromium.org/3176021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57048 0039d316-1c4b-4281-b951-d872f2087c98
parent ae72160f
......@@ -241,13 +241,18 @@ int CurrentTabId() {
[window->cocoa_controller() toolbarController];
LocationBarViewMac* locationBarView =
[toolbarController locationBarBridge];
NSPoint popupPoint = locationBarView->GetPageActionBubblePoint(action_);
// If there was no matching page action, it was a browser action.
if (NSEqualPoints(popupPoint, NSZeroPoint)) {
NSPoint popupPoint = NSZeroPoint;
if (extension_->page_action() == action_) {
popupPoint = locationBarView->GetPageActionBubblePoint(action_);
} else if (extension_->browser_action() == action_) {
BrowserActionsController* controller =
[toolbarController browserActionsController];
popupPoint = [controller popupPointForBrowserAction:extension_];
} else {
NOTREACHED() << "action_ is not a page action or browser action?";
}
int tabId = CurrentTabId();
......
......@@ -110,7 +110,9 @@ class LocationBarViewMac : public AutocompleteEditController,
bool preview_enabled);
// Return |page_action|'s info-bubble point in window coordinates.
// Returns |NSZeroPoint| if |page_action| is not present.
// This function should always be called with a visible page action.
// If |page_action| is not a page action or not visible, NOTREACHED()
// is called and this function returns |NSZeroPoint|.
NSPoint GetPageActionBubblePoint(ExtensionAction* page_action);
// Get the blocked-popup content setting's frame in window
......
......@@ -287,6 +287,8 @@ PageActionDecoration* LocationBarViewMac::GetPageActionDecoration(
if (page_action_decorations_[i]->page_action() == page_action)
return page_action_decorations_[i];
}
// If |page_action| is the browser action of an extension, no element in
// |page_action_decorations_| will match.
NOTREACHED();
return NULL;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment