[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / website_settings / permission_bubble_cocoa.mm
blob1d67b3cedffdb6280760f5c27215b474202d9af7
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/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"
14 PermissionBubbleCocoa::PermissionBubbleCocoa(NSWindow* parent_window)
15     : parent_window_(parent_window), delegate_(NULL), bubbleController_(nil) {}
17 PermissionBubbleCocoa::~PermissionBubbleCocoa() {
18   if (delegate_)
19     delegate_->SetView(NULL);
22 void PermissionBubbleCocoa::Show(
23     const std::vector<PermissionBubbleRequest*>& requests,
24     const std::vector<bool>& accept_state,
25     bool customization_mode) {
26   DCHECK(parent_window_);
28   if (!bubbleController_) {
29     bubbleController_ = [[PermissionBubbleController alloc]
30         initWithParentWindow:parent_window_
31                       bridge:this];
32   }
34   LocationBarViewMac* location_bar =
35       [[parent_window_ windowController] locationBarBridge];
36   NSPoint anchor = location_bar->GetPageInfoBubblePoint();
37   [bubbleController_ showAtAnchor:[parent_window_ convertBaseToScreen:anchor]
38                      withDelegate:delegate_
39                       forRequests:requests
40                      acceptStates:accept_state
41                 customizationMode:customization_mode];
44 void PermissionBubbleCocoa::Hide() {
45   [bubbleController_ close];
48 void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) {
49   if (delegate_ == delegate)
50     return;
51   if (delegate_ && delegate)
52     delegate_->SetView(NULL);
53   delegate_ = delegate;
56 bool PermissionBubbleCocoa::CanAcceptRequestUpdate() {
57   // TODO(gbillock): implement. Should return true if the mouse is not over the
58   // dialog.
59   return false;
62 void PermissionBubbleCocoa::OnBubbleClosing() {
63   bubbleController_ = nil;