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/website_settings/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/website_settings/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 if (delegate_) | |
| 20 delegate_->SetView(NULL); | |
| 21 } | |
| 22 | |
| 23 void PermissionBubbleCocoa::Show( | |
| 24 const std::vector<PermissionBubbleRequest*>& requests, | |
| 25 const std::vector<bool>& accept_state, | |
| 26 bool customization_mode) { | |
| 27 DCHECK(parent_window_); | |
| 28 | |
| 29 if (!bubbleController_) { | |
| 30 bubbleController_ = [[PermissionBubbleController alloc] | |
| 31 initWithParentWindow:parent_window_ | |
| 32 bridge:this]; | |
| 33 } | |
| 34 | |
| 35 LocationBarViewMac* location_bar = | |
| 36 [[parent_window_ windowController] locationBarBridge]; | |
| 37 NSPoint anchor = location_bar->GetPageInfoBubblePoint(); | |
| 38 [bubbleController_ showAtAnchor:[parent_window_ convertBaseToScreen:anchor] | |
| 39 withDelegate:delegate_ | |
| 40 forRequests:requests | |
| 41 acceptStates:accept_state | |
| 42 customizationMode:customization_mode]; | |
| 43 } | |
| 44 | |
| 45 void PermissionBubbleCocoa::Hide() { | |
| 46 [bubbleController_ close]; | |
| 47 } | |
| 48 | |
| 49 void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) { | |
| 50 if (delegate_ == delegate) | |
|
groby-ooo-7-16
2014/03/03 18:34:05
I'm confused - this seems to re-attach an existing
leng
2014/03/03 19:01:04
It's just here as an early return. The delegate i
| |
| 51 return; | |
| 52 if (delegate_ && delegate) | |
| 53 delegate_->SetView(NULL); | |
| 54 delegate_ = delegate; | |
| 55 } | |
| 56 | |
| 57 void PermissionBubbleCocoa::OnBubbleClosing() { | |
| 58 bubbleController_ = nil; | |
|
groby-ooo-7-16
2014/03/03 18:34:05
delegate_->SetView(NULL) here? I'm not clear on th
leng
2014/03/03 19:01:04
No, because the delegate might still have 'control
| |
| 59 } | |
| OLD | NEW |