Commit 103c6801 authored by finnur@chromium.org's avatar finnur@chromium.org

Don't show the button for hidden page/browser actions or script badges.

Browser Action, Page Actions and Script Badges can be hidden, which causes us to get invalid |button| and |frame| (respectively). We'll need to figure out what to do in these cases (on all platforms) but the minimum for now is to ignore the keystroke to avoid a crash. 

BUG=140396
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10828364

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152321 0039d316-1c4b-4281-b951-d872f2087c98
parent 77086caa
......@@ -213,7 +213,9 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver,
if (!extension)
break;
BrowserActionButton* button = [owner_ buttonForExtension:extension];
[owner_ browserActionClicked:button];
// |button| can be nil when the browser action has its button hidden.
if (button)
[owner_ browserActionClicked:button];
break;
}
default:
......
......@@ -411,7 +411,6 @@ NSRect LocationBarViewMac::GetPageActionFrame(ExtensionAction* page_action) {
AutocompleteTextFieldCell* cell = [field_ cell];
NSRect frame = [cell frameForDecoration:decoration inFrame:[field_ bounds]];
DCHECK(!NSIsEmptyRect(frame));
return frame;
}
......@@ -422,8 +421,13 @@ NSPoint LocationBarViewMac::GetPageActionBubblePoint(
return NSZeroPoint;
NSRect frame = GetPageActionFrame(page_action);
if (NSIsEmptyRect(frame))
if (NSIsEmptyRect(frame)) {
// The bubble point positioning assumes that the page action is visible. If
// not, something else needs to be done otherwise the bubble will appear
// near the top left corner (unanchored).
NOTREACHED();
return NSZeroPoint;
}
NSPoint bubble_point = decoration->GetBubblePointInFrame(frame);
return [field_ convertPoint:bubble_point toView:nil];
......
......@@ -285,8 +285,8 @@ void PageActionDecoration::Observe(
break;
if (extension_id != page_action_->extension_id())
break;
NSRect frame = owner_->GetPageActionFrame(page_action_);
ActivatePageAction(frame);
if (IsVisible())
ActivatePageAction(owner_->GetPageActionFrame(page_action_));
break;
}
......
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