Chromium Code Reviews| Index: chrome/browser/ui/cocoa/permission_bubble_cocoa.mm |
| diff --git a/chrome/browser/ui/cocoa/permission_bubble_cocoa.mm b/chrome/browser/ui/cocoa/permission_bubble_cocoa.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..256738d0e503fcf7f1c305e0cb3ad9dea9bebbac |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/permission_bubble_cocoa.mm |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/cocoa/permission_bubble_cocoa.h" |
| + |
| +#import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| +#import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| +#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| +#import "chrome/browser/ui/cocoa/permission_bubble_controller.h" |
| +#import "chrome/browser/ui/website_settings/permission_bubble_view.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "content/public/browser/web_contents_view.h" |
| + |
| +PermissionBubbleCocoa::PermissionBubbleCocoa(NSWindow* parent_window) |
| + : parent_window_(parent_window), delegate_(NULL), bubbleController_(nil) {} |
| + |
| +PermissionBubbleCocoa::~PermissionBubbleCocoa() {} |
| + |
| +void PermissionBubbleCocoa::Show( |
| + const std::vector<PermissionBubbleDelegate*>& delegates, |
| + const std::vector<bool>& accept_state, |
| + bool customization_mode) { |
| + DCHECK(parent_window_); |
| + LocationBarViewMac* location_bar = |
| + [[parent_window_ windowController] locationBarBridge]; |
| + |
| + if (!bubbleController_) { |
| + bubbleController_ = [[PermissionBubbleController alloc] |
| + initWithParentWindow:parent_window_ |
| + bridge:this]; |
| + } |
| + |
| + NSPoint anchor = location_bar->GetPageInfoBubblePoint(); |
| + [bubbleController_ showAtAnchor:[parent_window_ convertBaseToScreen:anchor] |
| + withDelegate:delegate_ |
| + forRequests:delegates |
| + acceptStates:accept_state |
| + customizationMode:customization_mode]; |
| +} |
| + |
| +void PermissionBubbleCocoa::Hide() { |
| + 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.
|
| + [bubbleController_ close]; |
| +} |
| + |
| +void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) { |
| + delegate_ = delegate; |
| +} |
| + |
| +void PermissionBubbleCocoa::OnBubbleClosing() { |
| + bubbleController_ = nil; |
| +} |