| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 void PermissionBubbleManager::NavigationEntryCommitted( | 138 void PermissionBubbleManager::NavigationEntryCommitted( |
| 139 const content::LoadCommittedDetails& details) { | 139 const content::LoadCommittedDetails& details) { |
| 140 if (!request_url_.is_empty() && | 140 if (!request_url_.is_empty() && |
| 141 request_url_ != web_contents()->GetLastCommittedURL()) { | 141 request_url_ != web_contents()->GetLastCommittedURL()) { |
| 142 // Kill off existing bubble and cancel any pending requests. | 142 // Kill off existing bubble and cancel any pending requests. |
| 143 CancelPendingQueue(); | 143 CancelPendingQueue(); |
| 144 FinalizeBubble(); | 144 FinalizeBubble(); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 void PermissionBubbleManager::WebContentsDestroyed( | 148 void PermissionBubbleManager::WebContentsDestroyed() { |
| 149 content::WebContents* web_contents) { | |
| 150 // If the web contents has been destroyed, do not attempt to notify | 149 // If the web contents has been destroyed, do not attempt to notify |
| 151 // the requests of any changes - simply close the bubble. | 150 // the requests of any changes - simply close the bubble. |
| 152 CancelPendingQueue(); | 151 CancelPendingQueue(); |
| 153 FinalizeBubble(); | 152 FinalizeBubble(); |
| 154 | 153 |
| 155 // The WebContents is going away; be aggressively paranoid and delete | 154 // The WebContents is going away; be aggressively paranoid and delete |
| 156 // ourselves lest other parts of the system attempt to add permission bubbles | 155 // ourselves lest other parts of the system attempt to add permission bubbles |
| 157 // or use us otherwise during the destruction. | 156 // or use us otherwise during the destruction. |
| 158 web_contents->RemoveUserData(UserDataKey()); | 157 web_contents()->RemoveUserData(UserDataKey()); |
| 159 // That was the equivalent of "delete this". This object is now destroyed; | 158 // That was the equivalent of "delete this". This object is now destroyed; |
| 160 // returning from this function is the only safe thing to do. | 159 // returning from this function is the only safe thing to do. |
| 161 } | 160 } |
| 162 | 161 |
| 163 void PermissionBubbleManager::ToggleAccept(int request_index, bool new_value) { | 162 void PermissionBubbleManager::ToggleAccept(int request_index, bool new_value) { |
| 164 DCHECK(request_index < static_cast<int>(accept_states_.size())); | 163 DCHECK(request_index < static_cast<int>(accept_states_.size())); |
| 165 accept_states_[request_index] = new_value; | 164 accept_states_[request_index] = new_value; |
| 166 } | 165 } |
| 167 | 166 |
| 168 void PermissionBubbleManager::SetCustomizationMode() { | 167 void PermissionBubbleManager::SetCustomizationMode() { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 238 } |
| 240 | 239 |
| 241 void PermissionBubbleManager::CancelPendingQueue() { | 240 void PermissionBubbleManager::CancelPendingQueue() { |
| 242 std::vector<PermissionBubbleRequest*>::iterator requests_iter; | 241 std::vector<PermissionBubbleRequest*>::iterator requests_iter; |
| 243 for (requests_iter = queued_requests_.begin(); | 242 for (requests_iter = queued_requests_.begin(); |
| 244 requests_iter != queued_requests_.end(); | 243 requests_iter != queued_requests_.end(); |
| 245 requests_iter++) { | 244 requests_iter++) { |
| 246 (*requests_iter)->RequestFinished(); | 245 (*requests_iter)->RequestFinished(); |
| 247 } | 246 } |
| 248 } | 247 } |
| OLD | NEW |