Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: chrome/browser/media/media_stream_devices_controller.cc

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
Patch Set: Addressing nit. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
21 #include "components/content_settings/core/browser/host_content_settings_map.h" 20 #include "components/content_settings/core/browser/host_content_settings_map.h"
22 #include "components/content_settings/core/common/content_settings.h" 21 #include "components/content_settings/core/common/content_settings.h"
23 #include "components/content_settings/core/common/content_settings_pattern.h" 22 #include "components/content_settings/core/common/content_settings_pattern.h"
24 #include "components/pref_registry/pref_registry_syncable.h" 23 #include "components/pref_registry/pref_registry_syncable.h"
25 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
26 #include "content/public/browser/render_widget_host_view.h" 25 #include "content/public/browser/render_widget_host_view.h"
27 #include "content/public/common/media_stream_request.h" 26 #include "content/public/common/media_stream_request.h"
28 #include "extensions/common/constants.h" 27 #include "extensions/common/constants.h"
29 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
30 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 return false; 535 return false;
537 536
538 if (policy == POLICY_NOT_SET) { 537 if (policy == POLICY_NOT_SET) {
539 // Only load content settings from secure origins unless it is a 538 // Only load content settings from secure origins unless it is a
540 // content::MEDIA_OPEN_DEVICE (Pepper) request. 539 // content::MEDIA_OPEN_DEVICE (Pepper) request.
541 if (!IsSchemeSecure() && 540 if (!IsSchemeSecure() &&
542 request_.request_type != content::MEDIA_OPEN_DEVICE) { 541 request_.request_type != content::MEDIA_OPEN_DEVICE) {
543 return false; 542 return false;
544 } 543 }
545 if (profile_->GetHostContentSettingsMap()->GetContentSetting( 544 if (profile_->GetHostContentSettingsMap()->GetContentSetting(
546 request_.security_origin, request_.security_origin, 545 request_.security_origin,
547 device_checks[i].settings_type, NO_RESOURCE_IDENTIFIER) != 546 request_.security_origin,
548 CONTENT_SETTING_ALLOW) { 547 device_checks[i].settings_type,
548 content_settings::ResourceIdentifier()) !=
549 CONTENT_SETTING_ALLOW) {
549 return false; 550 return false;
550 } 551 }
551 } 552 }
552 // If we get here, then either policy is set to ALWAYS_ALLOW or the content 553 // If we get here, then either policy is set to ALWAYS_ALLOW or the content
553 // settings allow the request by default. 554 // settings allow the request by default.
554 } 555 }
555 556
556 return true; 557 return true;
557 } 558 }
558 559
559 int MediaStreamDevicesController::FilterBlockedByDefaultDevices() { 560 int MediaStreamDevicesController::FilterBlockedByDefaultDevices() {
560 int requested_devices = 0; 561 int requested_devices = 0;
561 562
562 if (IsDeviceAudioCaptureRequestedAndAllowed()) { 563 if (IsDeviceAudioCaptureRequestedAndAllowed()) {
563 if (profile_->GetHostContentSettingsMap()->GetContentSetting( 564 if (profile_->GetHostContentSettingsMap()->GetContentSetting(
564 request_.security_origin, 565 request_.security_origin,
565 request_.security_origin, 566 request_.security_origin,
566 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 567 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
567 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_BLOCK) { 568 content_settings::ResourceIdentifier()) ==
569 CONTENT_SETTING_BLOCK) {
568 request_permissions_[content::MEDIA_DEVICE_AUDIO_CAPTURE].permission = 570 request_permissions_[content::MEDIA_DEVICE_AUDIO_CAPTURE].permission =
569 MEDIA_BLOCKED_BY_USER_SETTING; 571 MEDIA_BLOCKED_BY_USER_SETTING;
570 } else { 572 } else {
571 ++requested_devices; 573 ++requested_devices;
572 } 574 }
573 } 575 }
574 576
575 if (IsDeviceVideoCaptureRequestedAndAllowed()) { 577 if (IsDeviceVideoCaptureRequestedAndAllowed()) {
576 if (profile_->GetHostContentSettingsMap()->GetContentSetting( 578 if (profile_->GetHostContentSettingsMap()->GetContentSetting(
577 request_.security_origin, 579 request_.security_origin,
578 request_.security_origin, 580 request_.security_origin,
579 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 581 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
580 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_BLOCK) { 582 content_settings::ResourceIdentifier()) ==
583 CONTENT_SETTING_BLOCK) {
581 request_permissions_[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission = 584 request_permissions_[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission =
582 MEDIA_BLOCKED_BY_USER_SETTING; 585 MEDIA_BLOCKED_BY_USER_SETTING;
583 } else { 586 } else {
584 ++requested_devices; 587 ++requested_devices;
585 } 588 }
586 } 589 }
587 590
588 return requested_devices; 591 return requested_devices;
589 } 592 }
590 593
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 683 }
681 684
682 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { 685 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const {
683 #if defined(OS_ANDROID) 686 #if defined(OS_ANDROID)
684 // Don't approve device requests if the tab was hidden. 687 // Don't approve device requests if the tab was hidden.
685 // TODO(qinmin): Add a test for this. http://crbug.com/396869. 688 // TODO(qinmin): Add a test for this. http://crbug.com/396869.
686 return web_contents_->GetRenderWidgetHostView()->IsShowing(); 689 return web_contents_->GetRenderWidgetHostView()->IsShowing();
687 #endif 690 #endif
688 return true; 691 return true;
689 } 692 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698