| 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/midi_permission_context.h" | 5 #include "chrome/browser/media/midi_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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 web_contents(), | 97 web_contents(), |
| 97 id, url, true, | 98 id, url, true, |
| 98 base::Bind(&TestPermissionContext::TrackPermissionDecision, | 99 base::Bind(&TestPermissionContext::TrackPermissionDecision, |
| 99 base::Unretained(&permission_context))); | 100 base::Unretained(&permission_context))); |
| 100 | 101 |
| 101 EXPECT_TRUE(permission_context.permission_set()); | 102 EXPECT_TRUE(permission_context.permission_set()); |
| 102 EXPECT_FALSE(permission_context.permission_granted()); | 103 EXPECT_FALSE(permission_context.permission_granted()); |
| 103 EXPECT_TRUE(permission_context.tab_context_updated()); | 104 EXPECT_TRUE(permission_context.tab_context_updated()); |
| 104 | 105 |
| 105 ContentSetting setting = | 106 ContentSetting setting = |
| 106 profile()->GetHostContentSettingsMap()->GetContentSetting( | 107 HostContentSettingsMapFactory::GetForProfile(profile()) |
| 107 url.GetOrigin(), url.GetOrigin(), | 108 ->GetContentSetting(url.GetOrigin(), |
| 108 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string()); | 109 url.GetOrigin(), |
| 110 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
| 111 std::string()); |
| 109 EXPECT_EQ(CONTENT_SETTING_ASK, setting); | 112 EXPECT_EQ(CONTENT_SETTING_ASK, setting); |
| 110 } | 113 } |
| 111 | 114 |
| 112 // Web MIDI permission status should be denied for insecure origin. | 115 // Web MIDI permission status should be denied for insecure origin. |
| 113 TEST_F(MidiPermissionContextTests, TestInsecureQueryingUrl) { | 116 TEST_F(MidiPermissionContextTests, TestInsecureQueryingUrl) { |
| 114 TestPermissionContext permission_context(profile()); | 117 TestPermissionContext permission_context(profile()); |
| 115 GURL insecure_url("http://www.example.com"); | 118 GURL insecure_url("http://www.example.com"); |
| 116 GURL secure_url("https://www.example.com"); | 119 GURL secure_url("https://www.example.com"); |
| 117 | 120 |
| 118 // Check that there is no saved content settings. | 121 // Check that there is no saved content settings. |
| 119 EXPECT_EQ(CONTENT_SETTING_ASK, | 122 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 120 profile()->GetHostContentSettingsMap()->GetContentSetting( | 123 HostContentSettingsMapFactory::GetForProfile(profile()) |
| 121 insecure_url.GetOrigin(), insecure_url.GetOrigin(), | 124 ->GetContentSetting(insecure_url.GetOrigin(), |
| 122 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string())); | 125 insecure_url.GetOrigin(), |
| 126 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
| 127 std::string())); |
| 123 EXPECT_EQ(CONTENT_SETTING_ASK, | 128 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 124 profile()->GetHostContentSettingsMap()->GetContentSetting( | 129 HostContentSettingsMapFactory::GetForProfile(profile()) |
| 125 secure_url.GetOrigin(), insecure_url.GetOrigin(), | 130 ->GetContentSetting(secure_url.GetOrigin(), |
| 126 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string())); | 131 insecure_url.GetOrigin(), |
| 132 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
| 133 std::string())); |
| 127 EXPECT_EQ(CONTENT_SETTING_ASK, | 134 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 128 profile()->GetHostContentSettingsMap()->GetContentSetting( | 135 HostContentSettingsMapFactory::GetForProfile(profile()) |
| 129 insecure_url.GetOrigin(), secure_url.GetOrigin(), | 136 ->GetContentSetting(insecure_url.GetOrigin(), |
| 130 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string())); | 137 secure_url.GetOrigin(), |
| 138 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
| 139 std::string())); |
| 131 | 140 |
| 132 EXPECT_EQ(CONTENT_SETTING_BLOCK, permission_context.GetPermissionStatus( | 141 EXPECT_EQ(CONTENT_SETTING_BLOCK, permission_context.GetPermissionStatus( |
| 133 insecure_url, insecure_url)); | 142 insecure_url, insecure_url)); |
| 134 EXPECT_EQ(CONTENT_SETTING_BLOCK, permission_context.GetPermissionStatus( | 143 EXPECT_EQ(CONTENT_SETTING_BLOCK, permission_context.GetPermissionStatus( |
| 135 insecure_url, secure_url)); | 144 insecure_url, secure_url)); |
| 136 } | 145 } |
| OLD | NEW |