| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 it->second->RequestFinished(); | 222 it->second->RequestFinished(); |
| 223 duplicate_requests_.erase(it); | 223 duplicate_requests_.erase(it); |
| 224 return; | 224 return; |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 NOTREACHED(); // Callers should not cancel requests that are not pending. | 228 NOTREACHED(); // Callers should not cancel requests that are not pending. |
| 229 } | 229 } |
| 230 | 230 |
| 231 void PermissionRequestManager::HideBubble() { | 231 void PermissionRequestManager::HideBubble() { |
| 232 #if defined(ANDROID) | 232 // Disengage from the existing view if there is one and it doesn't manage |
| 233 // The infobar system manages infobar lifetime and visibility so don't delete | 233 // its own visibility. |
| 234 // the PermissionPromptAndroid. | 234 if (!view_ || view_->HidesAutomatically()) |
| 235 NOTREACHED(); | |
| 236 #else | |
| 237 // Disengage from the existing view if there is one. | |
| 238 if (!view_) | |
| 239 return; | 235 return; |
| 240 | 236 |
| 241 view_->SetDelegate(nullptr); | 237 view_->SetDelegate(nullptr); |
| 242 view_->Hide(); | 238 view_->Hide(); |
| 243 view_.reset(); | 239 view_.reset(); |
| 244 #endif | |
| 245 } | 240 } |
| 246 | 241 |
| 247 void PermissionRequestManager::DisplayPendingRequests() { | 242 void PermissionRequestManager::DisplayPendingRequests() { |
| 248 if (IsBubbleVisible()) | 243 if (IsBubbleVisible()) |
| 249 return; | 244 return; |
| 250 | 245 |
| 251 view_ = view_factory_.Run(web_contents()); | 246 view_ = view_factory_.Run(web_contents()); |
| 252 view_->SetDelegate(this); | 247 view_->SetDelegate(this); |
| 253 | 248 |
| 254 TriggerShowBubble(); | 249 TriggerShowBubble(); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 view_->Show(requests_, accept_states_); | 400 view_->Show(requests_, accept_states_); |
| 406 PermissionUmaUtil::PermissionPromptShown(requests_); | 401 PermissionUmaUtil::PermissionPromptShown(requests_); |
| 407 NotifyBubbleAdded(); | 402 NotifyBubbleAdded(); |
| 408 | 403 |
| 409 // If in testing mode, automatically respond to the bubble that was shown. | 404 // If in testing mode, automatically respond to the bubble that was shown. |
| 410 if (auto_response_for_test_ != NONE) | 405 if (auto_response_for_test_ != NONE) |
| 411 DoAutoResponseForTesting(); | 406 DoAutoResponseForTesting(); |
| 412 } | 407 } |
| 413 | 408 |
| 414 void PermissionRequestManager::FinalizeBubble() { | 409 void PermissionRequestManager::FinalizeBubble() { |
| 415 if (view_) | 410 if (view_ && !view_->HidesAutomatically()) |
| 416 view_->Hide(); | 411 view_->Hide(); |
| 417 | 412 |
| 418 std::vector<PermissionRequest*>::iterator requests_iter; | 413 std::vector<PermissionRequest*>::iterator requests_iter; |
| 419 for (requests_iter = requests_.begin(); | 414 for (requests_iter = requests_.begin(); |
| 420 requests_iter != requests_.end(); | 415 requests_iter != requests_.end(); |
| 421 requests_iter++) { | 416 requests_iter++) { |
| 422 RequestFinishedIncludingDuplicates(*requests_iter); | 417 RequestFinishedIncludingDuplicates(*requests_iter); |
| 423 } | 418 } |
| 424 requests_.clear(); | 419 requests_.clear(); |
| 425 accept_states_.clear(); | 420 accept_states_.clear(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 case DENY_ALL: | 527 case DENY_ALL: |
| 533 Deny(); | 528 Deny(); |
| 534 break; | 529 break; |
| 535 case DISMISS: | 530 case DISMISS: |
| 536 Closing(); | 531 Closing(); |
| 537 break; | 532 break; |
| 538 case NONE: | 533 case NONE: |
| 539 NOTREACHED(); | 534 NOTREACHED(); |
| 540 } | 535 } |
| 541 } | 536 } |
| OLD | NEW |