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

Unified Diff: chrome/browser/ui/cocoa/permission_bubble/permission_bubble_controller.mm

Issue 2853143003: MacViews: Allows the toolkit-views Device Chooser bubble to be used (Closed)
Patch Set: MacViews: Allows the toolkit-views Device Chooser bubble to be used (nits) Created 3 years, 7 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/permission_bubble/permission_bubble_controller.mm
diff --git a/chrome/browser/ui/cocoa/permission_bubble/permission_bubble_controller.mm b/chrome/browser/ui/cocoa/permission_bubble/permission_bubble_controller.mm
index 339f2ebe013e9950b5a451b5260c8562807a7b53..e0b158911316cdbac2a2eab1c9db978aadf5ee53 100644
--- a/chrome/browser/ui/cocoa/permission_bubble/permission_bubble_controller.mm
+++ b/chrome/browser/ui/cocoa/permission_bubble/permission_bubble_controller.mm
@@ -16,6 +16,7 @@
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/browser_window_utils.h"
+#import "chrome/browser/ui/cocoa/bubble_anchor_helper.h"
#import "chrome/browser/ui/cocoa/chrome_style.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
#import "chrome/browser/ui/cocoa/hover_close_button.h"
@@ -69,8 +70,6 @@ const CGFloat kTitlePaddingX = 50.0f;
const CGFloat kBubbleMinWidth = 315.0f;
const NSSize kPermissionIconSize = {18, 18};
-const NSInteger kFullscreenLeftOffset = 40;
-
} // namespace
// NSPopUpButton with a menu containing two items: allow and block.
@@ -185,10 +184,6 @@ const NSInteger kFullscreenLeftOffset = 40;
// Called when the 'close' button is pressed.
- (void)onClose:(id)sender;
-// Returns the constant offset from the left to use for fullscreen permission
-// bubbles. Only used in tests.
-+ (NSInteger)getFullscreenLeftOffset;
-
// Sets the width of both |viewA| and |viewB| to be the larger of the
// two views' widths. Does not change either view's origin or height.
+ (CGFloat)matchWidthsOf:(NSView*)viewA andOf:(NSView*)viewB;
@@ -233,43 +228,13 @@ const NSInteger kFullscreenLeftOffset = 40;
}
+ (NSPoint)getAnchorPointForBrowser:(Browser*)browser {
- NSPoint anchor;
- NSWindow* parentWindow = browser->window()->GetNativeWindow();
- if ([PermissionBubbleController hasVisibleLocationBarForBrowser:browser]) {
- LocationBarViewMac* location_bar =
- [[parentWindow windowController] locationBarBridge];
- anchor = location_bar->GetPageInfoBubblePoint();
- } else {
- // Position the bubble on the left of the screen if there is no page info
- // button to point at.
- NSRect contentFrame = [[parentWindow contentView] frame];
- anchor = NSMakePoint(NSMinX(contentFrame) + kFullscreenLeftOffset,
- NSMaxY(contentFrame));
- }
-
- return ui::ConvertPointFromWindowToScreen(parentWindow, anchor);
+ return GetPermissionBubbleAnchorPointForBrowser(
+ browser,
+ [PermissionBubbleController hasVisibleLocationBarForBrowser:browser]);
}
+ (bool)hasVisibleLocationBarForBrowser:(Browser*)browser {
- if (!browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR))
- return false;
-
- if (!browser->exclusive_access_manager()->context()->IsFullscreen())
- return true;
-
- // If the browser is in browser-initiated full screen, a preference can cause
- // the toolbar to be hidden.
- if (browser->exclusive_access_manager()
- ->fullscreen_controller()
- ->IsFullscreenForBrowser()) {
- PrefService* prefs = browser->profile()->GetPrefs();
- bool show_toolbar = prefs->GetBoolean(prefs::kShowFullscreenToolbar);
- return show_toolbar;
- }
-
- // Otherwise this is fullscreen without a toolbar, so there is no visible
- // location bar.
- return false;
+ return HasVisibleLocationBarForBrowser(browser);
}
- (void)windowWillClose:(NSNotification*)notification {
@@ -630,10 +595,6 @@ const NSInteger kFullscreenLeftOffset = 40;
delegate_->Closing();
}
-+ (NSInteger)getFullscreenLeftOffset {
- return kFullscreenLeftOffset;
-}
-
- (void)activateTabWithContents:(content::WebContents*)newContents
previousContents:(content::WebContents*)oldContents
atIndex:(NSInteger)index

Powered by Google App Engine
This is Rietveld 408576698