OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #import <Cocoa/Cocoa.h> | |
6 | |
7 #include "base/mac/scoped_nsobject.h" | |
8 #import "chrome/browser/ui/cocoa/omnibox_decoration_bubble_controller.h" | |
9 #include "chrome/browser/ui/website_settings/permission_prompt.h" | |
10 #include "ui/base/models/simple_menu_model.h" | |
11 | |
12 class Browser; | |
13 @class MenuController; | |
14 class PermissionBubbleCocoa; | |
15 class PermissionRequest; | |
16 | |
17 @interface PermissionBubbleController | |
18 : OmniboxDecorationBubbleController<NSTextViewDelegate> { | |
19 @private | |
20 // Array of views that are the checkboxes for every requested permission. | |
21 // Only populated if multiple requests are shown at once. | |
22 base::scoped_nsobject<NSMutableArray> checkboxes_; | |
23 | |
24 // Delegate to be informed of user actions. | |
25 PermissionPrompt::Delegate* delegate_; // Weak. | |
26 | |
27 // Used to determine the correct anchor location and parent window. | |
28 Browser* browser_; // Weak. | |
29 | |
30 // Delegate that receives menu events on behalf of this. | |
31 std::unique_ptr<ui::SimpleMenuModel::Delegate> menuDelegate_; | |
32 | |
33 // Bridge to the C++ class that created this object. | |
34 PermissionBubbleCocoa* bridge_; // Weak. | |
35 } | |
36 | |
37 // Designated initializer. |browser| and |bridge| must both be non-nil. | |
38 - (id)initWithBrowser:(Browser*)browser bridge:(PermissionBubbleCocoa*)bridge; | |
39 | |
40 // Returns the anchor point to use for the given Cocoa |browser|. | |
41 + (NSPoint)getAnchorPointForBrowser:(Browser*)browser; | |
42 | |
43 // Returns true if |browser| has a visible location bar. | |
44 + (bool)hasVisibleLocationBarForBrowser:(Browser*)browser; | |
45 | |
46 // Makes the bubble visible. The bubble will be populated with text retrieved | |
47 // from |requests|. |delegate| will receive callbacks for user actions. | |
48 - (void)showWithDelegate:(PermissionPrompt::Delegate*)delegate | |
49 forRequests:(const std::vector<PermissionRequest*>&)requests | |
50 acceptStates:(const std::vector<bool>&)acceptStates; | |
51 | |
52 // Will reposition the bubble based in case the anchor or parent should change. | |
53 - (void)updateAnchorPosition; | |
54 | |
55 // Will calculate the expected anchor point for this bubble. | |
56 // Should only be used outside this class for tests. | |
57 - (NSPoint)getExpectedAnchorPoint; | |
58 | |
59 // Returns true if the browser has a visible location bar. | |
60 // Should only be used outside this class for tests. | |
61 - (bool)hasVisibleLocationBar; | |
62 | |
63 @end | |
OLD | NEW |