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