| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/webrtc/media_stream_device_permission_context.h" | 5 #include "chrome/browser/media/webrtc/media_stream_device_permission_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 insecure_url.GetOrigin(), | 67 insecure_url.GetOrigin(), |
| 68 permission_type, | 68 permission_type, |
| 69 std::string())); | 69 std::string())); |
| 70 EXPECT_EQ(CONTENT_SETTING_ASK, | 70 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 71 HostContentSettingsMapFactory::GetForProfile(profile()) | 71 HostContentSettingsMapFactory::GetForProfile(profile()) |
| 72 ->GetContentSetting(insecure_url.GetOrigin(), | 72 ->GetContentSetting(insecure_url.GetOrigin(), |
| 73 secure_url.GetOrigin(), | 73 secure_url.GetOrigin(), |
| 74 permission_type, | 74 permission_type, |
| 75 std::string())); | 75 std::string())); |
| 76 | 76 |
| 77 EXPECT_EQ(CONTENT_SETTING_ASK, permission_context.GetPermissionStatus( | 77 PermissionResult result = |
| 78 insecure_url, insecure_url)); | 78 permission_context.GetPermissionStatus(insecure_url, insecure_url); |
| 79 EXPECT_EQ(CONTENT_SETTING_ASK, | 79 EXPECT_EQ(CONTENT_SETTING_ASK, result.content_setting); |
| 80 permission_context.GetPermissionStatus(insecure_url, secure_url)); | 80 EXPECT_EQ(PermissionStatusSource::UNSPECIFIED, result.source); |
| 81 |
| 82 result = permission_context.GetPermissionStatus(insecure_url, secure_url); |
| 83 EXPECT_EQ(CONTENT_SETTING_ASK, result.content_setting); |
| 84 EXPECT_EQ(PermissionStatusSource::UNSPECIFIED, result.source); |
| 81 } | 85 } |
| 82 | 86 |
| 83 void TestSecureQueryingUrl(ContentSettingsType permission_type) { | 87 void TestSecureQueryingUrl(ContentSettingsType permission_type) { |
| 84 TestPermissionContext permission_context(profile(), permission_type); | 88 TestPermissionContext permission_context(profile(), permission_type); |
| 85 GURL secure_url("https://www.example.com"); | 89 GURL secure_url("https://www.example.com"); |
| 86 | 90 |
| 87 // Check that there is no saved content settings. | 91 // Check that there is no saved content settings. |
| 88 EXPECT_EQ(CONTENT_SETTING_ASK, | 92 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 89 HostContentSettingsMapFactory::GetForProfile(profile()) | 93 HostContentSettingsMapFactory::GetForProfile(profile()) |
| 90 ->GetContentSetting(secure_url.GetOrigin(), | 94 ->GetContentSetting(secure_url.GetOrigin(), |
| 91 secure_url.GetOrigin(), | 95 secure_url.GetOrigin(), |
| 92 permission_type, | 96 permission_type, |
| 93 std::string())); | 97 std::string())); |
| 94 | 98 |
| 95 EXPECT_EQ(CONTENT_SETTING_ASK, | 99 PermissionResult result = |
| 96 permission_context.GetPermissionStatus(secure_url, secure_url)); | 100 permission_context.GetPermissionStatus(secure_url, secure_url); |
| 101 EXPECT_EQ(CONTENT_SETTING_ASK, result.content_setting); |
| 102 EXPECT_EQ(PermissionStatusSource::UNSPECIFIED, result.source); |
| 97 } | 103 } |
| 98 | 104 |
| 99 private: | 105 private: |
| 100 // ChromeRenderViewHostTestHarness: | 106 // ChromeRenderViewHostTestHarness: |
| 101 void SetUp() override { | 107 void SetUp() override { |
| 102 ChromeRenderViewHostTestHarness::SetUp(); | 108 ChromeRenderViewHostTestHarness::SetUp(); |
| 103 #if defined(OS_ANDROID) | 109 #if defined(OS_ANDROID) |
| 104 InfoBarService::CreateForWebContents(web_contents()); | 110 InfoBarService::CreateForWebContents(web_contents()); |
| 105 #else | 111 #else |
| 106 PermissionRequestManager::CreateForWebContents(web_contents()); | 112 PermissionRequestManager::CreateForWebContents(web_contents()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 124 | 130 |
| 125 // MEDIASTREAM_MIC permission status should be ask for Secure origin. | 131 // MEDIASTREAM_MIC permission status should be ask for Secure origin. |
| 126 TEST_F(MediaStreamDevicePermissionContextTests, TestMicSecureQueryingUrl) { | 132 TEST_F(MediaStreamDevicePermissionContextTests, TestMicSecureQueryingUrl) { |
| 127 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 133 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 128 } | 134 } |
| 129 | 135 |
| 130 // MEDIASTREAM_CAMERA permission status should be ask for Secure origin. | 136 // MEDIASTREAM_CAMERA permission status should be ask for Secure origin. |
| 131 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraSecureQueryingUrl) { | 137 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraSecureQueryingUrl) { |
| 132 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 138 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 133 } | 139 } |
| OLD | NEW |