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_WEBSITE_SETTINGS_PERMISSION_PROMPT_H_ | |
6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_PROMPT_H_ | |
7 | |
8 #include <memory> | |
9 #include <vector> | |
10 | |
11 #include "base/callback.h" | |
12 #include "ui/gfx/native_widget_types.h" | |
13 | |
14 class PermissionRequest; | |
15 | |
16 namespace content { | |
17 class WebContents; | |
18 } | |
19 | |
20 // This class is the platform-independent interface through which the permission | |
21 // request managers (which are one per tab) communicate to the UI surface. | |
22 // When the visible tab changes, the UI code must provide an object of this type | |
23 // to the manager for the visible tab. | |
24 class PermissionPrompt { | |
25 public: | |
26 // The delegate will receive events caused by user action which need to | |
27 // be persisted in the per-tab UI state. | |
28 class Delegate { | |
29 public: | |
30 virtual ~Delegate() {} | |
31 | |
32 virtual void ToggleAccept(int index, bool new_value) = 0; | |
33 virtual void TogglePersist(bool new_value) = 0; | |
34 virtual void Accept() = 0; | |
35 virtual void Deny() = 0; | |
36 virtual void Closing() = 0; | |
37 }; | |
38 | |
39 typedef base::Callback<std::unique_ptr<PermissionPrompt>( | |
40 content::WebContents*)> | |
41 Factory; | |
42 | |
43 // Create a platform specific instance. | |
44 static std::unique_ptr<PermissionPrompt> Create( | |
45 content::WebContents* web_contents); | |
46 virtual ~PermissionPrompt() {} | |
47 | |
48 // Sets the delegate which will receive UI events forwarded from the prompt. | |
49 virtual void SetDelegate(Delegate* delegate) = 0; | |
50 | |
51 // Causes the request UI to show up with the given contents. This method may | |
52 // be called with mostly-identical contents to the existing contents. This can | |
53 // happen, for instance, if a new permission is requested and | |
54 // CanAcceptRequestUpdate() is true. | |
55 // Important: the view must not store any of the request objects it receives | |
56 // in this call. | |
57 virtual void Show(const std::vector<PermissionRequest*>& requests, | |
58 const std::vector<bool>& accept_state) = 0; | |
59 | |
60 // Returns true if the view can accept a new Show() command to coalesce | |
61 // requests. Currently the policy is that this should return true if the view | |
62 // is being shown and the mouse is not over the view area (!IsMouseHovered). | |
63 virtual bool CanAcceptRequestUpdate() = 0; | |
64 | |
65 // Hides the permission prompt. | |
66 virtual void Hide() = 0; | |
67 | |
68 // Returns true if there is a prompt currently showing. | |
69 virtual bool IsVisible() = 0; | |
70 | |
71 // Updates where the prompt should be anchored. ex: fullscreen toggle. | |
72 virtual void UpdateAnchorPosition() = 0; | |
73 | |
74 // Returns a reference to this prompt's native window. | |
75 // TODO(hcarmona): Remove this as part of the bubble API work. | |
76 virtual gfx::NativeWindow GetNativeWindow() = 0; | |
77 }; | |
78 | |
79 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_PROMPT_H_ | |
OLD | NEW |