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

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

Issue 2403763003: [Mac] Address buggy permission bubble behaviour on dismissal via ESC. (Closed)
Patch Set: Override [cancel] instead of [dealloc] Created 4 years, 2 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/metrics/user_metrics_action.h" 10 #include "base/metrics/user_metrics_action.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if (request == it->second) { 216 if (request == it->second) {
217 it->second->RequestFinished(); 217 it->second->RequestFinished();
218 duplicate_requests_.erase(it); 218 duplicate_requests_.erase(it);
219 return; 219 return;
220 } 220 }
221 } 221 }
222 222
223 NOTREACHED(); // Callers should not cancel requests that are not pending. 223 NOTREACHED(); // Callers should not cancel requests that are not pending.
224 } 224 }
225 225
226 void PermissionRequestManager::DismissBubble() {
hcarmona 2016/10/10 18:08:19 |Closing| calls |FinalizeBubble| which hides the b
dominickn 2016/10/10 22:55:48 This would work, and I did think of doing that. Th
hcarmona 2016/10/11 14:45:33 Casting to PermissionPrompt::Delegate will let you
227 if (IsBubbleVisible())
228 Closing();
229 HideBubble();
230 }
231
226 void PermissionRequestManager::HideBubble() { 232 void PermissionRequestManager::HideBubble() {
227 // Disengage from the existing view if there is one. 233 // Disengage from the existing view if there is one.
228 if (!view_) 234 if (!view_)
229 return; 235 return;
230 236
231 view_->SetDelegate(nullptr); 237 view_->SetDelegate(nullptr);
232 view_->Hide(); 238 view_->Hide();
233 view_.reset(); 239 view_.reset();
234 } 240 }
235 241
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 view_->Show(requests_, accept_states_); 394 view_->Show(requests_, accept_states_);
389 PermissionUmaUtil::PermissionPromptShown(requests_); 395 PermissionUmaUtil::PermissionPromptShown(requests_);
390 NotifyBubbleAdded(); 396 NotifyBubbleAdded();
391 397
392 // If in testing mode, automatically respond to the bubble that was shown. 398 // If in testing mode, automatically respond to the bubble that was shown.
393 if (auto_response_for_test_ != NONE) 399 if (auto_response_for_test_ != NONE)
394 DoAutoResponseForTesting(); 400 DoAutoResponseForTesting();
395 } 401 }
396 402
397 void PermissionRequestManager::FinalizeBubble() { 403 void PermissionRequestManager::FinalizeBubble() {
398 if (view_) 404 if (view_) {
399 view_->Hide(); 405 view_->Hide();
406 #if !defined(OS_ANDROID)
407 } else if (web_contents() && !web_contents()->IsBeingDestroyed()) {
408 // Ensure that the view exists. It may have been deleted by HideBubble,
hcarmona 2016/10/10 18:08:19 Good description. However, since your change is fi
dominickn 2016/10/10 22:55:47 Done.
409 // creating a race condition where if AddRequest is called before
410 // DisplayPendingRequests, no prompt will be displayed. See
411 // crbug.com/653498.
412 view_ = view_factory_.Run(web_contents());
413 view_->SetDelegate(this);
414 #endif
415 }
400 416
401 std::vector<PermissionRequest*>::iterator requests_iter; 417 std::vector<PermissionRequest*>::iterator requests_iter;
402 for (requests_iter = requests_.begin(); 418 for (requests_iter = requests_.begin();
403 requests_iter != requests_.end(); 419 requests_iter != requests_.end();
404 requests_iter++) { 420 requests_iter++) {
405 RequestFinishedIncludingDuplicates(*requests_iter); 421 RequestFinishedIncludingDuplicates(*requests_iter);
406 } 422 }
407 requests_.clear(); 423 requests_.clear();
408 accept_states_.clear(); 424 accept_states_.clear();
409 if (queued_requests_.size() || queued_frame_requests_.size()) 425 if (queued_requests_.size() || queued_frame_requests_.size())
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 case DENY_ALL: 530 case DENY_ALL:
515 Deny(); 531 Deny();
516 break; 532 break;
517 case DISMISS: 533 case DISMISS:
518 Closing(); 534 Closing();
519 break; 535 break;
520 case NONE: 536 case NONE:
521 NOTREACHED(); 537 NOTREACHED();
522 } 538 }
523 } 539 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698