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