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_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ |
6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/timer/timer.h" | |
10 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" | 11 #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_observer.h" |
12 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
13 | 14 |
14 class PermissionBubbleRequest; | 15 class PermissionBubbleRequest; |
15 | 16 |
16 // Provides access to permissions bubbles. Allows clients to add a request | 17 // Provides access to permissions bubbles. Allows clients to add a request |
17 // callback interface to the existing permission bubble configuration. | 18 // callback interface to the existing permission bubble configuration. |
18 // Depending on the situation and policy, that may add new UI to an existing | 19 // 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 // permission bubble, create and show a new permission bubble, or provide no |
20 // visible UI action at all. (In that case, the request will be immediately | 21 // visible UI action at all. (In that case, the request will be immediately |
21 // informed that the permission request failed.) | 22 // informed that the permission request failed.) |
22 // | 23 // |
23 // A PermissionBubbleManager is associated with a particular WebContents. | 24 // A PermissionBubbleManager is associated with a particular WebContents. |
24 // Requests attached to a particular WebContents' PBM must outlive it. | 25 // Requests attached to a particular WebContents' PBM must outlive it. |
25 // | 26 // |
26 // The PermissionBubbleManager should be addressed on the UI thread. | 27 // The PermissionBubbleManager should be addressed on the UI thread. |
27 class PermissionBubbleManager | 28 class PermissionBubbleManager |
28 : public content::WebContentsObserver, | 29 : public content::WebContentsObserver, |
29 public content::WebContentsUserData<PermissionBubbleManager>, | 30 public content::WebContentsUserData<PermissionBubbleManager>, |
30 public PermissionBubbleView::Delegate { | 31 public PermissionBubbleView::Delegate { |
31 public: | 32 public: |
32 // Return the flag-driven enabled state of permissions bubbles. | 33 // Return the flag-driven enabled state of permissions bubbles. |
33 static bool Enabled(); | 34 static bool Enabled(); |
34 | 35 |
35 virtual ~PermissionBubbleManager(); | 36 virtual ~PermissionBubbleManager(); |
36 | 37 |
37 // Add a new request to the permission bubble. Ownership of the request | 38 // Add a new request to the permission bubble. Ownership of the request |
38 // remains with the caller. The caller must arrange for the request to | 39 // remains with the caller. The caller must arrange for the request to |
39 // outlive the PermissionBubbleManager. | 40 // outlive the PermissionBubbleManager. If a bubble is visible when this |
41 // call is made, the request will be queued up and shown after the current | |
42 // bubble closes. | |
40 virtual void AddRequest(PermissionBubbleRequest* request); | 43 virtual void AddRequest(PermissionBubbleRequest* request); |
41 | 44 |
42 // Set the active view for the permission bubble. If this is NULL, it | 45 // Set the active view for the permission bubble. If this is NULL, it |
43 // means the permission bubble is no longer showing. | 46 // means the permission bubble is no longer showing. |
44 virtual void SetView(PermissionBubbleView* view); | 47 virtual void SetView(PermissionBubbleView* view); |
45 | 48 |
49 protected: | |
50 // Sets the coalesce time interval to |interval_ms|. For testing only. | |
51 void SetCoalesceIntervalForTesting(int interval_ms); | |
52 | |
46 private: | 53 private: |
47 friend class PermissionBubbleManagerTest; | 54 friend class PermissionBubbleManagerTest; |
48 friend class content::WebContentsUserData<PermissionBubbleManager>; | 55 friend class content::WebContentsUserData<PermissionBubbleManager>; |
49 | 56 |
50 explicit PermissionBubbleManager(content::WebContents* web_contents); | 57 explicit PermissionBubbleManager(content::WebContents* web_contents); |
51 | 58 |
52 // contents::WebContentsObserver: | 59 // contents::WebContentsObserver: |
53 virtual void WebContentsDestroyed( | 60 virtual void WebContentsDestroyed( |
Greg Billock
2014/02/07 20:14:24
Lets add
DocumentOnLoadCompletedInMainFrame
Docum
leng
2014/02/08 00:11:18
I tested those two functions, along with DidFinish
Greg Billock
2014/02/11 16:26:50
Sounds good. Did you try with iframes? That might
leng
2014/02/11 16:46:51
I did not try with iframes. Now you know how much
| |
54 content::WebContents* web_contents) OVERRIDE; | 61 content::WebContents* web_contents) OVERRIDE; |
55 | 62 |
56 // PermissionBubbleView::Delegate: | 63 // PermissionBubbleView::Delegate: |
57 virtual void ToggleAccept(int request_index, bool new_value) OVERRIDE; | 64 virtual void ToggleAccept(int request_index, bool new_value) OVERRIDE; |
58 virtual void SetCustomizationMode() OVERRIDE; | 65 virtual void SetCustomizationMode() OVERRIDE; |
59 virtual void Accept() OVERRIDE; | 66 virtual void Accept() OVERRIDE; |
60 virtual void Deny() OVERRIDE; | 67 virtual void Deny() OVERRIDE; |
61 virtual void Closing() OVERRIDE; | 68 virtual void Closing() OVERRIDE; |
62 | 69 |
70 // Called when the coalescing timer is done. Will show the bubble. | |
71 void OnTimerExpired(); | |
72 | |
63 // Finalize the pending permissions request. | 73 // Finalize the pending permissions request. |
64 void FinalizeBubble(); | 74 void FinalizeBubble(); |
65 | 75 |
66 // Whether or not we are showing the bubble in this tab. | 76 // Whether or not we are showing the bubble in this tab. |
67 bool bubble_showing_; | 77 bool bubble_showing_; |
68 | 78 |
69 // Set to the UI surface to be used to display the permissions requests. | 79 // Set to the UI surface to be used to display the permissions requests. |
70 PermissionBubbleView* view_; | 80 PermissionBubbleView* view_; |
71 | 81 |
72 std::vector<PermissionBubbleRequest*> requests_; | 82 std::vector<PermissionBubbleRequest*> requests_; |
83 std::vector<PermissionBubbleRequest*> queued_requests_; | |
73 std::vector<bool> accept_state_; | 84 std::vector<bool> accept_state_; |
74 bool customization_mode_; | 85 bool customization_mode_; |
86 | |
87 scoped_ptr<base::Timer> timer_; | |
75 }; | 88 }; |
76 | 89 |
77 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ | 90 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ |
OLD | NEW |