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

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

Issue 2829023002: Fix cancelling permission requests on Android when the PermissionRequestManager is enabled (Closed)
Patch Set: comment Created 3 years, 8 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 #include "chrome/browser/permissions/permission_request_manager.h" 5 #include "chrome/browser/permissions/permission_request_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 181 }
182 182
183 std::vector<bool>::iterator accepts_iter = accept_states_.begin(); 183 std::vector<bool>::iterator accepts_iter = accept_states_.begin();
184 for (requests_iter = requests_.begin(), accepts_iter = accept_states_.begin(); 184 for (requests_iter = requests_.begin(), accepts_iter = accept_states_.begin();
185 requests_iter != requests_.end(); 185 requests_iter != requests_.end();
186 requests_iter++, accepts_iter++) { 186 requests_iter++, accepts_iter++) {
187 if (*requests_iter != request) 187 if (*requests_iter != request)
188 continue; 188 continue;
189 189
190 // We can simply erase the current entry in the request table if we aren't 190 // We can simply erase the current entry in the request table if we aren't
191 // showing the dialog, or if we are showing it and it can accept the update. 191 // showing the dialog
192 bool can_erase = !IsBubbleVisible() || view_->CanAcceptRequestUpdate(); 192 if (!IsBubbleVisible()) {
193 if (can_erase) {
194 RequestFinishedIncludingDuplicates(*requests_iter); 193 RequestFinishedIncludingDuplicates(*requests_iter);
195 requests_.erase(requests_iter); 194 requests_.erase(requests_iter);
196 accept_states_.erase(accepts_iter); 195 accept_states_.erase(accepts_iter);
197 196 } else if (view_->MaybeCancelRequest()) {
raymes 2017/05/01 04:23:35 I think we could document each of these cases bett
198 if (IsBubbleVisible()) { 197 RequestFinishedIncludingDuplicates(*requests_iter);
199 view_->Hide(); 198 requests_.erase(requests_iter);
200 // Will redraw the bubble if it is being shown. 199 accept_states_.erase(accepts_iter);
201 TriggerShowBubble(); 200 TriggerShowBubble();
202 } 201 } else {
203 return; 202 // Cancel the existing request and replace it with a dummy.
raymes 2017/05/01 04:23:35 I think we can clarify this comment a bit. // If t
203 PermissionRequest* cancelled_request =
204 new CancelledRequest(*requests_iter);
205 RequestFinishedIncludingDuplicates(*requests_iter);
206 *requests_iter = cancelled_request;
207 view_->Show(requests_, accept_states_);
raymes 2017/05/01 04:23:35 As discussed I think it would be preferable to all
204 } 208 }
205
206 // Cancel the existing request and replace it with a dummy.
207 PermissionRequest* cancelled_request =
208 new CancelledRequest(*requests_iter);
209 RequestFinishedIncludingDuplicates(*requests_iter);
210 *requests_iter = cancelled_request;
211 return; 209 return;
212 } 210 }
213 211
214 // Since |request| wasn't found in queued_requests_, queued_frame_requests_ or 212 // Since |request| wasn't found in queued_requests_, queued_frame_requests_ or
215 // requests_ it must have been marked as a duplicate. We can't search 213 // requests_ it must have been marked as a duplicate. We can't search
216 // duplicate_requests_ by value, so instead use GetExistingRequest to find the 214 // duplicate_requests_ by value, so instead use GetExistingRequest to find the
217 // key (request it was duped against), and iterate through duplicates of that. 215 // key (request it was duped against), and iterate through duplicates of that.
218 PermissionRequest* existing_request = GetExistingRequest(request); 216 PermissionRequest* existing_request = GetExistingRequest(request);
219 auto range = duplicate_requests_.equal_range(existing_request); 217 auto range = duplicate_requests_.equal_range(existing_request);
220 for (auto it = range.first; it != range.second; ++it) { 218 for (auto it = range.first; it != range.second; ++it) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 case DENY_ALL: 524 case DENY_ALL:
527 Deny(); 525 Deny();
528 break; 526 break;
529 case DISMISS: 527 case DISMISS:
530 Closing(); 528 Closing();
531 break; 529 break;
532 case NONE: 530 case NONE:
533 NOTREACHED(); 531 NOTREACHED();
534 } 532 }
535 } 533 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698