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

Side by Side Diff: chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.mm

Issue 2233293003: Position Mac permission bubbles on the left when in fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller_private.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h " 5 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h "
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/mac/bind_objc_block.h" 9 #include "base/mac/bind_objc_block.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 const CGFloat kVerticalPermissionPadding = 2.0f; 58 const CGFloat kVerticalPermissionPadding = 2.0f;
59 59
60 const CGFloat kHorizontalPadding = 13.0f; 60 const CGFloat kHorizontalPadding = 13.0f;
61 const CGFloat kVerticalPadding = 15.0f; 61 const CGFloat kVerticalPadding = 15.0f;
62 const CGFloat kBetweenButtonsPadding = 10.0f; 62 const CGFloat kBetweenButtonsPadding = 10.0f;
63 const CGFloat kButtonRightEdgePadding = 17.0f; 63 const CGFloat kButtonRightEdgePadding = 17.0f;
64 const CGFloat kTitlePaddingX = 50.0f; 64 const CGFloat kTitlePaddingX = 50.0f;
65 const CGFloat kBubbleMinWidth = 315.0f; 65 const CGFloat kBubbleMinWidth = 315.0f;
66 const NSSize kPermissionIconSize = {18, 18}; 66 const NSSize kPermissionIconSize = {18, 18};
67 67
68 const NSInteger kFullscreenLeftMargin = 40;
69
68 } // namespace 70 } // namespace
69 71
70 // NSPopUpButton with a menu containing two items: allow and block. 72 // NSPopUpButton with a menu containing two items: allow and block.
71 // One AllowBlockMenuButton is used for each requested permission when there are 73 // One AllowBlockMenuButton is used for each requested permission when there are
72 // multiple permissions in the bubble. 74 // multiple permissions in the bubble.
73 @interface AllowBlockMenuButton : NSPopUpButton { 75 @interface AllowBlockMenuButton : NSPopUpButton {
74 @private 76 @private
75 std::unique_ptr<PermissionMenuModel> menuModel_; 77 std::unique_ptr<PermissionMenuModel> menuModel_;
76 base::scoped_nsobject<MenuController> menuController_; 78 base::scoped_nsobject<MenuController> menuController_;
77 } 79 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 251 }
250 252
251 + (NSPoint)getAnchorPointForBrowser:(Browser*)browser { 253 + (NSPoint)getAnchorPointForBrowser:(Browser*)browser {
252 NSPoint anchor; 254 NSPoint anchor;
253 NSWindow* parentWindow = browser->window()->GetNativeWindow(); 255 NSWindow* parentWindow = browser->window()->GetNativeWindow();
254 if ([PermissionBubbleController hasVisibleLocationBarForBrowser:browser]) { 256 if ([PermissionBubbleController hasVisibleLocationBarForBrowser:browser]) {
255 LocationBarViewMac* location_bar = 257 LocationBarViewMac* location_bar =
256 [[parentWindow windowController] locationBarBridge]; 258 [[parentWindow windowController] locationBarBridge];
257 anchor = location_bar->GetPageInfoBubblePoint(); 259 anchor = location_bar->GetPageInfoBubblePoint();
258 } else { 260 } else {
259 // Center the bubble if there's no location bar. 261 // Position the bubble on the left of the screen if there is no page info
262 // button to point at.
260 NSRect contentFrame = [[parentWindow contentView] frame]; 263 NSRect contentFrame = [[parentWindow contentView] frame];
261 anchor = NSMakePoint(NSMidX(contentFrame), NSMaxY(contentFrame)); 264 anchor = NSMakePoint(NSMinX(contentFrame) + kFullscreenLeftMargin,
265 NSMaxY(contentFrame));
262 } 266 }
263 267
264 return ui::ConvertPointFromWindowToScreen(parentWindow, anchor); 268 return ui::ConvertPointFromWindowToScreen(parentWindow, anchor);
265 } 269 }
266 270
267 + (bool)hasVisibleLocationBarForBrowser:(Browser*)browser { 271 + (bool)hasVisibleLocationBarForBrowser:(Browser*)browser {
268 if (!browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) 272 if (!browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR))
269 return false; 273 return false;
270 274
271 if (!browser->exclusive_access_manager()->context()->IsFullscreen()) 275 if (!browser->exclusive_access_manager()->context()->IsFullscreen())
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 481
478 - (NSPoint)getExpectedAnchorPoint { 482 - (NSPoint)getExpectedAnchorPoint {
479 return [PermissionBubbleController getAnchorPointForBrowser:browser_]; 483 return [PermissionBubbleController getAnchorPointForBrowser:browser_];
480 } 484 }
481 485
482 - (bool)hasVisibleLocationBar { 486 - (bool)hasVisibleLocationBar {
483 return [PermissionBubbleController hasVisibleLocationBarForBrowser:browser_]; 487 return [PermissionBubbleController hasVisibleLocationBarForBrowser:browser_];
484 } 488 }
485 489
486 - (info_bubble::BubbleArrowLocation)getExpectedArrowLocation { 490 - (info_bubble::BubbleArrowLocation)getExpectedArrowLocation {
487 return [self hasVisibleLocationBar] ? info_bubble::kTopLeft 491 return info_bubble::kTopLeft;
tapted 2016/08/11 23:51:20 does this mean that there will be an arrow in full
benwells 2016/08/12 04:13:43 Yep, that's what it means. This matches the views
488 : info_bubble::kNoArrow;
489 } 492 }
490 493
491 - (NSWindow*)getExpectedParentWindow { 494 - (NSWindow*)getExpectedParentWindow {
492 DCHECK(browser_->window()); 495 DCHECK(browser_->window());
493 return browser_->window()->GetNativeWindow(); 496 return browser_->window()->GetNativeWindow();
494 } 497 }
495 498
496 - (NSView*)labelForRequest:(PermissionRequest*)request { 499 - (NSView*)labelForRequest:(PermissionRequest*)request {
497 DCHECK(request); 500 DCHECK(request);
498 base::scoped_nsobject<NSView> permissionView( 501 base::scoped_nsobject<NSView> permissionView(
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 642
640 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { 643 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB {
641 NSRect frameA = [viewA frame]; 644 NSRect frameA = [viewA frame];
642 NSRect frameB = [viewB frame]; 645 NSRect frameB = [viewB frame];
643 frameA.origin.y = 646 frameA.origin.y =
644 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); 647 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2);
645 [viewA setFrameOrigin:frameA.origin]; 648 [viewA setFrameOrigin:frameA.origin];
646 } 649 }
647 650
648 @end // implementation PermissionBubbleController 651 @end // implementation PermissionBubbleController
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller_private.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698