Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/cocoa/permission_bubble_cocoa.h" | |
| 6 | |
| 7 #import "chrome/browser/ui/cocoa/base_bubble_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" | |
| 10 #import "chrome/browser/ui/cocoa/permission_bubble_controller.h" | |
| 11 #import "chrome/browser/ui/website_settings/permission_bubble_view.h" | |
| 12 #include "content/public/browser/web_contents.h" | |
| 13 #include "content/public/browser/web_contents_view.h" | |
| 14 | |
| 15 PermissionBubbleCocoa::PermissionBubbleCocoa(NSWindow* parent_window) | |
| 16 : parent_window_(parent_window), delegate_(NULL), bubbleController_(nil) {} | |
| 17 | |
| 18 PermissionBubbleCocoa::~PermissionBubbleCocoa() {} | |
| 19 | |
| 20 void PermissionBubbleCocoa::Show( | |
| 21 const std::vector<PermissionBubbleDelegate*>& delegates, | |
| 22 const std::vector<bool>& accept_state, | |
| 23 bool customization_mode) { | |
| 24 DCHECK(parent_window_); | |
| 25 LocationBarViewMac* location_bar = | |
| 26 [[parent_window_ windowController] locationBarBridge]; | |
| 27 | |
| 28 if (!bubbleController_) { | |
| 29 bubbleController_ = [[PermissionBubbleController alloc] | |
| 30 initWithParentWindow:parent_window_ | |
| 31 bridge:this]; | |
| 32 } | |
| 33 | |
| 34 NSPoint anchor = location_bar->GetPageInfoBubblePoint(); | |
| 35 [bubbleController_ showAtAnchor:[parent_window_ convertBaseToScreen:anchor] | |
| 36 withDelegate:delegate_ | |
| 37 forRequests:delegates | |
| 38 acceptStates:accept_state | |
| 39 customizationMode:customization_mode]; | |
| 40 } | |
| 41 | |
| 42 void PermissionBubbleCocoa::Hide() { | |
| 43 if (bubbleController_) | |
|
groby-ooo-7-16
2014/01/31 22:31:51
No need for if. (messages to nil are ignored)
leng
2014/02/03 22:38:04
Too many years in C++... :)
Done.
| |
| 44 [bubbleController_ close]; | |
| 45 } | |
| 46 | |
| 47 void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) { | |
| 48 delegate_ = delegate; | |
| 49 } | |
| 50 | |
| 51 void PermissionBubbleCocoa::OnBubbleClosing() { | |
| 52 bubbleController_ = nil; | |
| 53 } | |
| OLD | NEW |