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, ...@@ -213,7 +213,9 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver,
if (!extension) if (!extension)
break; break;
BrowserActionButton* button = [owner_ buttonForExtension:extension]; 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; break;
} }
default: default:
......
...@@ -411,7 +411,6 @@ NSRect LocationBarViewMac::GetPageActionFrame(ExtensionAction* page_action) { ...@@ -411,7 +411,6 @@ NSRect LocationBarViewMac::GetPageActionFrame(ExtensionAction* page_action) {
AutocompleteTextFieldCell* cell = [field_ cell]; AutocompleteTextFieldCell* cell = [field_ cell];
NSRect frame = [cell frameForDecoration:decoration inFrame:[field_ bounds]]; NSRect frame = [cell frameForDecoration:decoration inFrame:[field_ bounds]];
DCHECK(!NSIsEmptyRect(frame));
return frame; return frame;
} }
...@@ -422,8 +421,13 @@ NSPoint LocationBarViewMac::GetPageActionBubblePoint( ...@@ -422,8 +421,13 @@ NSPoint LocationBarViewMac::GetPageActionBubblePoint(
return NSZeroPoint; return NSZeroPoint;
NSRect frame = GetPageActionFrame(page_action); 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; return NSZeroPoint;
}
NSPoint bubble_point = decoration->GetBubblePointInFrame(frame); NSPoint bubble_point = decoration->GetBubblePointInFrame(frame);
return [field_ convertPoint:bubble_point toView:nil]; return [field_ convertPoint:bubble_point toView:nil];
......
...@@ -285,8 +285,8 @@ void PageActionDecoration::Observe( ...@@ -285,8 +285,8 @@ void PageActionDecoration::Observe(
break; break;
if (extension_id != page_action_->extension_id()) if (extension_id != page_action_->extension_id())
break; break;
NSRect frame = owner_->GetPageActionFrame(page_action_); if (IsVisible())
ActivatePageAction(frame); ActivatePageAction(owner_->GetPageActionFrame(page_action_));
break; 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