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

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

Issue 2123653006: Rename PermissionBubbleRequest to PermissionRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission_manager_rename
Patch Set: Fix missed file 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_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_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 PermissionRequest;
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 PermissionRequestManager 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.
(...skipping 19 matching lines...) Expand all
48 48
49 ~PermissionRequestManager() 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 PermissionRequestManager. 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(PermissionRequest* 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(PermissionRequest* 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 PermissionRequestManager 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();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 // Cancel any pending requests. This is called if the WebContents 137 // Cancel any pending requests. This is called if the WebContents
138 // on which permissions calls are pending is destroyed or navigated away 138 // on which permissions calls are pending is destroyed or navigated away
139 // from the requesting page. 139 // from the requesting page.
140 void CancelPendingQueues(); 140 void CancelPendingQueues();
141 141
142 // Searches |requests_|, |queued_requests_| and |queued_frame_requests_| - but 142 // Searches |requests_|, |queued_requests_| and |queued_frame_requests_| - but
143 // *not* |duplicate_requests_| - for a request matching |request|, and returns 143 // *not* |duplicate_requests_| - for a request matching |request|, and returns
144 // the matching request, or |nullptr| if no match. Note that the matching 144 // the matching request, or |nullptr| if no match. Note that the matching
145 // request may or may not be the same object as |request|. 145 // request may or may not be the same object as |request|.
146 PermissionBubbleRequest* GetExistingRequest(PermissionBubbleRequest* request); 146 PermissionRequest* GetExistingRequest(PermissionRequest* request);
147 147
148 // Returns true if |queue| contains a request which was generated by a user 148 // Returns true if |queue| contains a request which was generated by a user
149 // gesture. Returns false otherwise. 149 // gesture. Returns false otherwise.
150 bool HasUserGestureRequest( 150 bool HasUserGestureRequest(const std::vector<PermissionRequest*>& queue);
151 const std::vector<PermissionBubbleRequest*>& queue);
152 151
153 // Calls PermissionGranted on a request and all its duplicates. 152 // Calls PermissionGranted on a request and all its duplicates.
154 void PermissionGrantedIncludingDuplicates(PermissionBubbleRequest* request); 153 void PermissionGrantedIncludingDuplicates(PermissionRequest* request);
155 // Calls PermissionDenied on a request and all its duplicates. 154 // Calls PermissionDenied on a request and all its duplicates.
156 void PermissionDeniedIncludingDuplicates(PermissionBubbleRequest* request); 155 void PermissionDeniedIncludingDuplicates(PermissionRequest* request);
157 // Calls Cancelled on a request and all its duplicates. 156 // Calls Cancelled on a request and all its duplicates.
158 void CancelledIncludingDuplicates(PermissionBubbleRequest* request); 157 void CancelledIncludingDuplicates(PermissionRequest* request);
159 // Calls RequestFinished on a request and all its duplicates. 158 // Calls RequestFinished on a request and all its duplicates.
160 void RequestFinishedIncludingDuplicates(PermissionBubbleRequest* request); 159 void RequestFinishedIncludingDuplicates(PermissionRequest* request);
161 160
162 void NotifyBubbleAdded(); 161 void NotifyBubbleAdded();
163 162
164 void DoAutoResponseForTesting(); 163 void DoAutoResponseForTesting();
165 164
166 // Factory to be used to create views when needed. 165 // Factory to be used to create views when needed.
167 PermissionBubbleView::Factory view_factory_; 166 PermissionBubbleView::Factory view_factory_;
168 167
169 // The UI surface to be used to display the permissions requests. 168 // The UI surface to be used to display the permissions requests.
170 std::unique_ptr<PermissionBubbleView> view_; 169 std::unique_ptr<PermissionBubbleView> view_;
171 170
172 std::vector<PermissionBubbleRequest*> requests_; 171 std::vector<PermissionRequest*> requests_;
173 std::vector<PermissionBubbleRequest*> queued_requests_; 172 std::vector<PermissionRequest*> queued_requests_;
174 std::vector<PermissionBubbleRequest*> queued_frame_requests_; 173 std::vector<PermissionRequest*> queued_frame_requests_;
175 // Maps from the first request of a kind to subsequent requests that were 174 // Maps from the first request of a kind to subsequent requests that were
176 // duped against it. 175 // duped against it.
177 std::unordered_multimap<PermissionBubbleRequest*, PermissionBubbleRequest*> 176 std::unordered_multimap<PermissionRequest*, PermissionRequest*>
178 duplicate_requests_; 177 duplicate_requests_;
179 178
180 // URL of the main frame in the WebContents to which this manager is attached. 179 // URL of the main frame in the WebContents to which this manager is attached.
181 // TODO(gbillock): if there are iframes in the page, we need to deal with it. 180 // TODO(gbillock): if there are iframes in the page, we need to deal with it.
182 GURL request_url_; 181 GURL request_url_;
183 bool main_frame_has_fully_loaded_; 182 bool main_frame_has_fully_loaded_;
184 183
185 // Whether each of the requests in |requests_| is accepted by the user. 184 // Whether each of the requests in |requests_| is accepted by the user.
186 std::vector<bool> accept_states_; 185 std::vector<bool> accept_states_;
187 186
188 base::ObserverList<Observer> observer_list_; 187 base::ObserverList<Observer> observer_list_;
189 AutoResponseType auto_response_for_test_; 188 AutoResponseType auto_response_for_test_;
190 189
191 base::WeakPtrFactory<PermissionRequestManager> weak_factory_; 190 base::WeakPtrFactory<PermissionRequestManager> weak_factory_;
192 }; 191 };
193 192
194 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_ 193 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_request_impl.cc ('k') | chrome/browser/permissions/permission_request_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698