Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / website_settings / permission_bubble_cocoa.mm
blob8da7fb1aa5d4aa0059326fa58c1140be8aa2399c
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) {
15   DCHECK(browser);
18 PermissionBubbleCocoa::~PermissionBubbleCocoa() {
21 // static
22 scoped_ptr<PermissionBubbleView> PermissionBubbleView::Create(
23     Browser* browser) {
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_) {
31     bubbleController_ =
32         [[PermissionBubbleController alloc] initWithBrowser:browser_
33                                                      bridge:this];
34   }
36   [bubbleController_ showWithDelegate:delegate_
37                           forRequests:requests
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)
51     return;
52   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;