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