Chromium Code Reviews| 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/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 Loading... | |
| 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() { | |
| 227 if (IsBubbleVisible()) | |
| 228 Closing(); | |
| 229 HideBubble(); | |
|
raymes
2016/10/26 04:59:11
Could we just remove HideBubble here and then we w
dominickn
2016/10/26 05:54:23
Done.
| |
| 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 Loading... | |
| 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, | |
| 409 // creating a race condition where if AddRequest is called before | |
| 410 // DisplayPendingRequests, no prompt will be displayed. | |
| 411 view_ = view_factory_.Run(web_contents()); | |
| 412 view_->SetDelegate(this); | |
| 413 #endif | |
| 414 } | |
| 400 | 415 |
| 401 std::vector<PermissionRequest*>::iterator requests_iter; | 416 std::vector<PermissionRequest*>::iterator requests_iter; |
| 402 for (requests_iter = requests_.begin(); | 417 for (requests_iter = requests_.begin(); |
| 403 requests_iter != requests_.end(); | 418 requests_iter != requests_.end(); |
| 404 requests_iter++) { | 419 requests_iter++) { |
| 405 RequestFinishedIncludingDuplicates(*requests_iter); | 420 RequestFinishedIncludingDuplicates(*requests_iter); |
| 406 } | 421 } |
| 407 requests_.clear(); | 422 requests_.clear(); |
| 408 accept_states_.clear(); | 423 accept_states_.clear(); |
| 409 if (queued_requests_.size() || queued_frame_requests_.size()) | 424 if (queued_requests_.size() || queued_frame_requests_.size()) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 case DENY_ALL: | 529 case DENY_ALL: |
| 515 Deny(); | 530 Deny(); |
| 516 break; | 531 break; |
| 517 case DISMISS: | 532 case DISMISS: |
| 518 Closing(); | 533 Closing(); |
| 519 break; | 534 break; |
| 520 case NONE: | 535 case NONE: |
| 521 NOTREACHED(); | 536 NOTREACHED(); |
| 522 } | 537 } |
| 523 } | 538 } |
| OLD | NEW |