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

Unified Diff: chrome/browser/ui/cocoa/bubble_anchor_helper.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/bubble_anchor_helper.mm
diff --git a/chrome/browser/ui/cocoa/bubble_anchor_helper.mm b/chrome/browser/ui/cocoa/bubble_anchor_helper.mm
new file mode 100644
index 0000000000000000000000000000000000000000..0a26933090b46863c6a04f24a3db761c926aa94d
--- /dev/null
+++ b/chrome/browser/ui/cocoa/bubble_anchor_helper.mm
@@ -0,0 +1,68 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/cocoa/bubble_anchor_helper.h"
+
+#import <Cocoa/Cocoa.h>
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_window.h"
+#import "chrome/browser/ui/cocoa/browser_window_controller.h"
+#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
+#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_service.h"
+#import "ui/base/cocoa/cocoa_base_utils.h"
+
+namespace {
+
+// Offset from the screen edge to show dialogs when there is no location bar.
+// Don't center, since that could obscure a fullscreen bubble.
+constexpr NSInteger kFullscreenLeftOffset = 40;
+
+} // namespace
+
+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;
+}
+
+NSPoint GetPermissionBubbleAnchorPointForBrowser(Browser* browser,
+ bool has_location_bar) {
+ NSPoint anchor;
+ NSWindow* parentWindow = browser->window()->GetNativeWindow();
+ if (has_location_bar) {
+ 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);
+}
« no previous file with comments | « chrome/browser/ui/cocoa/bubble_anchor_helper.h ('k') | chrome/browser/ui/cocoa/permission_bubble/chooser_bubble_ui_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698