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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/cocoa/bubble_anchor_helper.h"
6
7 #import <Cocoa/Cocoa.h>
8
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
13 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
14 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
15 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
16 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
17 #include "chrome/common/pref_names.h"
18 #include "components/prefs/pref_service.h"
19 #import "ui/base/cocoa/cocoa_base_utils.h"
20
21 namespace {
22
23 // Offset from the screen edge to show dialogs when there is no location bar.
24 // Don't center, since that could obscure a fullscreen bubble.
25 constexpr NSInteger kFullscreenLeftOffset = 40;
26
27 } // namespace
28
29 bool HasVisibleLocationBarForBrowser(Browser* browser) {
30 if (!browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR))
31 return false;
32
33 if (!browser->exclusive_access_manager()->context()->IsFullscreen())
34 return true;
35
36 // If the browser is in browser-initiated full screen, a preference can cause
37 // the toolbar to be hidden.
38 if (browser->exclusive_access_manager()
39 ->fullscreen_controller()
40 ->IsFullscreenForBrowser()) {
41 PrefService* prefs = browser->profile()->GetPrefs();
42 bool show_toolbar = prefs->GetBoolean(prefs::kShowFullscreenToolbar);
43 return show_toolbar;
44 }
45
46 // Otherwise this is fullscreen without a toolbar, so there is no visible
47 // location bar.
48 return false;
49 }
50
51 NSPoint GetPermissionBubbleAnchorPointForBrowser(Browser* browser,
52 bool has_location_bar) {
53 NSPoint anchor;
54 NSWindow* parentWindow = browser->window()->GetNativeWindow();
55 if (has_location_bar) {
56 LocationBarViewMac* location_bar =
57 [[parentWindow windowController] locationBarBridge];
58 anchor = location_bar->GetPageInfoBubblePoint();
59 } else {
60 // Position the bubble on the left of the screen if there is no page info
61 // button to point at.
62 NSRect contentFrame = [[parentWindow contentView] frame];
63 anchor = NSMakePoint(NSMinX(contentFrame) + kFullscreenLeftOffset,
64 NSMaxY(contentFrame));
65 }
66
67 return ui::ConvertPointFromWindowToScreen(parentWindow, anchor);
68 }
OLDNEW
« 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