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

Side by Side Diff: chrome/browser/media/webrtc/media_stream_device_permission_context_unittest.cc

Issue 2686463002: Add a source to the result of PermissionContextBase::GetPermissionStatus (Closed)
Patch Set: Add a source to the result of PermissionContextBase::GetPermissionStatus Created 3 years, 10 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 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
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(
78 insecure_url, insecure_url));
79 EXPECT_EQ(CONTENT_SETTING_ASK, 77 EXPECT_EQ(CONTENT_SETTING_ASK,
80 permission_context.GetPermissionStatus(insecure_url, secure_url)); 78 permission_context.GetPermissionStatus(insecure_url, insecure_url)
79 .content_setting);
80
81 EXPECT_EQ(CONTENT_SETTING_ASK,
82 permission_context.GetPermissionStatus(insecure_url, secure_url)
83 .content_setting);
81 } 84 }
82 85
83 void TestSecureQueryingUrl(ContentSettingsType permission_type) { 86 void TestSecureQueryingUrl(ContentSettingsType permission_type) {
84 TestPermissionContext permission_context(profile(), permission_type); 87 TestPermissionContext permission_context(profile(), permission_type);
85 GURL secure_url("https://www.example.com"); 88 GURL secure_url("https://www.example.com");
86 89
87 // Check that there is no saved content settings. 90 // Check that there is no saved content settings.
88 EXPECT_EQ(CONTENT_SETTING_ASK, 91 EXPECT_EQ(CONTENT_SETTING_ASK,
89 HostContentSettingsMapFactory::GetForProfile(profile()) 92 HostContentSettingsMapFactory::GetForProfile(profile())
90 ->GetContentSetting(secure_url.GetOrigin(), 93 ->GetContentSetting(secure_url.GetOrigin(),
91 secure_url.GetOrigin(), 94 secure_url.GetOrigin(),
92 permission_type, 95 permission_type,
93 std::string())); 96 std::string()));
94 97
95 EXPECT_EQ(CONTENT_SETTING_ASK, 98 EXPECT_EQ(CONTENT_SETTING_ASK,
96 permission_context.GetPermissionStatus(secure_url, secure_url)); 99 permission_context.GetPermissionStatus(secure_url, secure_url)
100 .content_setting);
97 } 101 }
98 102
99 private: 103 private:
100 // ChromeRenderViewHostTestHarness: 104 // ChromeRenderViewHostTestHarness:
101 void SetUp() override { 105 void SetUp() override {
102 ChromeRenderViewHostTestHarness::SetUp(); 106 ChromeRenderViewHostTestHarness::SetUp();
103 #if defined(OS_ANDROID) 107 #if defined(OS_ANDROID)
104 InfoBarService::CreateForWebContents(web_contents()); 108 InfoBarService::CreateForWebContents(web_contents());
105 #else 109 #else
106 PermissionRequestManager::CreateForWebContents(web_contents()); 110 PermissionRequestManager::CreateForWebContents(web_contents());
(...skipping 17 matching lines...) Expand all
124 128
125 // MEDIASTREAM_MIC permission status should be ask for Secure origin. 129 // MEDIASTREAM_MIC permission status should be ask for Secure origin.
126 TEST_F(MediaStreamDevicePermissionContextTests, TestMicSecureQueryingUrl) { 130 TEST_F(MediaStreamDevicePermissionContextTests, TestMicSecureQueryingUrl) {
127 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 131 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
128 } 132 }
129 133
130 // MEDIASTREAM_CAMERA permission status should be ask for Secure origin. 134 // MEDIASTREAM_CAMERA permission status should be ask for Secure origin.
131 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraSecureQueryingUrl) { 135 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraSecureQueryingUrl) {
132 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 136 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
133 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698