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

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: Created 5 years, 9 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"
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 if (policy == POLICY_NOT_SET) { 534 if (policy == POLICY_NOT_SET) {
535 // Only load content settings from secure origins unless it is a 535 // Only load content settings from secure origins unless it is a
536 // content::MEDIA_OPEN_DEVICE (Pepper) request. 536 // content::MEDIA_OPEN_DEVICE (Pepper) request.
537 if (!IsSchemeSecure() && 537 if (!IsSchemeSecure() &&
538 request_.request_type != content::MEDIA_OPEN_DEVICE) { 538 request_.request_type != content::MEDIA_OPEN_DEVICE) {
539 return false; 539 return false;
540 } 540 }
541 if (profile_->GetHostContentSettingsMap()->GetContentSetting( 541 if (profile_->GetHostContentSettingsMap()->GetContentSetting(
542 request_.security_origin, request_.security_origin, 542 request_.security_origin, request_.security_origin,
543 device_checks[i].settings_type, NO_RESOURCE_IDENTIFIER) != 543 device_checks[i].settings_type,
544 CONTENT_SETTING_ALLOW) { 544 NoResourceIdentifier::GetResourceIdentifier()) !=
545 CONTENT_SETTING_ALLOW) {
545 return false; 546 return false;
546 } 547 }
547 } 548 }
548 // If we get here, then either policy is set to ALWAYS_ALLOW or the content 549 // If we get here, then either policy is set to ALWAYS_ALLOW or the content
549 // settings allow the request by default. 550 // settings allow the request by default.
550 } 551 }
551 552
552 return true; 553 return true;
553 } 554 }
554 555
555 int MediaStreamDevicesController::FilterBlockedByDefaultDevices() { 556 int MediaStreamDevicesController::FilterBlockedByDefaultDevices() {
556 int requested_devices = 0; 557 int requested_devices = 0;
557 558
558 if (IsDeviceAudioCaptureRequestedAndAllowed()) { 559 if (IsDeviceAudioCaptureRequestedAndAllowed()) {
559 if (profile_->GetHostContentSettingsMap()->GetContentSetting( 560 if (profile_->GetHostContentSettingsMap()->GetContentSetting(
560 request_.security_origin, 561 request_.security_origin, request_.security_origin,
561 request_.security_origin, 562 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
562 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 563 NoResourceIdentifier::GetResourceIdentifier()) ==
563 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_BLOCK) { 564 CONTENT_SETTING_BLOCK) {
564 request_permissions_[content::MEDIA_DEVICE_AUDIO_CAPTURE].permission = 565 request_permissions_[content::MEDIA_DEVICE_AUDIO_CAPTURE].permission =
565 MEDIA_BLOCKED_BY_USER_SETTING; 566 MEDIA_BLOCKED_BY_USER_SETTING;
566 } else { 567 } else {
567 ++requested_devices; 568 ++requested_devices;
568 } 569 }
569 } 570 }
570 571
571 if (IsDeviceVideoCaptureRequestedAndAllowed()) { 572 if (IsDeviceVideoCaptureRequestedAndAllowed()) {
572 if (profile_->GetHostContentSettingsMap()->GetContentSetting( 573 if (profile_->GetHostContentSettingsMap()->GetContentSetting(
573 request_.security_origin, 574 request_.security_origin, request_.security_origin,
574 request_.security_origin, 575 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
575 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 576 NoResourceIdentifier::GetResourceIdentifier()) ==
576 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_BLOCK) { 577 CONTENT_SETTING_BLOCK) {
577 request_permissions_[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission = 578 request_permissions_[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission =
578 MEDIA_BLOCKED_BY_USER_SETTING; 579 MEDIA_BLOCKED_BY_USER_SETTING;
579 } else { 580 } else {
580 ++requested_devices; 581 ++requested_devices;
581 } 582 }
582 } 583 }
583 584
584 return requested_devices; 585 return requested_devices;
585 } 586 }
586 587
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 } 678 }
678 679
679 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { 680 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const {
680 #if defined(OS_ANDROID) 681 #if defined(OS_ANDROID)
681 // Don't approve device requests if the tab was hidden. 682 // Don't approve device requests if the tab was hidden.
682 // TODO(qinmin): Add a test for this. http://crbug.com/396869. 683 // TODO(qinmin): Add a test for this. http://crbug.com/396869.
683 return web_contents_->GetRenderWidgetHostView()->IsShowing(); 684 return web_contents_->GetRenderWidgetHostView()->IsShowing();
684 #endif 685 #endif
685 return true; 686 return true;
686 } 687 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698