Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1011)

Unified Diff: chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm

Issue 986333006: Center permission bubble if location bar is hidden in MacOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test names Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..fba3518d9faee19a6dfd883238ce8b7176c92128 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];
+ anchor.y = NSMaxY(content_view.frame);
+ anchor.x = NSMidX(content_view.frame);
+ }
+
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(
+ Browser::FEATURE_LOCATIONBAR);
+ }
+ return false;
+}
+
+info_bubble::BubbleArrowLocation PermissionBubbleCocoa::GetArrowLocation() {
+ return HasLocationBar() ? info_bubble::kTopLeft : info_bubble::kNoArrow;
+}

Powered by Google App Engine
This is Rietveld 408576698