| 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_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 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // on which permissions calls are pending is destroyed or navigated away | 156 // on which permissions calls are pending is destroyed or navigated away |
| 157 // from the requesting page. | 157 // from the requesting page. |
| 158 void CancelPendingQueues(); | 158 void CancelPendingQueues(); |
| 159 | 159 |
| 160 // Searches |requests_|, |queued_requests_| and |queued_frame_requests_| - but | 160 // Searches |requests_|, |queued_requests_| and |queued_frame_requests_| - but |
| 161 // *not* |duplicate_requests_| - for a request matching |request|, and returns | 161 // *not* |duplicate_requests_| - for a request matching |request|, and returns |
| 162 // the matching request, or |nullptr| if no match. Note that the matching | 162 // the matching request, or |nullptr| if no match. Note that the matching |
| 163 // request may or may not be the same object as |request|. | 163 // request may or may not be the same object as |request|. |
| 164 PermissionRequest* GetExistingRequest(PermissionRequest* request); | 164 PermissionRequest* GetExistingRequest(PermissionRequest* request); |
| 165 | 165 |
| 166 // Returns true if |queue| contains a request which was generated by a user | |
| 167 // gesture. Returns false otherwise. | |
| 168 bool HasUserGestureRequest(const std::vector<PermissionRequest*>& queue); | |
| 169 | |
| 170 // Calls PermissionGranted on a request and all its duplicates. | 166 // Calls PermissionGranted on a request and all its duplicates. |
| 171 void PermissionGrantedIncludingDuplicates(PermissionRequest* request); | 167 void PermissionGrantedIncludingDuplicates(PermissionRequest* request); |
| 172 // Calls PermissionDenied on a request and all its duplicates. | 168 // Calls PermissionDenied on a request and all its duplicates. |
| 173 void PermissionDeniedIncludingDuplicates(PermissionRequest* request); | 169 void PermissionDeniedIncludingDuplicates(PermissionRequest* request); |
| 174 // Calls Cancelled on a request and all its duplicates. | 170 // Calls Cancelled on a request and all its duplicates. |
| 175 void CancelledIncludingDuplicates(PermissionRequest* request); | 171 void CancelledIncludingDuplicates(PermissionRequest* request); |
| 176 // Calls RequestFinished on a request and all its duplicates. | 172 // Calls RequestFinished on a request and all its duplicates. |
| 177 void RequestFinishedIncludingDuplicates(PermissionRequest* request); | 173 void RequestFinishedIncludingDuplicates(PermissionRequest* request); |
| 178 | 174 |
| 179 void NotifyBubbleAdded(); | 175 void NotifyBubbleAdded(); |
| 180 | 176 |
| 181 void DoAutoResponseForTesting(); | 177 void DoAutoResponseForTesting(); |
| 182 | 178 |
| 183 // Factory to be used to create views when needed. | 179 // Factory to be used to create views when needed. |
| 184 PermissionPrompt::Factory view_factory_; | 180 PermissionPrompt::Factory view_factory_; |
| 185 | 181 |
| 186 // The UI surface to be used to display the permissions requests. | 182 // The UI surface to be used to display the permissions requests. |
| 187 std::unique_ptr<PermissionPrompt> view_; | 183 std::unique_ptr<PermissionPrompt> view_; |
| 188 | 184 |
| 189 std::vector<PermissionRequest*> requests_; | 185 std::vector<PermissionRequest*> requests_; |
| 190 std::vector<PermissionRequest*> queued_requests_; | 186 std::vector<PermissionRequest*> queued_requests_; |
| 191 std::vector<PermissionRequest*> queued_frame_requests_; | 187 std::vector<PermissionRequest*> queued_frame_requests_; |
| 192 // Maps from the first request of a kind to subsequent requests that were | 188 // Maps from the first request of a kind to subsequent requests that were |
| 193 // duped against it. | 189 // duped against it. |
| 194 std::unordered_multimap<PermissionRequest*, PermissionRequest*> | 190 std::unordered_multimap<PermissionRequest*, PermissionRequest*> |
| 195 duplicate_requests_; | 191 duplicate_requests_; |
| 196 | 192 |
| 197 // URL of the main frame in the WebContents to which this manager is attached. | |
| 198 // TODO(gbillock): if there are iframes in the page, we need to deal with it. | |
| 199 GURL request_url_; | |
| 200 bool main_frame_has_fully_loaded_; | 193 bool main_frame_has_fully_loaded_; |
| 201 | 194 |
| 202 // Whether the response to each request should be persisted. | 195 // Whether the response to each request should be persisted. |
| 203 bool persist_; | 196 bool persist_; |
| 204 | 197 |
| 205 // Whether each of the requests in |requests_| is accepted by the user. | 198 // Whether each of the requests in |requests_| is accepted by the user. |
| 206 std::vector<bool> accept_states_; | 199 std::vector<bool> accept_states_; |
| 207 | 200 |
| 208 base::ObserverList<Observer> observer_list_; | 201 base::ObserverList<Observer> observer_list_; |
| 209 AutoResponseType auto_response_for_test_; | 202 AutoResponseType auto_response_for_test_; |
| 210 | 203 |
| 211 base::WeakPtrFactory<PermissionRequestManager> weak_factory_; | 204 base::WeakPtrFactory<PermissionRequestManager> weak_factory_; |
| 212 }; | 205 }; |
| 213 | 206 |
| 214 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_ | 207 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_ |
| OLD | NEW |