OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_cocoa.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | 8 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
9 #import "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_controller.
h" | 9 #import "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_controller.
h" |
10 #import "chrome/browser/ui/permission_bubble/permission_prompt.h" | 10 #import "chrome/browser/ui/permission_bubble/permission_prompt.h" |
11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
12 #import "ui/base/cocoa/nsview_additions.h" | 12 #import "ui/base/cocoa/nsview_additions.h" |
13 | 13 |
14 PermissionBubbleCocoa::PermissionBubbleCocoa(Browser* browser) | 14 PermissionBubbleCocoa::PermissionBubbleCocoa(Browser* browser) |
15 : browser_(browser), delegate_(nullptr), bubbleController_(nil) {} | 15 : browser_(browser), delegate_(nullptr), bubbleController_(nil) {} |
16 | 16 |
17 PermissionBubbleCocoa::~PermissionBubbleCocoa() { | 17 PermissionBubbleCocoa::~PermissionBubbleCocoa() { |
18 } | 18 } |
19 | 19 |
20 void PermissionBubbleCocoa::Show( | 20 void PermissionBubbleCocoa::Show() { |
21 const std::vector<PermissionRequest*>& requests, | |
22 const std::vector<bool>& accept_state) { | |
23 DCHECK(browser_); | 21 DCHECK(browser_); |
24 | 22 |
25 if (!bubbleController_) { | 23 if (!bubbleController_) { |
26 bubbleController_ = | 24 bubbleController_ = |
27 [[PermissionBubbleController alloc] initWithBrowser:browser_ | 25 [[PermissionBubbleController alloc] initWithBrowser:browser_ |
28 bridge:this]; | 26 bridge:this]; |
29 } | 27 } |
30 | 28 |
31 [bubbleController_ showWithDelegate:delegate_ | 29 [bubbleController_ showWithDelegate:delegate_]; |
32 forRequests:requests | |
33 acceptStates:accept_state]; | |
34 } | 30 } |
35 | 31 |
36 void PermissionBubbleCocoa::Hide() { | 32 void PermissionBubbleCocoa::Hide() { |
37 [bubbleController_ close]; | 33 [bubbleController_ close]; |
38 } | 34 } |
39 | 35 |
40 void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) { | 36 void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) { |
41 if (delegate_ == delegate) | 37 if (delegate_ == delegate) |
42 return; | 38 return; |
43 delegate_ = delegate; | 39 delegate_ = delegate; |
(...skipping 11 matching lines...) Expand all Loading... |
55 [bubbleController_ updateAnchorPosition]; | 51 [bubbleController_ updateAnchorPosition]; |
56 } | 52 } |
57 | 53 |
58 gfx::NativeWindow PermissionBubbleCocoa::GetNativeWindow() { | 54 gfx::NativeWindow PermissionBubbleCocoa::GetNativeWindow() { |
59 return [bubbleController_ window]; | 55 return [bubbleController_ window]; |
60 } | 56 } |
61 | 57 |
62 void PermissionBubbleCocoa::OnBubbleClosing() { | 58 void PermissionBubbleCocoa::OnBubbleClosing() { |
63 bubbleController_ = nil; | 59 bubbleController_ = nil; |
64 } | 60 } |
OLD | NEW |