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

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: Attempt to fix failures in new tests Created 5 years, 9 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..4b415a98620311f159da7bf560a0e7f8ba42c0cb 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,19 @@ 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];
+ DCHECK(location_bar);
+ anchor = location_bar->GetPageInfoBubblePoint();
+ } else {
+ // Center the bubble if there's no location bar.
+ NSView* content_view = parent_window_.contentView;
+ anchor.y = content_view.frame.size.height;
+ anchor.x = (content_view.frame.size.width) / 2;
+ }
+
return [parent_window_ convertBaseToScreen:anchor];
}
@@ -77,3 +86,17 @@ NSWindow* PermissionBubbleCocoa::window() {
void PermissionBubbleCocoa::SwitchParentWindow(NSWindow* parent) {
parent_window_ = parent;
}
+
+bool PermissionBubbleCocoa::HasLocationBar() {
+ LocationBarViewMac* location_bar =
+ [[parent_window_ windowController] locationBarBridge];
+ if (location_bar) {
groby-ooo-7-16 2015/04/01 00:19:14 Please add a comment why even if we have a locatio
hcarmona 2015/04/02 01:30:14 Done.
+ return location_bar->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