| 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/ui/website_settings/permission_bubble_manager.h" | 5 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/user_metrics_action.h" | 8 #include "base/metrics/user_metrics_action.h" |
| 9 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | 9 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 return; | 227 return; |
| 228 | 228 |
| 229 // If we have navigated to a new url... | 229 // If we have navigated to a new url... |
| 230 if (request_url_ != web_contents()->GetLastCommittedURL()) { | 230 if (request_url_ != web_contents()->GetLastCommittedURL()) { |
| 231 // Kill off existing bubble and cancel any pending requests. | 231 // Kill off existing bubble and cancel any pending requests. |
| 232 CancelPendingQueue(); | 232 CancelPendingQueue(); |
| 233 FinalizeBubble(); | 233 FinalizeBubble(); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 void PermissionBubbleManager::WebContentsDestroyed( | 237 void PermissionBubbleManager::WebContentsDestroyed() { |
| 238 content::WebContents* web_contents) { | |
| 239 // If the web contents has been destroyed, treat the bubble as cancelled. | 238 // If the web contents has been destroyed, treat the bubble as cancelled. |
| 240 CancelPendingQueue(); | 239 CancelPendingQueue(); |
| 241 FinalizeBubble(); | 240 FinalizeBubble(); |
| 242 | 241 |
| 243 // The WebContents is going away; be aggressively paranoid and delete | 242 // The WebContents is going away; be aggressively paranoid and delete |
| 244 // ourselves lest other parts of the system attempt to add permission bubbles | 243 // ourselves lest other parts of the system attempt to add permission bubbles |
| 245 // or use us otherwise during the destruction. | 244 // or use us otherwise during the destruction. |
| 246 web_contents->RemoveUserData(UserDataKey()); | 245 web_contents()->RemoveUserData(UserDataKey()); |
| 247 // That was the equivalent of "delete this". This object is now destroyed; | 246 // That was the equivalent of "delete this". This object is now destroyed; |
| 248 // returning from this function is the only safe thing to do. | 247 // returning from this function is the only safe thing to do. |
| 249 } | 248 } |
| 250 | 249 |
| 251 void PermissionBubbleManager::ToggleAccept(int request_index, bool new_value) { | 250 void PermissionBubbleManager::ToggleAccept(int request_index, bool new_value) { |
| 252 DCHECK(request_index < static_cast<int>(accept_states_.size())); | 251 DCHECK(request_index < static_cast<int>(accept_states_.size())); |
| 253 accept_states_[request_index] = new_value; | 252 accept_states_[request_index] = new_value; |
| 254 } | 253 } |
| 255 | 254 |
| 256 void PermissionBubbleManager::SetCustomizationMode() { | 255 void PermissionBubbleManager::SetCustomizationMode() { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 333 } |
| 335 | 334 |
| 336 void PermissionBubbleManager::CancelPendingQueue() { | 335 void PermissionBubbleManager::CancelPendingQueue() { |
| 337 std::vector<PermissionBubbleRequest*>::iterator requests_iter; | 336 std::vector<PermissionBubbleRequest*>::iterator requests_iter; |
| 338 for (requests_iter = queued_requests_.begin(); | 337 for (requests_iter = queued_requests_.begin(); |
| 339 requests_iter != queued_requests_.end(); | 338 requests_iter != queued_requests_.end(); |
| 340 requests_iter++) { | 339 requests_iter++) { |
| 341 (*requests_iter)->RequestFinished(); | 340 (*requests_iter)->RequestFinished(); |
| 342 } | 341 } |
| 343 } | 342 } |
| OLD | NEW |