Chromium Code Reviews| Index: chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm |
| diff --git a/chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm b/chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm |
| index 821ddcad6490138052970976561d42895480dfeb..63933b13e24b4bdef21e8941c4ad61fe3e1e949d 100644 |
| --- a/chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm |
| +++ b/chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm |
| @@ -63,10 +63,18 @@ void PermissionBubbleCocoa::OnBubbleClosing() { |
| } |
| NSPoint PermissionBubbleCocoa::GetAnchorPoint() { |
| - LocationBarViewMac* location_bar = |
| - [[parent_window_ windowController] locationBarBridge]; |
| - DCHECK(location_bar); |
| - NSPoint anchor = location_bar->GetPageInfoBubblePoint(); |
| + NSPoint anchor; |
| + if (HasLocationBar()) { |
| + LocationBarViewMac* location_bar = |
| + [[parent_window_ windowController] locationBarBridge]; |
| + anchor = location_bar->GetPageInfoBubblePoint(); |
| + } else { |
| + // Center the bubble if there's no location bar. |
| + NSView* content_view = parent_window_.contentView; |
|
groby-ooo-7-16
2015/04/10 20:58:55
[parent_window_ contentView];
hcarmona
2015/04/13 21:13:24
Done.
|
| + anchor.y = content_view.frame.size.height; |
|
groby-ooo-7-16
2015/04/10 20:58:55
NSMaxY([content_view frame]); (This is not height,
hcarmona
2015/04/13 21:13:24
Done.
|
| + anchor.x = (content_view.frame.size.width) / 2; |
|
groby-ooo-7-16
2015/04/10 20:58:55
NSMidX([content_view frame]);
hcarmona
2015/04/13 21:13:24
Done.
|
| + } |
| + |
| return [parent_window_ convertBaseToScreen:anchor]; |
| } |
| @@ -77,3 +85,20 @@ NSWindow* PermissionBubbleCocoa::window() { |
| void PermissionBubbleCocoa::SwitchParentWindow(NSWindow* parent) { |
| parent_window_ = parent; |
| } |
| + |
| +bool PermissionBubbleCocoa::HasLocationBar() { |
| + LocationBarViewMac* location_bar_bridge = |
| + [[parent_window_ windowController] locationBarBridge]; |
| + if (location_bar_bridge) { |
| + // It is necessary to check that the location bar bridge will actually |
| + // support the location bar. This is important because an application window |
| + // will have a location_bar_bridge but not have a location bar. |
| + return location_bar_bridge->browser()->SupportsWindowFeature( |
|
groby-ooo-7-16
2015/04/08 18:39:15
I'm wondering if we shouldn't simply pass the brow
hcarmona
2015/04/10 18:54:07
|parent_window_| can be updated. When that happens
groby-ooo-7-16
2015/04/10 20:58:55
In what case would that happen?
hcarmona
2015/04/13 21:13:24
This can happen when a site requests to transition
|
| + Browser::FEATURE_LOCATIONBAR); |
| + } |
| + return false; |
| +} |
| + |
| +info_bubble::BubbleArrowLocation PermissionBubbleCocoa::GetArrowLocation() { |
|
groby-ooo-7-16
2015/04/08 18:39:15
Is there any way we can hoist this policy out into
hcarmona
2015/04/10 18:54:07
In cocoa we use info_bubble::BubbleArrowLocation
h
groby-ooo-7-16
2015/04/10 20:58:55
Please file a bug for that so we don't forget :)
hcarmona
2015/04/13 21:13:24
Done. crbug.com/476662
|
| + return HasLocationBar() ? info_bubble::kTopLeft : info_bubble::kNoArrow; |
|
groby-ooo-7-16
2015/04/10 20:58:55
Sigh. I'm slow, sorry - I only just realized that
hcarmona
2015/04/13 21:13:24
We should return kNoArrow to avoid having an arrow
|
| +} |