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 #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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 172 } |
173 | 173 |
174 std::vector<bool>::iterator accepts_iter = accept_states_.begin(); | 174 std::vector<bool>::iterator accepts_iter = accept_states_.begin(); |
175 for (requests_iter = requests_.begin(), accepts_iter = accept_states_.begin(); | 175 for (requests_iter = requests_.begin(), accepts_iter = accept_states_.begin(); |
176 requests_iter != requests_.end(); | 176 requests_iter != requests_.end(); |
177 requests_iter++, accepts_iter++) { | 177 requests_iter++, accepts_iter++) { |
178 if (*requests_iter != request) | 178 if (*requests_iter != request) |
179 continue; | 179 continue; |
180 | 180 |
181 // We can simply erase the current entry in the request table if we aren't | 181 // We can simply erase the current entry in the request table if we aren't |
182 // showing the dialog, or if we are showing it and it can accept the update. | 182 // showing the dialog, or if we are showing it and it can be cancelled. |
183 bool can_erase = !view_ || view_->CanAcceptRequestUpdate(); | 183 if (!view_ || view_->MaybeCancelRequest()) { |
184 if (can_erase) { | |
185 RequestFinishedIncludingDuplicates(*requests_iter); | |
186 requests_.erase(requests_iter); | 184 requests_.erase(requests_iter); |
187 accept_states_.erase(accepts_iter); | 185 accept_states_.erase(accepts_iter); |
188 | 186 if (view_) |
189 if (view_) { | |
190 view_->Hide(); | |
191 // Will redraw the bubble if it is being shown. | |
192 DequeueRequestsAndShowBubble(); | 187 DequeueRequestsAndShowBubble(); |
193 } | 188 } else { |
194 return; | 189 // The prompt is still being shown so replace the request with a dummy. |
| 190 *requests_iter = new CancelledRequest(*requests_iter); |
195 } | 191 } |
196 | 192 RequestFinishedIncludingDuplicates(request); |
197 // Cancel the existing request and replace it with a dummy. | |
198 PermissionRequest* cancelled_request = | |
199 new CancelledRequest(*requests_iter); | |
200 RequestFinishedIncludingDuplicates(*requests_iter); | |
201 *requests_iter = cancelled_request; | |
202 return; | 193 return; |
203 } | 194 } |
204 | 195 |
205 // Since |request| wasn't found in queued_requests_, queued_frame_requests_ or | 196 // Since |request| wasn't found in queued_requests_, queued_frame_requests_ or |
206 // requests_ it must have been marked as a duplicate. We can't search | 197 // requests_ it must have been marked as a duplicate. We can't search |
207 // duplicate_requests_ by value, so instead use GetExistingRequest to find the | 198 // duplicate_requests_ by value, so instead use GetExistingRequest to find the |
208 // key (request it was duped against), and iterate through duplicates of that. | 199 // key (request it was duped against), and iterate through duplicates of that. |
209 PermissionRequest* existing_request = GetExistingRequest(request); | 200 PermissionRequest* existing_request = GetExistingRequest(request); |
210 auto range = duplicate_requests_.equal_range(existing_request); | 201 auto range = duplicate_requests_.equal_range(existing_request); |
211 for (auto it = range.first; it != range.second; ++it) { | 202 for (auto it = range.first; it != range.second; ++it) { |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 Accept(); | 534 Accept(); |
544 } | 535 } |
545 break; | 536 break; |
546 case DISMISS: | 537 case DISMISS: |
547 Closing(); | 538 Closing(); |
548 break; | 539 break; |
549 case NONE: | 540 case NONE: |
550 NOTREACHED(); | 541 NOTREACHED(); |
551 } | 542 } |
552 } | 543 } |
OLD | NEW |