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

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

Issue 1828803003: Media permissions: Remove plumbing for insecure pepper requests in Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and fix tests Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.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/content_settings/tab_specific_content_settings.h" 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 MediaStreamDevicesController controller( 696 MediaStreamDevicesController controller(
697 GetWebContents(), 697 GetWebContents(),
698 CreateRequestWithType(example_audio_id(), std::string(), 698 CreateRequestWithType(example_audio_id(), std::string(),
699 content::MEDIA_OPEN_DEVICE_PEPPER_ONLY), 699 content::MEDIA_OPEN_DEVICE_PEPPER_ONLY),
700 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, 700 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse,
701 this)); 701 this));
702 ASSERT_FALSE(controller.IsAskingForAudio()); 702 ASSERT_FALSE(controller.IsAskingForAudio());
703 ASSERT_FALSE(controller.IsAskingForVideo()); 703 ASSERT_FALSE(controller.IsAskingForVideo());
704 } 704 }
705 705
706 // For non-Pepper request from insecure origin, if it's ALLOW, it will be
707 // changed to ASK.
708 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest,
709 NonPepperRequestInsecure) {
710 InitWithUrl(GURL("http://www.example.com"));
711 SetContentSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW);
712
713 MediaStreamDevicesController controller(
714 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()),
715 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse,
716 this));
717 ASSERT_TRUE(controller.IsAskingForAudio());
718 ASSERT_TRUE(controller.IsAskingForVideo());
719 }
720
721 // Request and block microphone and camera access with kill switch. 706 // Request and block microphone and camera access with kill switch.
722 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, 707 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest,
723 RequestAndKillSwitchMicCam) { 708 RequestAndKillSwitchMicCam) {
724 std::map<std::string, std::string> params; 709 std::map<std::string, std::string> params;
725 params[PermissionUtil::GetPermissionString( 710 params[PermissionUtil::GetPermissionString(
726 content::PermissionType::AUDIO_CAPTURE)] = 711 content::PermissionType::AUDIO_CAPTURE)] =
727 PermissionContextBase::kPermissionsKillSwitchBlockedValue; 712 PermissionContextBase::kPermissionsKillSwitchBlockedValue;
728 params[PermissionUtil::GetPermissionString( 713 params[PermissionUtil::GetPermissionString(
729 content::PermissionType::VIDEO_CAPTURE)] = 714 content::PermissionType::VIDEO_CAPTURE)] =
730 PermissionContextBase::kPermissionsKillSwitchBlockedValue; 715 PermissionContextBase::kPermissionsKillSwitchBlockedValue;
731 variations::AssociateVariationParams( 716 variations::AssociateVariationParams(
732 PermissionContextBase::kPermissionsKillSwitchFieldStudy, 717 PermissionContextBase::kPermissionsKillSwitchFieldStudy,
733 "TestGroup", params); 718 "TestGroup", params);
734 base::FieldTrialList::CreateFieldTrial( 719 base::FieldTrialList::CreateFieldTrial(
735 PermissionContextBase::kPermissionsKillSwitchFieldStudy, 720 PermissionContextBase::kPermissionsKillSwitchFieldStudy,
736 "TestGroup"); 721 "TestGroup");
737 InitWithUrl(GURL("https://www.example.com")); 722 InitWithUrl(GURL("https://www.example.com"));
738 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); 723 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED);
739 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); 724 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED);
740 MediaStreamDevicesController controller( 725 MediaStreamDevicesController controller(
741 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), 726 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()),
742 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, 727 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse,
743 this)); 728 this));
744 729
745 EXPECT_FALSE(controller.IsAllowedForAudio()); 730 EXPECT_FALSE(controller.IsAllowedForAudio());
746 EXPECT_FALSE(controller.IsAllowedForVideo()); 731 EXPECT_FALSE(controller.IsAllowedForVideo());
747 EXPECT_FALSE(controller.IsAskingForAudio()); 732 EXPECT_FALSE(controller.IsAskingForAudio());
748 EXPECT_FALSE(controller.IsAskingForVideo()); 733 EXPECT_FALSE(controller.IsAskingForVideo());
749 } 734 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698