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 NSPoint anchor; | 66 LocationBarViewMac* location_bar = |
67 if (HasLocationBar()) { | 67 [[parent_window_ windowController] locationBarBridge]; |
68 LocationBarViewMac* location_bar = | 68 DCHECK(location_bar); |
69 [[parent_window_ windowController] locationBarBridge]; | 69 NSPoint anchor = location_bar->GetPageInfoBubblePoint(); |
70 anchor = location_bar->GetPageInfoBubblePoint(); | |
71 } else { | |
72 // Center the bubble if there's no location bar. | |
73 NSView* content_view = [parent_window_ contentView]; | |
74 anchor.y = NSMaxY(content_view.frame); | |
75 anchor.x = NSMidX(content_view.frame); | |
76 } | |
77 | |
78 return [parent_window_ convertBaseToScreen:anchor]; | 70 return [parent_window_ convertBaseToScreen:anchor]; |
79 } | 71 } |
80 | 72 |
81 NSWindow* PermissionBubbleCocoa::window() { | 73 NSWindow* PermissionBubbleCocoa::window() { |
82 return [bubbleController_ window]; | 74 return [bubbleController_ window]; |
83 } | 75 } |
84 | 76 |
85 void PermissionBubbleCocoa::SwitchParentWindow(NSWindow* parent) { | 77 void PermissionBubbleCocoa::SwitchParentWindow(NSWindow* parent) { |
86 parent_window_ = parent; | 78 parent_window_ = parent; |
87 } | 79 } |
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( | |
97 Browser::FEATURE_LOCATIONBAR); | |
98 } | |
99 return false; | |
100 } | |
101 | |
102 info_bubble::BubbleArrowLocation PermissionBubbleCocoa::GetArrowLocation() { | |
103 return HasLocationBar() ? info_bubble::kTopLeft : info_bubble::kNoArrow; | |
104 } | |
OLD | NEW |