Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/browser/ui/website_settings/permission_bubble_manager.h

Issue 121113007: [WebsiteSettings] API for permissions bubbles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: destructor Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 PermissionBubbleView::Delegate {
31 public:
32 virtual ~PermissionBubbleManager();
33
34 // Add a new consumer delegate to the permission bubble. Ownership of the
35 // delegate remains with the caller. The caller must arrange for the delegate
36 // to outlive the PermissionBubbleManager.
37 virtual void AddPermissionBubbleDelegate(PermissionBubbleDelegate* delegate);
38
39 // Remove a consumer delegate from the permission bubble.
40 virtual void RemovePermissionBubbleDelegate(
41 PermissionBubbleDelegate* delegate);
42
43 // Set the active view for the permission bubble. If this is NULL, it
44 // means the permission bubble is no longer showing.
45 virtual void SetView(PermissionBubbleView* view);
46
47 private:
48 friend class content::WebContentsUserData<PermissionBubbleManager>;
49
50 explicit PermissionBubbleManager(content::WebContents* web_contents);
51
52 // contents::WebContentsObserver:
53 virtual void WebContentsDestroyed(
54 content::WebContents* web_contents) OVERRIDE;
55
56 // PermissionBubbleView::Delegate:
57 virtual void ToggleAccept(int delegate_index, bool new_value) OVERRIDE;
58 virtual void Accept() OVERRIDE;
59 virtual void Deny() OVERRIDE;
60 virtual void Closing() OVERRIDE;
61
62 // Finalize the pending permissions request.
63 void FinalizeBubble();
64
65 // Whether or not we are showing the bubble in this tab.
66 bool bubble_showing_;
67
68 // Set to the UI surface to be used to display the permissions requests.
69 PermissionBubbleView* view_;
70
71 std::vector<PermissionBubbleDelegate*> delegates_;
72 std::vector<bool> accept_state_;
73 };
74
75 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698