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

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

Issue 2829023002: Fix cancelling permission requests on Android when the PermissionRequestManager is enabled (Closed)
Patch Set: rebase Created 3 years, 7 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/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 DCHECK(browser_); 21 DCHECK(browser_);
22 22
23 if (!bubbleController_) { 23 bubbleController_ =
24 bubbleController_ = 24 [[PermissionBubbleController alloc] initWithBrowser:browser_ bridge:this];
25 [[PermissionBubbleController alloc] initWithBrowser:browser_
26 bridge:this];
27 }
28
29 [bubbleController_ showWithDelegate:delegate_]; 25 [bubbleController_ showWithDelegate:delegate_];
30 } 26 }
31 27
32 void PermissionBubbleCocoa::Hide() { 28 void PermissionBubbleCocoa::Hide() {
33 [bubbleController_ close]; 29 [bubbleController_ close];
34 } 30 }
35 31
36 void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) { 32 void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) {
37 if (delegate_ == delegate) 33 if (delegate_ == delegate)
38 return; 34 return;
39 delegate_ = delegate; 35 delegate_ = delegate;
40 } 36 }
41 37
42 bool PermissionBubbleCocoa::CanAcceptRequestUpdate() { 38 bool PermissionBubbleCocoa::MaybeCancelRequest() {
43 return ![[[bubbleController_ window] contentView] cr_isMouseInView]; 39 if ([[[bubbleController_ window] contentView] cr_isMouseInView])
40 return false;
41 Hide();
42 return true;
44 } 43 }
45 44
46 bool PermissionBubbleCocoa::HidesAutomatically() { 45 bool PermissionBubbleCocoa::HidesAutomatically() {
47 return false; 46 return false;
48 } 47 }
49 48
50 void PermissionBubbleCocoa::UpdateAnchorPosition() { 49 void PermissionBubbleCocoa::UpdateAnchorPosition() {
51 [bubbleController_ updateAnchorPosition]; 50 [bubbleController_ updateAnchorPosition];
52 } 51 }
53 52
54 gfx::NativeWindow PermissionBubbleCocoa::GetNativeWindow() { 53 gfx::NativeWindow PermissionBubbleCocoa::GetNativeWindow() {
55 return [bubbleController_ window]; 54 return [bubbleController_ window];
56 } 55 }
57 56
58 void PermissionBubbleCocoa::OnBubbleClosing() { 57 void PermissionBubbleCocoa::OnBubbleClosing() {
59 bubbleController_ = nil; 58 bubbleController_ = nil;
60 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698