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

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 (swizzling tests) 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 const NSInteger kFullscreenLeftOffset = 40;
tapted 2017/05/03 09:09:11 nit: constexpr Also, comment here like // Offset
varkha 2017/05/03 09:22:40 Done.
24
25 } // namespace
26
27 bool HasVisibleLocationBarForBrowser(Browser* browser) {
28 if (!browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR))
29 return false;
30
31 if (!browser->exclusive_access_manager()->context()->IsFullscreen())
32 return true;
33
34 // If the browser is in browser-initiated full screen, a preference can cause
35 // the toolbar to be hidden.
36 if (browser->exclusive_access_manager()
37 ->fullscreen_controller()
38 ->IsFullscreenForBrowser()) {
39 PrefService* prefs = browser->profile()->GetPrefs();
40 bool show_toolbar = prefs->GetBoolean(prefs::kShowFullscreenToolbar);
41 return show_toolbar;
42 }
43
44 // Otherwise this is fullscreen without a toolbar, so there is no visible
45 // location bar.
46 return false;
47 }
48
49 NSPoint GetPermissionBubbleAnchorPointForBrowser(Browser* browser,
50 bool has_location_bar) {
51 NSPoint anchor;
52 NSWindow* parentWindow = browser->window()->GetNativeWindow();
53 if (has_location_bar) {
54 LocationBarViewMac* location_bar =
55 [[parentWindow windowController] locationBarBridge];
56 anchor = location_bar->GetPageInfoBubblePoint();
57 } else {
58 // Position the bubble on the left of the screen if there is no page info
59 // button to point at.
60 NSRect contentFrame = [[parentWindow contentView] frame];
61 anchor = NSMakePoint(NSMinX(contentFrame) + kFullscreenLeftOffset,
62 NSMaxY(contentFrame));
63 }
64
65 return ui::ConvertPointFromWindowToScreen(parentWindow, anchor);
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698