| 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/permissions/permission_queue_controller.h" | 5 #include "chrome/browser/permissions/permission_queue_controller.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.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_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 218 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 219 | 219 |
| 220 PermissionRequestType request_type = | 220 PermissionRequestType request_type = |
| 221 PermissionUtil::GetRequestType(content_settings_type_); | 221 PermissionUtil::GetRequestType(content_settings_type_); |
| 222 PermissionRequestGestureType gesture_type = | 222 PermissionRequestGestureType gesture_type = |
| 223 PermissionUtil::GetGestureType(user_gesture); | 223 PermissionUtil::GetGestureType(user_gesture); |
| 224 PermissionEmbargoStatus embargo_status = | 224 PermissionEmbargoStatus embargo_status = |
| 225 PermissionEmbargoStatus::NOT_EMBARGOED; | 225 PermissionEmbargoStatus::NOT_EMBARGOED; |
| 226 | 226 |
| 227 switch (decision) { | 227 switch (decision) { |
| 228 case GRANTED: | 228 case PermissionAction::GRANTED: |
| 229 PermissionUmaUtil::PermissionGranted(content_settings_type_, gesture_type, | 229 PermissionUmaUtil::PermissionGranted(content_settings_type_, gesture_type, |
| 230 requesting_frame, profile_); | 230 requesting_frame, profile_); |
| 231 PermissionUmaUtil::RecordPermissionPromptAccepted(request_type, | 231 PermissionUmaUtil::RecordPermissionPromptAccepted(request_type, |
| 232 gesture_type); | 232 gesture_type); |
| 233 break; | 233 break; |
| 234 case DENIED: | 234 case PermissionAction::DENIED: |
| 235 PermissionUmaUtil::PermissionDenied(content_settings_type_, gesture_type, | 235 PermissionUmaUtil::PermissionDenied(content_settings_type_, gesture_type, |
| 236 requesting_frame, profile_); | 236 requesting_frame, profile_); |
| 237 PermissionUmaUtil::RecordPermissionPromptDenied(request_type, | 237 PermissionUmaUtil::RecordPermissionPromptDenied(request_type, |
| 238 gesture_type); | 238 gesture_type); |
| 239 break; | 239 break; |
| 240 case DISMISSED: | 240 case PermissionAction::DISMISSED: |
| 241 PermissionUmaUtil::PermissionDismissed( | 241 PermissionUmaUtil::PermissionDismissed( |
| 242 content_settings_type_, gesture_type, requesting_frame, profile_); | 242 content_settings_type_, gesture_type, requesting_frame, profile_); |
| 243 if (PermissionDecisionAutoBlocker::GetForProfile(profile_) | 243 if (PermissionDecisionAutoBlocker::GetForProfile(profile_) |
| 244 ->RecordDismissAndEmbargo(requesting_frame, | 244 ->RecordDismissAndEmbargo(requesting_frame, |
| 245 content_settings_type_)) { | 245 content_settings_type_)) { |
| 246 embargo_status = PermissionEmbargoStatus::REPEATED_DISMISSALS; | 246 embargo_status = PermissionEmbargoStatus::REPEATED_DISMISSALS; |
| 247 } | 247 } |
| 248 break; | 248 break; |
| 249 default: | 249 default: |
| 250 NOTREACHED(); | 250 NOTREACHED(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 for (PendingInfobarRequests::iterator i = infobars_to_remove.begin(); | 289 for (PendingInfobarRequests::iterator i = infobars_to_remove.begin(); |
| 290 i != infobars_to_remove.end(); ++i) | 290 i != infobars_to_remove.end(); ++i) |
| 291 GetInfoBarService(i->id())->RemoveInfoBar(i->infobar()); | 291 GetInfoBarService(i->id())->RemoveInfoBar(i->infobar()); |
| 292 | 292 |
| 293 // PermissionContextBase needs to know about the new ContentSetting value, | 293 // PermissionContextBase needs to know about the new ContentSetting value, |
| 294 // CONTENT_SETTING_DEFAULT being the value for nothing happened. The callers | 294 // CONTENT_SETTING_DEFAULT being the value for nothing happened. The callers |
| 295 // of ::OnPermissionSet passes { bool, GRANTED } for allow, { bool, DENIED } | 295 // of ::OnPermissionSet passes { bool, GRANTED } for allow, { bool, DENIED } |
| 296 // for block and { false, DISMISSED } for dismissed. The tuple being | 296 // for block and { false, DISMISSED } for dismissed. The tuple being |
| 297 // { update_content_setting, decision }. | 297 // { update_content_setting, decision }. |
| 298 ContentSetting content_setting = CONTENT_SETTING_DEFAULT; | 298 ContentSetting content_setting = CONTENT_SETTING_DEFAULT; |
| 299 if (decision == GRANTED) | 299 if (decision == PermissionAction::GRANTED) |
| 300 content_setting = CONTENT_SETTING_ALLOW; | 300 content_setting = CONTENT_SETTING_ALLOW; |
| 301 else if (decision == DENIED) | 301 else if (decision == PermissionAction::DENIED) |
| 302 content_setting = CONTENT_SETTING_BLOCK; | 302 content_setting = CONTENT_SETTING_BLOCK; |
| 303 else | 303 else |
| 304 DCHECK_EQ(DISMISSED, decision); | 304 DCHECK_EQ(PermissionAction::DISMISSED, decision); |
| 305 | 305 |
| 306 // Send out the permission notifications. | 306 // Send out the permission notifications. |
| 307 for (PendingInfobarRequests::iterator i = requests_to_notify.begin(); | 307 for (PendingInfobarRequests::iterator i = requests_to_notify.begin(); |
| 308 i != requests_to_notify.end(); ++i) { | 308 i != requests_to_notify.end(); ++i) { |
| 309 i->RunCallback(content_setting); | 309 i->RunCallback(content_setting); |
| 310 } | 310 } |
| 311 | 311 |
| 312 // Remove the pending requests in reverse order. | 312 // Remove the pending requests in reverse order. |
| 313 for (int i = pending_requests_to_remove.size() - 1; i >= 0; --i) | 313 for (int i = pending_requests_to_remove.size() - 1; i >= 0; --i) |
| 314 pending_infobar_requests_.erase(pending_requests_to_remove[i]); | 314 pending_infobar_requests_.erase(pending_requests_to_remove[i]); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 registrar_.Remove(this, | 425 registrar_.Remove(this, |
| 426 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 426 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
| 427 content::Source<InfoBarService>(infobar_service)); | 427 content::Source<InfoBarService>(infobar_service)); |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 | 430 |
| 431 void PermissionQueueController::UpdateContentSetting( | 431 void PermissionQueueController::UpdateContentSetting( |
| 432 const GURL& requesting_frame, | 432 const GURL& requesting_frame, |
| 433 const GURL& embedder, | 433 const GURL& embedder, |
| 434 PermissionAction decision) { | 434 PermissionAction decision) { |
| 435 DCHECK(decision == GRANTED || decision == DENIED); | 435 DCHECK(decision == PermissionAction::GRANTED || |
| 436 decision == PermissionAction::DENIED); |
| 436 if (requesting_frame.GetOrigin().SchemeIsFile()) { | 437 if (requesting_frame.GetOrigin().SchemeIsFile()) { |
| 437 // Chrome can be launched with --disable-web-security which allows | 438 // Chrome can be launched with --disable-web-security which allows |
| 438 // geolocation requests from file:// URLs. We don't want to store these | 439 // geolocation requests from file:// URLs. We don't want to store these |
| 439 // in the host content settings map. | 440 // in the host content settings map. |
| 440 return; | 441 return; |
| 441 } | 442 } |
| 442 | 443 |
| 443 ContentSetting content_setting = | 444 ContentSetting content_setting = (decision == PermissionAction::GRANTED) |
| 444 (decision == GRANTED) ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 445 ? CONTENT_SETTING_ALLOW |
| 446 : CONTENT_SETTING_BLOCK; |
| 445 | 447 |
| 446 // TODO(timloh): Remove this logic when push and notification permissions | 448 // TODO(timloh): Remove this logic when push and notification permissions |
| 447 // are reconciled, see crbug.com/563297. | 449 // are reconciled, see crbug.com/563297. |
| 448 ContentSettingsType type_for_map = content_settings_type_; | 450 ContentSettingsType type_for_map = content_settings_type_; |
| 449 if (type_for_map == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING) | 451 if (type_for_map == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING) |
| 450 type_for_map = CONTENT_SETTINGS_TYPE_NOTIFICATIONS; | 452 type_for_map = CONTENT_SETTINGS_TYPE_NOTIFICATIONS; |
| 451 HostContentSettingsMapFactory::GetForProfile(profile_) | 453 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 452 ->SetContentSettingDefaultScope( | 454 ->SetContentSettingDefaultScope( |
| 453 requesting_frame.GetOrigin(), embedder.GetOrigin(), | 455 requesting_frame.GetOrigin(), embedder.GetOrigin(), |
| 454 type_for_map, std::string(), content_setting); | 456 type_for_map, std::string(), content_setting); |
| 455 } | 457 } |
| OLD | NEW |