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

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

Issue 2723983004: Add PermissionManager::GetPermissionStatusForFrame function (Closed)
Patch Set: Add PermissionManager::GetPermissionStatusForFrame function Created 3 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 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 ->GetContentSetting(secure_url.GetOrigin(), 59 ->GetContentSetting(secure_url.GetOrigin(),
60 insecure_url.GetOrigin(), 60 insecure_url.GetOrigin(),
61 content_settings_type, std::string())); 61 content_settings_type, std::string()));
62 EXPECT_EQ(CONTENT_SETTING_ASK, 62 EXPECT_EQ(CONTENT_SETTING_ASK,
63 HostContentSettingsMapFactory::GetForProfile(profile()) 63 HostContentSettingsMapFactory::GetForProfile(profile())
64 ->GetContentSetting(insecure_url.GetOrigin(), 64 ->GetContentSetting(insecure_url.GetOrigin(),
65 secure_url.GetOrigin(), 65 secure_url.GetOrigin(),
66 content_settings_type, std::string())); 66 content_settings_type, std::string()));
67 67
68 EXPECT_EQ(CONTENT_SETTING_ASK, 68 EXPECT_EQ(CONTENT_SETTING_ASK,
69 permission_context.GetPermissionStatus(insecure_url, insecure_url) 69 permission_context
70 .GetPermissionStatus(nullptr /* render_frame_host */,
71 insecure_url, insecure_url)
70 .content_setting); 72 .content_setting);
71 73
72 EXPECT_EQ(CONTENT_SETTING_ASK, 74 EXPECT_EQ(CONTENT_SETTING_ASK,
73 permission_context.GetPermissionStatus(insecure_url, secure_url) 75 permission_context
76 .GetPermissionStatus(nullptr /* render_frame_host */,
77 insecure_url, secure_url)
74 .content_setting); 78 .content_setting);
75 } 79 }
76 80
77 void TestSecureQueryingUrl(ContentSettingsType content_settings_type) { 81 void TestSecureQueryingUrl(ContentSettingsType content_settings_type) {
78 TestPermissionContext permission_context(profile(), content_settings_type); 82 TestPermissionContext permission_context(profile(), content_settings_type);
79 GURL secure_url("https://www.example.com"); 83 GURL secure_url("https://www.example.com");
80 84
81 // Check that there is no saved content settings. 85 // Check that there is no saved content settings.
82 EXPECT_EQ(CONTENT_SETTING_ASK, 86 EXPECT_EQ(CONTENT_SETTING_ASK,
83 HostContentSettingsMapFactory::GetForProfile(profile()) 87 HostContentSettingsMapFactory::GetForProfile(profile())
84 ->GetContentSetting(secure_url.GetOrigin(), 88 ->GetContentSetting(secure_url.GetOrigin(),
85 secure_url.GetOrigin(), 89 secure_url.GetOrigin(),
86 content_settings_type, 90 content_settings_type,
87 std::string())); 91 std::string()));
88 92
89 EXPECT_EQ(CONTENT_SETTING_ASK, 93 EXPECT_EQ(CONTENT_SETTING_ASK,
90 permission_context.GetPermissionStatus(secure_url, secure_url) 94 permission_context
95 .GetPermissionStatus(nullptr /* render_frame_host */,
96 secure_url, secure_url)
91 .content_setting); 97 .content_setting);
92 } 98 }
93 99
94 private: 100 private:
95 // ChromeRenderViewHostTestHarness: 101 // ChromeRenderViewHostTestHarness:
96 void SetUp() override { 102 void SetUp() override {
97 ChromeRenderViewHostTestHarness::SetUp(); 103 ChromeRenderViewHostTestHarness::SetUp();
98 #if defined(OS_ANDROID) 104 #if defined(OS_ANDROID)
99 InfoBarService::CreateForWebContents(web_contents()); 105 InfoBarService::CreateForWebContents(web_contents());
100 #else 106 #else
(...skipping 18 matching lines...) Expand all
119 125
120 // MEDIASTREAM_MIC permission status should be ask for Secure origin. 126 // MEDIASTREAM_MIC permission status should be ask for Secure origin.
121 TEST_F(MediaStreamDevicePermissionContextTests, TestMicSecureQueryingUrl) { 127 TEST_F(MediaStreamDevicePermissionContextTests, TestMicSecureQueryingUrl) {
122 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 128 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
123 } 129 }
124 130
125 // MEDIASTREAM_CAMERA permission status should be ask for Secure origin. 131 // MEDIASTREAM_CAMERA permission status should be ask for Secure origin.
126 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraSecureQueryingUrl) { 132 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraSecureQueryingUrl) {
127 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 133 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
128 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698