OLD | NEW |
---|---|
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 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | 7 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
9 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 9 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
10 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h " | 10 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h " |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 // TODO(gbillock): implement. Should return true if the mouse is not over the | 56 // TODO(gbillock): implement. Should return true if the mouse is not over the |
57 // dialog. | 57 // dialog. |
58 return false; | 58 return false; |
59 } | 59 } |
60 | 60 |
61 void PermissionBubbleCocoa::OnBubbleClosing() { | 61 void PermissionBubbleCocoa::OnBubbleClosing() { |
62 bubbleController_ = nil; | 62 bubbleController_ = nil; |
63 } | 63 } |
64 | 64 |
65 NSPoint PermissionBubbleCocoa::GetAnchorPoint() { | 65 NSPoint PermissionBubbleCocoa::GetAnchorPoint() { |
66 LocationBarViewMac* location_bar = | 66 NSPoint anchor; |
67 [[parent_window_ windowController] locationBarBridge]; | 67 if (HasLocationBar()) { |
68 DCHECK(location_bar); | 68 LocationBarViewMac* location_bar = |
69 NSPoint anchor = location_bar->GetPageInfoBubblePoint(); | 69 [[parent_window_ windowController] locationBarBridge]; |
70 anchor = location_bar->GetPageInfoBubblePoint(); | |
71 } else { | |
72 // Center the bubble if there's no location bar. | |
73 NSView* content_view = parent_window_.contentView; | |
groby-ooo-7-16
2015/04/10 20:58:55
[parent_window_ contentView];
hcarmona
2015/04/13 21:13:24
Done.
| |
74 anchor.y = content_view.frame.size.height; | |
groby-ooo-7-16
2015/04/10 20:58:55
NSMaxY([content_view frame]); (This is not height,
hcarmona
2015/04/13 21:13:24
Done.
| |
75 anchor.x = (content_view.frame.size.width) / 2; | |
groby-ooo-7-16
2015/04/10 20:58:55
NSMidX([content_view frame]);
hcarmona
2015/04/13 21:13:24
Done.
| |
76 } | |
77 | |
70 return [parent_window_ convertBaseToScreen:anchor]; | 78 return [parent_window_ convertBaseToScreen:anchor]; |
71 } | 79 } |
72 | 80 |
73 NSWindow* PermissionBubbleCocoa::window() { | 81 NSWindow* PermissionBubbleCocoa::window() { |
74 return [bubbleController_ window]; | 82 return [bubbleController_ window]; |
75 } | 83 } |
76 | 84 |
77 void PermissionBubbleCocoa::SwitchParentWindow(NSWindow* parent) { | 85 void PermissionBubbleCocoa::SwitchParentWindow(NSWindow* parent) { |
78 parent_window_ = parent; | 86 parent_window_ = parent; |
79 } | 87 } |
88 | |
89 bool PermissionBubbleCocoa::HasLocationBar() { | |
90 LocationBarViewMac* location_bar_bridge = | |
91 [[parent_window_ windowController] locationBarBridge]; | |
92 if (location_bar_bridge) { | |
93 // It is necessary to check that the location bar bridge will actually | |
94 // support the location bar. This is important because an application window | |
95 // will have a location_bar_bridge but not have a location bar. | |
96 return location_bar_bridge->browser()->SupportsWindowFeature( | |
groby-ooo-7-16
2015/04/08 18:39:15
I'm wondering if we shouldn't simply pass the brow
hcarmona
2015/04/10 18:54:07
|parent_window_| can be updated. When that happens
groby-ooo-7-16
2015/04/10 20:58:55
In what case would that happen?
hcarmona
2015/04/13 21:13:24
This can happen when a site requests to transition
| |
97 Browser::FEATURE_LOCATIONBAR); | |
98 } | |
99 return false; | |
100 } | |
101 | |
102 info_bubble::BubbleArrowLocation PermissionBubbleCocoa::GetArrowLocation() { | |
groby-ooo-7-16
2015/04/08 18:39:15
Is there any way we can hoist this policy out into
hcarmona
2015/04/10 18:54:07
In cocoa we use info_bubble::BubbleArrowLocation
h
groby-ooo-7-16
2015/04/10 20:58:55
Please file a bug for that so we don't forget :)
hcarmona
2015/04/13 21:13:24
Done. crbug.com/476662
| |
103 return HasLocationBar() ? info_bubble::kTopLeft : info_bubble::kNoArrow; | |
groby-ooo-7-16
2015/04/10 20:58:55
Sigh. I'm slow, sorry - I only just realized that
hcarmona
2015/04/13 21:13:24
We should return kNoArrow to avoid having an arrow
| |
104 } | |
OLD | NEW |