 Chromium Code Reviews
 Chromium Code Reviews Issue 1034143002:
  Content settings clean-up: Clarify resource identifier & get rid of NO_RESOURCE_IDENTIFIER.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1034143002:
  Content settings clean-up: Clarify resource identifier & get rid of NO_RESOURCE_IDENTIFIER.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media/media_stream_devices_controller.h" | 5 #include "chrome/browser/media/media_stream_devices_controller.h" | 
| 6 | 6 | 
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" | 
| 8 #include "base/prefs/scoped_user_pref_update.h" | 8 #include "base/prefs/scoped_user_pref_update.h" | 
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" | 
| 10 #include "base/values.h" | 10 #include "base/values.h" | 
| 11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 
| 12 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 12 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 
| 13 #include "chrome/browser/media/media_stream_capture_indicator.h" | 13 #include "chrome/browser/media/media_stream_capture_indicator.h" | 
| 14 #include "chrome/browser/media/media_stream_device_permissions.h" | 14 #include "chrome/browser/media/media_stream_device_permissions.h" | 
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" | 
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" | 
| 17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" | 
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" | 
| 19 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" | 
| 20 #include "components/content_settings/core/browser/content_settings_provider.h" | 20 #include "components/content_settings/core/browser/content_settings_provider.h" | 
| 
msramek
2015/04/07 12:01:40
Remove this inclusion?
 
Deepak
2015/04/07 13:08:14
On 2015/04/07 12:01:40, msramek wrote:
Done.
 | |
| 21 #include "components/content_settings/core/browser/host_content_settings_map.h" | 21 #include "components/content_settings/core/browser/host_content_settings_map.h" | 
| 22 #include "components/content_settings/core/common/content_settings.h" | 22 #include "components/content_settings/core/common/content_settings.h" | 
| 23 #include "components/content_settings/core/common/content_settings_pattern.h" | 23 #include "components/content_settings/core/common/content_settings_pattern.h" | 
| 24 #include "components/pref_registry/pref_registry_syncable.h" | 24 #include "components/pref_registry/pref_registry_syncable.h" | 
| 25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" | 
| 26 #include "content/public/browser/render_widget_host_view.h" | 26 #include "content/public/browser/render_widget_host_view.h" | 
| 27 #include "content/public/common/media_stream_request.h" | 27 #include "content/public/common/media_stream_request.h" | 
| 28 #include "extensions/common/constants.h" | 28 #include "extensions/common/constants.h" | 
| 29 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" | 
| 30 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" | 
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 return false; | 536 return false; | 
| 537 | 537 | 
| 538 if (policy == POLICY_NOT_SET) { | 538 if (policy == POLICY_NOT_SET) { | 
| 539 // Only load content settings from secure origins unless it is a | 539 // Only load content settings from secure origins unless it is a | 
| 540 // content::MEDIA_OPEN_DEVICE (Pepper) request. | 540 // content::MEDIA_OPEN_DEVICE (Pepper) request. | 
| 541 if (!IsSchemeSecure() && | 541 if (!IsSchemeSecure() && | 
| 542 request_.request_type != content::MEDIA_OPEN_DEVICE) { | 542 request_.request_type != content::MEDIA_OPEN_DEVICE) { | 
| 543 return false; | 543 return false; | 
| 544 } | 544 } | 
| 545 if (profile_->GetHostContentSettingsMap()->GetContentSetting( | 545 if (profile_->GetHostContentSettingsMap()->GetContentSetting( | 
| 546 request_.security_origin, request_.security_origin, | 546 request_.security_origin, | 
| 547 device_checks[i].settings_type, NO_RESOURCE_IDENTIFIER) != | 547 request_.security_origin, | 
| 548 CONTENT_SETTING_ALLOW) { | 548 device_checks[i].settings_type, | 
| 549 content_settings::ResourceIdentifier()) != | |
| 550 CONTENT_SETTING_ALLOW) { | |
| 549 return false; | 551 return false; | 
| 550 } | 552 } | 
| 551 } | 553 } | 
| 552 // If we get here, then either policy is set to ALWAYS_ALLOW or the content | 554 // If we get here, then either policy is set to ALWAYS_ALLOW or the content | 
| 553 // settings allow the request by default. | 555 // settings allow the request by default. | 
| 554 } | 556 } | 
| 555 | 557 | 
| 556 return true; | 558 return true; | 
| 557 } | 559 } | 
| 558 | 560 | 
| 559 int MediaStreamDevicesController::FilterBlockedByDefaultDevices() { | 561 int MediaStreamDevicesController::FilterBlockedByDefaultDevices() { | 
| 560 int requested_devices = 0; | 562 int requested_devices = 0; | 
| 561 | 563 | 
| 562 if (IsDeviceAudioCaptureRequestedAndAllowed()) { | 564 if (IsDeviceAudioCaptureRequestedAndAllowed()) { | 
| 563 if (profile_->GetHostContentSettingsMap()->GetContentSetting( | 565 if (profile_->GetHostContentSettingsMap()->GetContentSetting( | 
| 564 request_.security_origin, | 566 request_.security_origin, | 
| 565 request_.security_origin, | 567 request_.security_origin, | 
| 566 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 568 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 
| 567 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_BLOCK) { | 569 content_settings::ResourceIdentifier()) == | 
| 570 CONTENT_SETTING_BLOCK) { | |
| 568 request_permissions_[content::MEDIA_DEVICE_AUDIO_CAPTURE].permission = | 571 request_permissions_[content::MEDIA_DEVICE_AUDIO_CAPTURE].permission = | 
| 569 MEDIA_BLOCKED_BY_USER_SETTING; | 572 MEDIA_BLOCKED_BY_USER_SETTING; | 
| 570 } else { | 573 } else { | 
| 571 ++requested_devices; | 574 ++requested_devices; | 
| 572 } | 575 } | 
| 573 } | 576 } | 
| 574 | 577 | 
| 575 if (IsDeviceVideoCaptureRequestedAndAllowed()) { | 578 if (IsDeviceVideoCaptureRequestedAndAllowed()) { | 
| 576 if (profile_->GetHostContentSettingsMap()->GetContentSetting( | 579 if (profile_->GetHostContentSettingsMap()->GetContentSetting( | 
| 577 request_.security_origin, | 580 request_.security_origin, | 
| 578 request_.security_origin, | 581 request_.security_origin, | 
| 579 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 582 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 
| 580 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_BLOCK) { | 583 content_settings::ResourceIdentifier()) == | 
| 584 CONTENT_SETTING_BLOCK) { | |
| 581 request_permissions_[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission = | 585 request_permissions_[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission = | 
| 582 MEDIA_BLOCKED_BY_USER_SETTING; | 586 MEDIA_BLOCKED_BY_USER_SETTING; | 
| 583 } else { | 587 } else { | 
| 584 ++requested_devices; | 588 ++requested_devices; | 
| 585 } | 589 } | 
| 586 } | 590 } | 
| 587 | 591 | 
| 588 return requested_devices; | 592 return requested_devices; | 
| 589 } | 593 } | 
| 590 | 594 | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 680 } | 684 } | 
| 681 | 685 | 
| 682 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { | 686 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { | 
| 683 #if defined(OS_ANDROID) | 687 #if defined(OS_ANDROID) | 
| 684 // Don't approve device requests if the tab was hidden. | 688 // Don't approve device requests if the tab was hidden. | 
| 685 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 689 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 
| 686 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 690 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 
| 687 #endif | 691 #endif | 
| 688 return true; | 692 return true; | 
| 689 } | 693 } | 
| OLD | NEW |