| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/content_settings/permission_queue_controller.h" | 5 #include "chrome/browser/content_settings/permission_queue_controller.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 10 #include "chrome/browser/geolocation/geolocation_infobar_delegate.h" | 10 #include "chrome/browser/geolocation/geolocation_infobar_delegate.h" |
| 11 #include "chrome/browser/infobars/infobar.h" | 11 #include "chrome/browser/infobars/infobar.h" |
| 12 #include "chrome/browser/infobars/infobar_manager.h" | |
| 13 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
| 14 #include "chrome/browser/media/midi_permission_infobar_delegate.h" | 13 #include "chrome/browser/media/midi_permission_infobar_delegate.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/tab_contents/tab_util.h" | 15 #include "chrome/browser/tab_contents/tab_util.h" |
| 17 #include "chrome/common/content_settings.h" | 16 #include "chrome/common/content_settings.h" |
| 18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
| 21 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 22 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 167 } |
| 169 | 168 |
| 170 void PermissionQueueController::CancelInfoBarRequest( | 169 void PermissionQueueController::CancelInfoBarRequest( |
| 171 const PermissionRequestID& id) { | 170 const PermissionRequestID& id) { |
| 172 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 171 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 173 | 172 |
| 174 for (PendingInfobarRequests::iterator i(pending_infobar_requests_.begin()); | 173 for (PendingInfobarRequests::iterator i(pending_infobar_requests_.begin()); |
| 175 i != pending_infobar_requests_.end(); ++i) { | 174 i != pending_infobar_requests_.end(); ++i) { |
| 176 if (i->id().Equals(id)) { | 175 if (i->id().Equals(id)) { |
| 177 if (i->has_infobar()) | 176 if (i->has_infobar()) |
| 178 GetInfoBarService(id)->infobar_manager()->RemoveInfoBar(i->infobar()); | 177 GetInfoBarService(id)->RemoveInfoBar(i->infobar()); |
| 179 else | 178 else |
| 180 pending_infobar_requests_.erase(i); | 179 pending_infobar_requests_.erase(i); |
| 181 return; | 180 return; |
| 182 } | 181 } |
| 183 } | 182 } |
| 184 } | 183 } |
| 185 | 184 |
| 186 void PermissionQueueController::CancelInfoBarRequests(int group_id) { | 185 void PermissionQueueController::CancelInfoBarRequests(int group_id) { |
| 187 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 186 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 188 | 187 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 202 i = pending_infobar_requests_.erase(i); | 201 i = pending_infobar_requests_.erase(i); |
| 203 } | 202 } |
| 204 } else { | 203 } else { |
| 205 ++i; | 204 ++i; |
| 206 } | 205 } |
| 207 } | 206 } |
| 208 | 207 |
| 209 for (PendingInfobarRequests::iterator i = infobar_requests_to_cancel.begin(); | 208 for (PendingInfobarRequests::iterator i = infobar_requests_to_cancel.begin(); |
| 210 i != infobar_requests_to_cancel.end(); | 209 i != infobar_requests_to_cancel.end(); |
| 211 ++i) { | 210 ++i) { |
| 212 GetInfoBarService(i->id())->infobar_manager()->RemoveInfoBar(i->infobar()); | 211 GetInfoBarService(i->id())->RemoveInfoBar(i->infobar()); |
| 213 } | 212 } |
| 214 } | 213 } |
| 215 | 214 |
| 216 void PermissionQueueController::OnPermissionSet( | 215 void PermissionQueueController::OnPermissionSet( |
| 217 const PermissionRequestID& id, | 216 const PermissionRequestID& id, |
| 218 const GURL& requesting_frame, | 217 const GURL& requesting_frame, |
| 219 const GURL& embedder, | 218 const GURL& embedder, |
| 220 bool update_content_setting, | 219 bool update_content_setting, |
| 221 bool allowed) { | 220 bool allowed) { |
| 222 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 221 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 248 i = pending_infobar_requests_.erase(i); | 247 i = pending_infobar_requests_.erase(i); |
| 249 } | 248 } |
| 250 } else { | 249 } else { |
| 251 ++i; | 250 ++i; |
| 252 } | 251 } |
| 253 } | 252 } |
| 254 | 253 |
| 255 // Remove all infobars for the same |requesting_frame| and |embedder|. | 254 // Remove all infobars for the same |requesting_frame| and |embedder|. |
| 256 for (PendingInfobarRequests::iterator i = infobars_to_remove.begin(); | 255 for (PendingInfobarRequests::iterator i = infobars_to_remove.begin(); |
| 257 i != infobars_to_remove.end(); ++i) | 256 i != infobars_to_remove.end(); ++i) |
| 258 GetInfoBarService(i->id())->infobar_manager()->RemoveInfoBar(i->infobar()); | 257 GetInfoBarService(i->id())->RemoveInfoBar(i->infobar()); |
| 259 | 258 |
| 260 // Send out the permission notifications. | 259 // Send out the permission notifications. |
| 261 for (PendingInfobarRequests::iterator i = requests_to_notify.begin(); | 260 for (PendingInfobarRequests::iterator i = requests_to_notify.begin(); |
| 262 i != requests_to_notify.end(); ++i) | 261 i != requests_to_notify.end(); ++i) |
| 263 i->RunCallback(allowed); | 262 i->RunCallback(allowed); |
| 264 } | 263 } |
| 265 | 264 |
| 266 void PermissionQueueController::Observe( | 265 void PermissionQueueController::Observe( |
| 267 int type, | 266 int type, |
| 268 const content::NotificationSource& source, | 267 const content::NotificationSource& source, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 379 |
| 381 ContentSetting content_setting = | 380 ContentSetting content_setting = |
| 382 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 381 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
| 383 profile_->GetHostContentSettingsMap()->SetContentSetting( | 382 profile_->GetHostContentSettingsMap()->SetContentSetting( |
| 384 ContentSettingsPattern::FromURLNoWildcard(requesting_frame.GetOrigin()), | 383 ContentSettingsPattern::FromURLNoWildcard(requesting_frame.GetOrigin()), |
| 385 ContentSettingsPattern::FromURLNoWildcard(embedder.GetOrigin()), | 384 ContentSettingsPattern::FromURLNoWildcard(embedder.GetOrigin()), |
| 386 type_, | 385 type_, |
| 387 std::string(), | 386 std::string(), |
| 388 content_setting); | 387 content_setting); |
| 389 } | 388 } |
| OLD | NEW |