| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 FinalizeBubble(); | 306 FinalizeBubble(); |
| 307 | 307 |
| 308 // The WebContents is going away; be aggressively paranoid and delete | 308 // The WebContents is going away; be aggressively paranoid and delete |
| 309 // ourselves lest other parts of the system attempt to add permission bubbles | 309 // ourselves lest other parts of the system attempt to add permission bubbles |
| 310 // or use us otherwise during the destruction. | 310 // or use us otherwise during the destruction. |
| 311 web_contents()->RemoveUserData(UserDataKey()); | 311 web_contents()->RemoveUserData(UserDataKey()); |
| 312 // That was the equivalent of "delete this". This object is now destroyed; | 312 // That was the equivalent of "delete this". This object is now destroyed; |
| 313 // returning from this function is the only safe thing to do. | 313 // returning from this function is the only safe thing to do. |
| 314 } | 314 } |
| 315 | 315 |
| 316 const std::vector<PermissionRequest*>& PermissionRequestManager::Requests() { |
| 317 return requests_; |
| 318 } |
| 319 |
| 320 const std::vector<bool>& PermissionRequestManager::AcceptStates() { |
| 321 return accept_states_; |
| 322 } |
| 323 |
| 316 void PermissionRequestManager::ToggleAccept(int request_index, bool new_value) { | 324 void PermissionRequestManager::ToggleAccept(int request_index, bool new_value) { |
| 317 DCHECK(request_index < static_cast<int>(accept_states_.size())); | 325 DCHECK(request_index < static_cast<int>(accept_states_.size())); |
| 318 accept_states_[request_index] = new_value; | 326 accept_states_[request_index] = new_value; |
| 319 } | 327 } |
| 320 | 328 |
| 321 void PermissionRequestManager::TogglePersist(bool new_value) { | 329 void PermissionRequestManager::TogglePersist(bool new_value) { |
| 322 persist_ = new_value; | 330 persist_ = new_value; |
| 323 } | 331 } |
| 324 | 332 |
| 325 void PermissionRequestManager::Accept() { | 333 void PermissionRequestManager::Accept() { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 accept_states_.resize(requests_.size(), true); | 401 accept_states_.resize(requests_.size(), true); |
| 394 | 402 |
| 395 ShowBubble(); | 403 ShowBubble(); |
| 396 } | 404 } |
| 397 | 405 |
| 398 void PermissionRequestManager::ShowBubble() { | 406 void PermissionRequestManager::ShowBubble() { |
| 399 DCHECK(view_); | 407 DCHECK(view_); |
| 400 DCHECK(!requests_.empty()); | 408 DCHECK(!requests_.empty()); |
| 401 DCHECK(main_frame_has_fully_loaded_); | 409 DCHECK(main_frame_has_fully_loaded_); |
| 402 | 410 |
| 403 view_->Show(requests_, accept_states_); | 411 view_->Show(); |
| 404 PermissionUmaUtil::PermissionPromptShown(requests_); | 412 PermissionUmaUtil::PermissionPromptShown(requests_); |
| 405 NotifyBubbleAdded(); | 413 NotifyBubbleAdded(); |
| 406 | 414 |
| 407 // If in testing mode, automatically respond to the bubble that was shown. | 415 // If in testing mode, automatically respond to the bubble that was shown. |
| 408 if (auto_response_for_test_ != NONE) | 416 if (auto_response_for_test_ != NONE) |
| 409 DoAutoResponseForTesting(); | 417 DoAutoResponseForTesting(); |
| 410 } | 418 } |
| 411 | 419 |
| 412 void PermissionRequestManager::FinalizeBubble() { | 420 void PermissionRequestManager::FinalizeBubble() { |
| 413 if (view_ && !view_->HidesAutomatically()) | 421 if (view_ && !view_->HidesAutomatically()) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 Accept(); | 543 Accept(); |
| 536 } | 544 } |
| 537 break; | 545 break; |
| 538 case DISMISS: | 546 case DISMISS: |
| 539 Closing(); | 547 Closing(); |
| 540 break; | 548 break; |
| 541 case NONE: | 549 case NONE: |
| 542 NOTREACHED(); | 550 NOTREACHED(); |
| 543 } | 551 } |
| 544 } | 552 } |
| OLD | NEW |