OLD | NEW |
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 prefs->SetBoolean(policy_name, access == ACCESS_ALLOWED); | 93 prefs->SetBoolean(policy_name, access == ACCESS_ALLOWED); |
94 } | 94 } |
95 | 95 |
96 // Set the content settings for mic/cam. | 96 // Set the content settings for mic/cam. |
97 void SetContentSettings(ContentSetting mic_setting, | 97 void SetContentSettings(ContentSetting mic_setting, |
98 ContentSetting cam_setting) { | 98 ContentSetting cam_setting) { |
99 HostContentSettingsMap* content_settings = | 99 HostContentSettingsMap* content_settings = |
100 HostContentSettingsMapFactory::GetForProfile( | 100 HostContentSettingsMapFactory::GetForProfile( |
101 Profile::FromBrowserContext(GetWebContents()->GetBrowserContext())); | 101 Profile::FromBrowserContext(GetWebContents()->GetBrowserContext())); |
102 ContentSettingsPattern pattern = | 102 content_settings->SetContentSettingDefaultScope( |
103 ContentSettingsPattern::FromURLNoWildcard(example_url_); | 103 example_url_, GURL(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
104 content_settings->SetContentSetting(pattern, pattern, | 104 std::string(), mic_setting); |
105 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 105 content_settings->SetContentSettingDefaultScope( |
106 std::string(), mic_setting); | 106 example_url_, GURL(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
107 content_settings->SetContentSetting( | |
108 pattern, pattern, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | |
109 std::string(), cam_setting); | 107 std::string(), cam_setting); |
110 } | 108 } |
111 | 109 |
112 // Checks whether the devices returned in OnMediaStreamResponse contains a | 110 // Checks whether the devices returned in OnMediaStreamResponse contains a |
113 // microphone and/or camera device. | 111 // microphone and/or camera device. |
114 bool DevicesContains(bool needs_mic, bool needs_cam) { | 112 bool DevicesContains(bool needs_mic, bool needs_cam) { |
115 bool has_mic = false; | 113 bool has_mic = false; |
116 bool has_cam = false; | 114 bool has_cam = false; |
117 for (const auto& device : media_stream_devices_) { | 115 for (const auto& device : media_stream_devices_) { |
118 if (device.type == content::MEDIA_DEVICE_AUDIO_CAPTURE) | 116 if (device.type == content::MEDIA_DEVICE_AUDIO_CAPTURE) |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 MediaStreamDevicesController controller( | 740 MediaStreamDevicesController controller( |
743 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 741 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
744 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 742 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
745 this)); | 743 this)); |
746 | 744 |
747 EXPECT_FALSE(controller.IsAllowedForAudio()); | 745 EXPECT_FALSE(controller.IsAllowedForAudio()); |
748 EXPECT_FALSE(controller.IsAllowedForVideo()); | 746 EXPECT_FALSE(controller.IsAllowedForVideo()); |
749 EXPECT_FALSE(controller.IsAskingForAudio()); | 747 EXPECT_FALSE(controller.IsAskingForAudio()); |
750 EXPECT_FALSE(controller.IsAskingForVideo()); | 748 EXPECT_FALSE(controller.IsAskingForVideo()); |
751 } | 749 } |
OLD | NEW |