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.
5 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h"
7 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
8 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h"
9 #import "chrome/browser/ui/website_settings/permission_bubble_view.h"
10 #include "content/public/browser/web_contents.h"
11 #import "ui/base/cocoa/nsview_additions.h"
13 PermissionBubbleCocoa::PermissionBubbleCocoa(Browser* browser)
14 : browser_(browser), delegate_(nullptr), bubbleController_(nil) {
18 PermissionBubbleCocoa::~PermissionBubbleCocoa() {
22 scoped_ptr<PermissionBubbleView> PermissionBubbleView::Create(
24 return make_scoped_ptr(new PermissionBubbleCocoa(browser));
27 void PermissionBubbleCocoa::Show(
28 const std::vector<PermissionBubbleRequest*>& requests,
29 const std::vector<bool>& accept_state) {
30 if (!bubbleController_) {
32 [[PermissionBubbleController alloc] initWithBrowser:browser_
36 [bubbleController_ showWithDelegate:delegate_
38 acceptStates:accept_state];
41 void PermissionBubbleCocoa::Hide() {
42 [bubbleController_ close];
45 bool PermissionBubbleCocoa::IsVisible() {
46 return bubbleController_ != nil;
49 void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) {
50 if (delegate_ == delegate)
55 bool PermissionBubbleCocoa::CanAcceptRequestUpdate() {
56 return ![[[bubbleController_ window] contentView] cr_isMouseInView];
59 void PermissionBubbleCocoa::UpdateAnchorPosition() {
60 [bubbleController_ updateAnchorPosition];
63 gfx::NativeWindow PermissionBubbleCocoa::GetNativeWindow() {
64 return [bubbleController_ window];
67 void PermissionBubbleCocoa::OnBubbleClosing() {
68 bubbleController_ = nil;