| 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 13 matching lines...) Expand all Loading... |
| 24 const std::vector<bool>& accept_state, | 24 const std::vector<bool>& accept_state, |
| 25 bool customization_mode) { | 25 bool customization_mode) { |
| 26 DCHECK(parent_window_); | 26 DCHECK(parent_window_); |
| 27 | 27 |
| 28 if (!bubbleController_) { | 28 if (!bubbleController_) { |
| 29 bubbleController_ = [[PermissionBubbleController alloc] | 29 bubbleController_ = [[PermissionBubbleController alloc] |
| 30 initWithParentWindow:parent_window_ | 30 initWithParentWindow:parent_window_ |
| 31 bridge:this]; | 31 bridge:this]; |
| 32 } | 32 } |
| 33 | 33 |
| 34 LocationBarViewMac* location_bar = | 34 [bubbleController_ showAtAnchor:GetAnchorPoint() |
| 35 [[parent_window_ windowController] locationBarBridge]; | |
| 36 NSPoint anchor = location_bar->GetPageInfoBubblePoint(); | |
| 37 [bubbleController_ showAtAnchor:[parent_window_ convertBaseToScreen:anchor] | |
| 38 withDelegate:delegate_ | 35 withDelegate:delegate_ |
| 39 forRequests:requests | 36 forRequests:requests |
| 40 acceptStates:accept_state | 37 acceptStates:accept_state |
| 41 customizationMode:customization_mode]; | 38 customizationMode:customization_mode]; |
| 42 } | 39 } |
| 43 | 40 |
| 44 void PermissionBubbleCocoa::Hide() { | 41 void PermissionBubbleCocoa::Hide() { |
| 45 [bubbleController_ close]; | 42 [bubbleController_ close]; |
| 46 } | 43 } |
| 47 | 44 |
| 45 bool PermissionBubbleCocoa::IsVisible() { |
| 46 return bubbleController_ != nil; |
| 47 } |
| 48 |
| 48 void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) { | 49 void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) { |
| 49 if (delegate_ == delegate) | 50 if (delegate_ == delegate) |
| 50 return; | 51 return; |
| 51 if (delegate_ && delegate) | 52 if (delegate_ && delegate) |
| 52 delegate_->SetView(NULL); | 53 delegate_->SetView(NULL); |
| 53 delegate_ = delegate; | 54 delegate_ = delegate; |
| 54 } | 55 } |
| 55 | 56 |
| 56 bool PermissionBubbleCocoa::CanAcceptRequestUpdate() { | 57 bool PermissionBubbleCocoa::CanAcceptRequestUpdate() { |
| 57 // TODO(gbillock): implement. Should return true if the mouse is not over the | 58 // TODO(gbillock): implement. Should return true if the mouse is not over the |
| 58 // dialog. | 59 // dialog. |
| 59 return false; | 60 return false; |
| 60 } | 61 } |
| 61 | 62 |
| 62 void PermissionBubbleCocoa::OnBubbleClosing() { | 63 void PermissionBubbleCocoa::OnBubbleClosing() { |
| 63 bubbleController_ = nil; | 64 bubbleController_ = nil; |
| 64 } | 65 } |
| 66 |
| 67 NSPoint PermissionBubbleCocoa::GetAnchorPoint() { |
| 68 LocationBarViewMac* location_bar = |
| 69 [[parent_window_ windowController] locationBarBridge]; |
| 70 NSPoint anchor = location_bar->GetPageInfoBubblePoint(); |
| 71 return [parent_window_ convertBaseToScreen:anchor]; |
| 72 } |
| 73 |
| 74 NSWindow* PermissionBubbleCocoa::window() { |
| 75 return [bubbleController_ window]; |
| 76 } |
| OLD | NEW |