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