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

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

Issue 1312453005: Removed Profile::GetHostContentSettingsMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed patch conflict Created 5 years, 3 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/media_stream_device_permission_context.h" 5 #include "chrome/browser/media/media_stream_device_permission_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
8 #include "chrome/browser/infobars/infobar_service.h" 9 #include "chrome/browser/infobars/infobar_service.h"
9 #include "chrome/browser/permissions/permission_queue_controller.h" 10 #include "chrome/browser/permissions/permission_queue_controller.h"
10 #include "chrome/browser/permissions/permission_request_id.h" 11 #include "chrome/browser/permissions/permission_request_id.h"
11 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 12 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 13 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
13 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
14 #include "components/content_settings/core/browser/host_content_settings_map.h" 15 #include "components/content_settings/core/browser/host_content_settings_map.h"
15 #include "components/content_settings/core/common/content_settings.h" 16 #include "components/content_settings/core/common/content_settings.h"
16 #include "components/content_settings/core/common/content_settings_types.h" 17 #include "components/content_settings/core/common/content_settings_types.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
(...skipping 20 matching lines...) Expand all
38 protected: 39 protected:
39 MediaStreamDevicePermissionContextTests() = default; 40 MediaStreamDevicePermissionContextTests() = default;
40 41
41 void TestInsecureQueryingUrl(ContentSettingsType permission_type) { 42 void TestInsecureQueryingUrl(ContentSettingsType permission_type) {
42 TestPermissionContext permission_context(profile(), permission_type); 43 TestPermissionContext permission_context(profile(), permission_type);
43 GURL insecure_url("http://www.example.com"); 44 GURL insecure_url("http://www.example.com");
44 GURL secure_url("https://www.example.com"); 45 GURL secure_url("https://www.example.com");
45 46
46 // Check that there is no saved content settings. 47 // Check that there is no saved content settings.
47 EXPECT_EQ(CONTENT_SETTING_ASK, 48 EXPECT_EQ(CONTENT_SETTING_ASK,
48 profile()->GetHostContentSettingsMap()->GetContentSetting( 49 HostContentSettingsMapFactory::GetForProfile(profile())
49 insecure_url.GetOrigin(), insecure_url.GetOrigin(), 50 ->GetContentSetting(insecure_url.GetOrigin(),
50 permission_type, std::string())); 51 insecure_url.GetOrigin(),
52 permission_type,
53 std::string()));
51 EXPECT_EQ(CONTENT_SETTING_ASK, 54 EXPECT_EQ(CONTENT_SETTING_ASK,
52 profile()->GetHostContentSettingsMap()->GetContentSetting( 55 HostContentSettingsMapFactory::GetForProfile(profile())
53 secure_url.GetOrigin(), insecure_url.GetOrigin(), 56 ->GetContentSetting(secure_url.GetOrigin(),
54 permission_type, std::string())); 57 insecure_url.GetOrigin(),
58 permission_type,
59 std::string()));
55 EXPECT_EQ(CONTENT_SETTING_ASK, 60 EXPECT_EQ(CONTENT_SETTING_ASK,
56 profile()->GetHostContentSettingsMap()->GetContentSetting( 61 HostContentSettingsMapFactory::GetForProfile(profile())
57 insecure_url.GetOrigin(), secure_url.GetOrigin(), 62 ->GetContentSetting(insecure_url.GetOrigin(),
58 permission_type, std::string())); 63 secure_url.GetOrigin(),
64 permission_type,
65 std::string()));
59 66
60 EXPECT_EQ(CONTENT_SETTING_ASK, permission_context.GetPermissionStatus( 67 EXPECT_EQ(CONTENT_SETTING_ASK, permission_context.GetPermissionStatus(
61 insecure_url, insecure_url)); 68 insecure_url, insecure_url));
62 EXPECT_EQ(CONTENT_SETTING_ASK, 69 EXPECT_EQ(CONTENT_SETTING_ASK,
63 permission_context.GetPermissionStatus(insecure_url, secure_url)); 70 permission_context.GetPermissionStatus(insecure_url, secure_url));
64 } 71 }
65 72
66 void TestSecureQueryingUrl(ContentSettingsType permission_type) { 73 void TestSecureQueryingUrl(ContentSettingsType permission_type) {
67 TestPermissionContext permission_context(profile(), permission_type); 74 TestPermissionContext permission_context(profile(), permission_type);
68 GURL secure_url("https://www.example.com"); 75 GURL secure_url("https://www.example.com");
69 76
70 // Check that there is no saved content settings. 77 // Check that there is no saved content settings.
71 EXPECT_EQ(CONTENT_SETTING_ASK, 78 EXPECT_EQ(CONTENT_SETTING_ASK,
72 profile()->GetHostContentSettingsMap()->GetContentSetting( 79 HostContentSettingsMapFactory::GetForProfile(profile())
73 secure_url.GetOrigin(), secure_url.GetOrigin(), 80 ->GetContentSetting(secure_url.GetOrigin(),
74 permission_type, std::string())); 81 secure_url.GetOrigin(),
82 permission_type,
83 std::string()));
75 84
76 EXPECT_EQ(CONTENT_SETTING_ASK, 85 EXPECT_EQ(CONTENT_SETTING_ASK,
77 permission_context.GetPermissionStatus(secure_url, secure_url)); 86 permission_context.GetPermissionStatus(secure_url, secure_url));
78 } 87 }
79 88
80 private: 89 private:
81 // ChromeRenderViewHostTestHarness: 90 // ChromeRenderViewHostTestHarness:
82 void SetUp() override { 91 void SetUp() override {
83 ChromeRenderViewHostTestHarness::SetUp(); 92 ChromeRenderViewHostTestHarness::SetUp();
84 InfoBarService::CreateForWebContents(web_contents()); 93 InfoBarService::CreateForWebContents(web_contents());
(...skipping 17 matching lines...) Expand all
102 111
103 // MEDIASTREAM_MIC permission status should be ask for Secure origin. 112 // MEDIASTREAM_MIC permission status should be ask for Secure origin.
104 TEST_F(MediaStreamDevicePermissionContextTests, TestMicSecureQueryingUrl) { 113 TEST_F(MediaStreamDevicePermissionContextTests, TestMicSecureQueryingUrl) {
105 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 114 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
106 } 115 }
107 116
108 // MEDIASTREAM_CAMERA permission status should be ask for Secure origin. 117 // MEDIASTREAM_CAMERA permission status should be ask for Secure origin.
109 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraSecureQueryingUrl) { 118 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraSecureQueryingUrl) {
110 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 119 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
111 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698