OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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_BUBBLE_MANAGER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" |
| 11 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "content/public/browser/web_contents_user_data.h" |
| 13 |
| 14 class PermissionBubbleDelegate; |
| 15 |
| 16 // Provides access to permissions bubbles. Allows clients to add a delegate |
| 17 // callback interface to the existing permission bubble configuration. |
| 18 // Depending on the situation and policy, that may add new UI to an existing |
| 19 // permission bubble, create and show a new permission bubble, or provide no |
| 20 // visible UI action at all. (In that case, the delegate will be immediately |
| 21 // informed that the permission request failed.) |
| 22 // |
| 23 // A PermissionBubbleManager is associated with a particular WebContents. |
| 24 // Delegates attached to a particular WebContents' PBM must outlive it. |
| 25 // |
| 26 // The PermissionBubbleManager should be addressed on the UI thread. |
| 27 class PermissionBubbleManager |
| 28 : public content::WebContentsObserver, |
| 29 public content::WebContentsUserData<PermissionBubbleManager> { |
| 30 public: |
| 31 // Add a new consumer delegate to the permission bubble. Ownership of the |
| 32 // delegate remains with the caller. The caller must arrange for the delegate |
| 33 // to outlive the PermissionBubbleManager. |
| 34 virtual void AddPermissionBubbleDelegate(PermissionBubbleDelegate* delegate); |
| 35 |
| 36 // Remove a consumer delegate from the permission bubble. |
| 37 virtual void RemovePermissionBubbleDelegate( |
| 38 PermissionBubbleDelegate* delegate); |
| 39 |
| 40 // Set the active view for the permission bubble. If this is NULL, it |
| 41 // means the permission bubble is no longer showing. |
| 42 virtual void SetView(PermissionBubbleView* view); |
| 43 |
| 44 private: |
| 45 friend class content::WebContentsUserData<PermissionBubbleManager>; |
| 46 |
| 47 explicit PermissionBubbleManager(content::WebContents* web_contents); |
| 48 |
| 49 // contents::WebContentsObserver: |
| 50 virtual void WebContentsDestroyed( |
| 51 content::WebContents* web_contents) OVERRIDE; |
| 52 |
| 53 // PermissionBubbleView::Observer: |
| 54 virtual void ToggleAccept(int delegate_index, bool new_value) OVERRIDE; |
| 55 virtual void Accept() OVERRIDE; |
| 56 virtual void Deny() OVERRIDE; |
| 57 virtual void Closing() OVERRIDE; |
| 58 |
| 59 // Finalize the pending permissions request. |
| 60 void FinalizeBubble(); |
| 61 |
| 62 // Whether or not we are showing the bubble in this tab. |
| 63 bool bubble_showing_; |
| 64 |
| 65 // Set to the UI surface to be used to display the permissions requests. |
| 66 PermissionBubbleView* view_; |
| 67 |
| 68 std::vector<PermissionBubbleDelegate*> delegates_; |
| 69 std::vector<bool> accept_state_; |
| 70 }; |
| 71 |
| 72 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ |
OLD | NEW |