Chromium Code Reviews| 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_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_ | 5 #ifndef CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_ |
| 6 #define CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_ | 6 #define CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 // When the visible tab changes, the UI code must provide an object of this type | 22 // When the visible tab changes, the UI code must provide an object of this type |
| 23 // to the manager for the visible tab. | 23 // to the manager for the visible tab. |
| 24 class PermissionPrompt { | 24 class PermissionPrompt { |
| 25 public: | 25 public: |
| 26 // The delegate will receive events caused by user action which need to | 26 // The delegate will receive events caused by user action which need to |
| 27 // be persisted in the per-tab UI state. | 27 // be persisted in the per-tab UI state. |
| 28 class Delegate { | 28 class Delegate { |
| 29 public: | 29 public: |
| 30 virtual ~Delegate() {} | 30 virtual ~Delegate() {} |
| 31 | 31 |
| 32 virtual const std::vector<PermissionRequest*>& Requests() = 0; | |
|
raymes
2017/05/11 01:17:55
We may want to add a comment that the objects in t
Timothy Loh
2017/05/11 04:42:08
Added a comment.
| |
| 33 virtual const std::vector<bool>& AcceptStates() = 0; | |
| 34 | |
| 32 virtual void ToggleAccept(int index, bool new_value) = 0; | 35 virtual void ToggleAccept(int index, bool new_value) = 0; |
| 33 virtual void TogglePersist(bool new_value) = 0; | 36 virtual void TogglePersist(bool new_value) = 0; |
| 34 virtual void Accept() = 0; | 37 virtual void Accept() = 0; |
| 35 virtual void Deny() = 0; | 38 virtual void Deny() = 0; |
| 36 virtual void Closing() = 0; | 39 virtual void Closing() = 0; |
| 37 }; | 40 }; |
| 38 | 41 |
| 39 typedef base::Callback<std::unique_ptr<PermissionPrompt>( | 42 typedef base::Callback<std::unique_ptr<PermissionPrompt>( |
| 40 content::WebContents*)> | 43 content::WebContents*)> |
| 41 Factory; | 44 Factory; |
| 42 | 45 |
| 43 // Create a platform specific instance. | 46 // Create a platform specific instance. |
| 44 static std::unique_ptr<PermissionPrompt> Create( | 47 static std::unique_ptr<PermissionPrompt> Create( |
| 45 content::WebContents* web_contents); | 48 content::WebContents* web_contents); |
| 46 virtual ~PermissionPrompt() {} | 49 virtual ~PermissionPrompt() {} |
| 47 | 50 |
| 48 // Sets the delegate which will receive UI events forwarded from the prompt. | 51 // Sets the delegate which will receive UI events forwarded from the prompt. |
| 49 virtual void SetDelegate(Delegate* delegate) = 0; | 52 virtual void SetDelegate(Delegate* delegate) = 0; |
| 50 | 53 |
| 51 // Causes the request UI to show up with the given contents. This method may | 54 // Show a prompt with the requests from the delegate. This will only be called |
| 52 // be called with mostly-identical contents to the existing contents. This can | 55 // if there is no prompt showing. |
| 53 // happen, for instance, if a new permission is requested and | 56 virtual void Show() = 0; |
| 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 | 57 |
| 60 // Returns true if the view can accept a new Show() command to coalesce | 58 // 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 | 59 // 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). | 60 // is being shown and the mouse is not over the view area (!IsMouseHovered). |
| 63 virtual bool CanAcceptRequestUpdate() = 0; | 61 virtual bool CanAcceptRequestUpdate() = 0; |
| 64 | 62 |
| 65 // Returns true if the prompt UI will manage hiding itself when the user | 63 // Returns true if the prompt UI will manage hiding itself when the user |
| 66 // resolves the prompt, on page navigation/destruction, and on tab switching. | 64 // resolves the prompt, on page navigation/destruction, and on tab switching. |
| 67 virtual bool HidesAutomatically() = 0; | 65 virtual bool HidesAutomatically() = 0; |
| 68 | 66 |
| 69 // Hides the permission prompt. | 67 // Hides the permission prompt. |
| 70 virtual void Hide() = 0; | 68 virtual void Hide() = 0; |
| 71 | 69 |
| 72 // Updates where the prompt should be anchored. ex: fullscreen toggle. | 70 // Updates where the prompt should be anchored. ex: fullscreen toggle. |
| 73 virtual void UpdateAnchorPosition() = 0; | 71 virtual void UpdateAnchorPosition() = 0; |
| 74 | 72 |
| 75 // Returns a reference to this prompt's native window. | 73 // Returns a reference to this prompt's native window. |
| 76 // TODO(hcarmona): Remove this as part of the bubble API work. | 74 // TODO(hcarmona): Remove this as part of the bubble API work. |
| 77 virtual gfx::NativeWindow GetNativeWindow() = 0; | 75 virtual gfx::NativeWindow GetNativeWindow() = 0; |
| 78 }; | 76 }; |
| 79 | 77 |
| 80 #endif // CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_ | 78 #endif // CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_ |
| OLD | NEW |