Cleanup: Update the path to insets and point headers.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / website_settings / permission_bubble_cocoa.mm
blob4370ec25fa348a916f2491e0636a370d3cb08fa5
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   [bubbleController_ showAtAnchor:GetAnchorPoint()
35                      withDelegate:delegate_
36                       forRequests:requests
37                      acceptStates:accept_state
38                 customizationMode:customization_mode];
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   if (delegate_ && delegate)
53     delegate_->SetView(NULL);
54   delegate_ = delegate;
57 bool PermissionBubbleCocoa::CanAcceptRequestUpdate() {
58   // TODO(gbillock): implement. Should return true if the mouse is not over the
59   // dialog.
60   return false;
63 void PermissionBubbleCocoa::OnBubbleClosing() {
64   bubbleController_ = nil;
67 NSPoint PermissionBubbleCocoa::GetAnchorPoint() {
68   LocationBarViewMac* location_bar =
69       [[parent_window_ windowController] locationBarBridge];
70   NSPoint anchor = location_bar->GetPageInfoBubblePoint();
71   return [parent_window_ convertBaseToScreen:anchor];
74 NSWindow* PermissionBubbleCocoa::window() {
75   return [bubbleController_ window];