Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm

Issue 1292353006: Mac Changes for BubbleManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mcdb-mac-3.gitbr
Patch Set: New upstream Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/website_settings/permission_bubble_cocoa.h" 5 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h"
6 6
7 #include "chrome/browser/ui/browser_finder.h"
7 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" 8 #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/cocoa/website_settings/permission_bubble_controller.h "
9 #import "chrome/browser/ui/website_settings/permission_bubble_view.h" 10 #import "chrome/browser/ui/website_settings/permission_bubble_delegate.h"
11 #import "chrome/browser/ui/website_settings/permission_bubble_manager.h"
10 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
11 #import "ui/base/cocoa/nsview_additions.h" 13 #import "ui/base/cocoa/nsview_additions.h"
12 14
13 PermissionBubbleCocoa::PermissionBubbleCocoa(Browser* browser) 15 PermissionBubbleCocoa::PermissionBubbleCocoa(PermissionBubbleManager* manager)
14 : browser_(browser), delegate_(nullptr), bubbleController_(nil) { 16 : manager_(manager), bubbleController_(nil) {
15 DCHECK(browser); 17 DCHECK(manager_);
16 } 18 }
17 19
18 PermissionBubbleCocoa::~PermissionBubbleCocoa() { 20 PermissionBubbleCocoa::~PermissionBubbleCocoa() {
19 } 21 }
20 22
21 // static 23 // static
22 scoped_ptr<PermissionBubbleView> PermissionBubbleView::Create( 24 scoped_ptr<BubbleUI> PermissionBubbleDelegate::CreateBubble(
23 Browser* browser) { 25 PermissionBubbleManager* manager) {
24 return make_scoped_ptr(new PermissionBubbleCocoa(browser)); 26 return make_scoped_ptr(new PermissionBubbleCocoa(manager));
25 } 27 }
26 28
27 void PermissionBubbleCocoa::Show( 29 void PermissionBubbleCocoa::Show() {
28 const std::vector<PermissionBubbleRequest*>& requests,
29 const std::vector<bool>& accept_state) {
30 if (!bubbleController_) { 30 if (!bubbleController_) {
31 bubbleController_ = 31 bubbleController_ = [[PermissionBubbleController alloc]
32 [[PermissionBubbleController alloc] initWithBrowser:browser_ 32 initWithBrowser:chrome::FindBrowserWithWebContents(
33 bridge:this]; 33 manager_->web_contents())
34 bridge:this];
34 } 35 }
35 36
36 [bubbleController_ showWithDelegate:delegate_ 37 [bubbleController_ showWithManager:manager_
37 forRequests:requests 38 forRequests:manager_->requests()
38 acceptStates:accept_state]; 39 acceptStates:manager_->accept_states()];
39 } 40 }
40 41
41 void PermissionBubbleCocoa::Hide() { 42 void PermissionBubbleCocoa::Hide() {
42 [bubbleController_ close]; 43 [bubbleController_ close];
43 } 44 }
44 45
45 bool PermissionBubbleCocoa::IsVisible() {
46 return bubbleController_ != nil;
47 }
48
49 void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) {
50 if (delegate_ == delegate)
51 return;
52 delegate_ = delegate;
53 }
54
55 bool PermissionBubbleCocoa::CanAcceptRequestUpdate() {
56 return ![[[bubbleController_ window] contentView] cr_isMouseInView];
57 }
58
59 void PermissionBubbleCocoa::UpdateAnchorPosition() { 46 void PermissionBubbleCocoa::UpdateAnchorPosition() {
60 [bubbleController_ updateAnchorPosition]; 47 [bubbleController_ updateAnchorPosition];
61 } 48 }
62 49
63 gfx::NativeWindow PermissionBubbleCocoa::GetNativeWindow() { 50 bool PermissionBubbleCocoa::CanAcceptUpdate() const {
64 return [bubbleController_ window]; 51 return ![[[bubbleController_ window] contentView] cr_isMouseInView];
65 } 52 }
66 53
67 void PermissionBubbleCocoa::OnBubbleClosing() { 54 void PermissionBubbleCocoa::OnBubbleClosing() {
68 bubbleController_ = nil; 55 bubbleController_ = nil;
69 } 56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698