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

Side by Side Diff: chrome/browser/permissions/permission_request_manager.h

Issue 2081103002: Rename PermissionBubbleManager to PermissionRequestManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 5 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
OLDNEW
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_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_
6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_
7 7
8 #include <unordered_map> 8 #include <unordered_map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" 14 #include "chrome/browser/ui/website_settings/permission_bubble_view.h"
15 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
16 #include "content/public/browser/web_contents_user_data.h" 16 #include "content/public/browser/web_contents_user_data.h"
17 17
18 class PermissionBubbleRequest; 18 class PermissionBubbleRequest;
19 19
20 // Provides access to permissions bubbles. Allows clients to add a request 20 // Provides access to permissions bubbles. Allows clients to add a request
21 // callback interface to the existing permission bubble configuration. 21 // callback interface to the existing permission bubble configuration.
22 // Depending on the situation and policy, that may add new UI to an existing 22 // Depending on the situation and policy, that may add new UI to an existing
23 // permission bubble, create and show a new permission bubble, or provide no 23 // permission bubble, create and show a new permission bubble, or provide no
24 // visible UI action at all. (In that case, the request will be immediately 24 // visible UI action at all. (In that case, the request will be immediately
25 // informed that the permission request failed.) 25 // informed that the permission request failed.)
26 // 26 //
27 // A PermissionBubbleManager is associated with a particular WebContents. 27 // A PermissionRequestManager is associated with a particular WebContents.
28 // Requests attached to a particular WebContents' PBM must outlive it. 28 // Requests attached to a particular WebContents' PBM must outlive it.
29 // 29 //
30 // The PermissionBubbleManager should be addressed on the UI thread. 30 // The PermissionRequestManager should be addressed on the UI thread.
31 class PermissionBubbleManager 31 class PermissionRequestManager
32 : public content::WebContentsObserver, 32 : public content::WebContentsObserver,
33 public content::WebContentsUserData<PermissionBubbleManager>, 33 public content::WebContentsUserData<PermissionRequestManager>,
34 public PermissionBubbleView::Delegate { 34 public PermissionBubbleView::Delegate {
35 public: 35 public:
36 class Observer { 36 class Observer {
37 public: 37 public:
38 virtual ~Observer(); 38 virtual ~Observer();
39 virtual void OnBubbleAdded(); 39 virtual void OnBubbleAdded();
40 }; 40 };
41 41
42 enum AutoResponseType { 42 enum AutoResponseType {
43 NONE, 43 NONE,
44 ACCEPT_ALL, 44 ACCEPT_ALL,
45 DENY_ALL, 45 DENY_ALL,
46 DISMISS 46 DISMISS
47 }; 47 };
48 48
49 ~PermissionBubbleManager() override; 49 ~PermissionRequestManager() override;
50 50
51 // Adds a new request to the permission bubble. Ownership of the request 51 // Adds a new request to the permission bubble. Ownership of the request
52 // remains with the caller. The caller must arrange for the request to 52 // remains with the caller. The caller must arrange for the request to
53 // outlive the PermissionBubbleManager. If a bubble is visible when this 53 // outlive the PermissionRequestManager. If a bubble is visible when this
54 // call is made, the request will be queued up and shown after the current 54 // call is made, the request will be queued up and shown after the current
55 // bubble closes. A request with message text identical to an outstanding 55 // bubble closes. A request with message text identical to an outstanding
56 // request will be merged with the outstanding request, and will have the same 56 // request will be merged with the outstanding request, and will have the same
57 // callbacks called as the outstanding request. 57 // callbacks called as the outstanding request.
58 void AddRequest(PermissionBubbleRequest* request); 58 void AddRequest(PermissionBubbleRequest* request);
59 59
60 // Cancels an outstanding request. This may have different effects depending 60 // Cancels an outstanding request. This may have different effects depending
61 // on what is going on with the bubble. If the request is pending, it will be 61 // on what is going on with the bubble. If the request is pending, it will be
62 // removed and never shown. If the request is showing, it will continue to be 62 // removed and never shown. If the request is showing, it will continue to be
63 // shown, but the user's action won't be reported back to the request object. 63 // shown, but the user's action won't be reported back to the request object.
64 // In some circumstances, we can remove the request from the bubble, and may 64 // In some circumstances, we can remove the request from the bubble, and may
65 // do so. The request will have RequestFinished executed on it if it is found, 65 // do so. The request will have RequestFinished executed on it if it is found,
66 // at which time the caller is free to delete the request. 66 // at which time the caller is free to delete the request.
67 void CancelRequest(PermissionBubbleRequest* request); 67 void CancelRequest(PermissionBubbleRequest* request);
68 68
69 // Hides the bubble. 69 // Hides the bubble.
70 void HideBubble(); 70 void HideBubble();
71 71
72 // Will show a permission bubble if there is a pending permission request on 72 // Will show a permission bubble if there is a pending permission request on
73 // the web contents that the PermissionBubbleManager belongs to. 73 // the web contents that the PermissionRequestManager belongs to.
74 void DisplayPendingRequests(); 74 void DisplayPendingRequests();
75 75
76 // Will reposition the bubble (may change parent if necessary). 76 // Will reposition the bubble (may change parent if necessary).
77 void UpdateAnchorPosition(); 77 void UpdateAnchorPosition();
78 78
79 // True if a permission bubble is currently visible. 79 // True if a permission bubble is currently visible.
80 // TODO(hcarmona): Remove this as part of the bubble API work. 80 // TODO(hcarmona): Remove this as part of the bubble API work.
81 bool IsBubbleVisible(); 81 bool IsBubbleVisible();
82 82
83 // Get the native window of the bubble. 83 // Get the native window of the bubble.
(...skipping 11 matching lines...) Expand all
95 void set_auto_response_for_test(AutoResponseType response) { 95 void set_auto_response_for_test(AutoResponseType response) {
96 auto_response_for_test_ = response; 96 auto_response_for_test_ = response;
97 } 97 }
98 98
99 private: 99 private:
100 // TODO(felt): Update testing so that it doesn't involve a lot of friends. 100 // TODO(felt): Update testing so that it doesn't involve a lot of friends.
101 friend class GeolocationBrowserTest; 101 friend class GeolocationBrowserTest;
102 friend class GeolocationPermissionContextTests; 102 friend class GeolocationPermissionContextTests;
103 friend class MockPermissionBubbleFactory; 103 friend class MockPermissionBubbleFactory;
104 friend class MockPermissionBubbleView; 104 friend class MockPermissionBubbleView;
105 friend class PermissionBubbleManagerTest; 105 friend class PermissionRequestManagerTest;
106 friend class PermissionContextBaseTests; 106 friend class PermissionContextBaseTests;
107 friend class content::WebContentsUserData<PermissionBubbleManager>; 107 friend class content::WebContentsUserData<PermissionRequestManager>;
108 FRIEND_TEST_ALL_PREFIXES(DownloadTest, TestMultipleDownloadsBubble); 108 FRIEND_TEST_ALL_PREFIXES(DownloadTest, TestMultipleDownloadsBubble);
109 109
110 explicit PermissionBubbleManager(content::WebContents* web_contents); 110 explicit PermissionRequestManager(content::WebContents* web_contents);
111 111
112 // WebContentsObserver: 112 // WebContentsObserver:
113 void DidNavigateMainFrame( 113 void DidNavigateMainFrame(
114 const content::LoadCommittedDetails& details, 114 const content::LoadCommittedDetails& details,
115 const content::FrameNavigateParams& params) override; 115 const content::FrameNavigateParams& params) override;
116 void DocumentOnLoadCompletedInMainFrame() override; 116 void DocumentOnLoadCompletedInMainFrame() override;
117 void DocumentLoadedInFrame( 117 void DocumentLoadedInFrame(
118 content::RenderFrameHost* render_frame_host) override; 118 content::RenderFrameHost* render_frame_host) override;
119 void WebContentsDestroyed() override; 119 void WebContentsDestroyed() override;
120 120
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // TODO(gbillock): if there are iframes in the page, we need to deal with it. 181 // TODO(gbillock): if there are iframes in the page, we need to deal with it.
182 GURL request_url_; 182 GURL request_url_;
183 bool main_frame_has_fully_loaded_; 183 bool main_frame_has_fully_loaded_;
184 184
185 // Whether each of the requests in |requests_| is accepted by the user. 185 // Whether each of the requests in |requests_| is accepted by the user.
186 std::vector<bool> accept_states_; 186 std::vector<bool> accept_states_;
187 187
188 base::ObserverList<Observer> observer_list_; 188 base::ObserverList<Observer> observer_list_;
189 AutoResponseType auto_response_for_test_; 189 AutoResponseType auto_response_for_test_;
190 190
191 base::WeakPtrFactory<PermissionBubbleManager> weak_factory_; 191 base::WeakPtrFactory<PermissionRequestManager> weak_factory_;
192 }; 192 };
193 193
194 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ 194 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698