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 (HasOmnibar()) { |
68 DCHECK(location_bar); | 68 LocationBarViewMac* location_bar = |
69 NSPoint anchor = location_bar->GetPageInfoBubblePoint(); | 69 [[parent_window_ windowController] locationBarBridge]; |
| 70 DCHECK(location_bar); |
| 71 anchor = location_bar->GetPageInfoBubblePoint(); |
| 72 } else { |
| 73 // Center the bubble if there's no omnibar. |
| 74 NSView* content_view = parent_window_.contentView; |
| 75 anchor.y = content_view.frame.size.height; |
| 76 anchor.x = (content_view.frame.size.width) / 2; |
| 77 } |
| 78 |
70 return [parent_window_ convertBaseToScreen:anchor]; | 79 return [parent_window_ convertBaseToScreen:anchor]; |
71 } | 80 } |
72 | 81 |
73 NSWindow* PermissionBubbleCocoa::window() { | 82 NSWindow* PermissionBubbleCocoa::window() { |
74 return [bubbleController_ window]; | 83 return [bubbleController_ window]; |
75 } | 84 } |
76 | 85 |
77 void PermissionBubbleCocoa::SwitchParentWindow(NSWindow* parent) { | 86 void PermissionBubbleCocoa::SwitchParentWindow(NSWindow* parent) { |
78 parent_window_ = parent; | 87 parent_window_ = parent; |
79 } | 88 } |
| 89 |
| 90 bool PermissionBubbleCocoa::HasOmnibar() { |
| 91 LocationBarViewMac* location_bar = |
| 92 [[parent_window_ windowController] locationBarBridge]; |
| 93 if (location_bar) { |
| 94 return location_bar->browser()->SupportsWindowFeature( |
| 95 Browser::FEATURE_LOCATIONBAR); |
| 96 } |
| 97 return false; |
| 98 } |
| 99 |
| 100 info_bubble::BubbleArrowLocation PermissionBubbleCocoa::GetArrowLocation() { |
| 101 return HasOmnibar() ? info_bubble::kTopLeft : info_bubble::kNoArrow; |
| 102 } |
OLD | NEW |