| 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 "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" |
| 11 #include "chrome/browser/permissions/permission_request_id.h" | 11 #include "chrome/browser/permissions/permission_request_id.h" |
| 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "components/content_settings/core/browser/host_content_settings_map.h" | 14 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 15 #include "components/content_settings/core/common/content_settings.h" | 15 #include "components/content_settings/core/common/content_settings.h" |
| 16 #include "components/content_settings/core/common/content_settings_types.h" | 16 #include "components/content_settings/core/common/content_settings_types.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/test/mock_render_process_host.h" | 18 #include "content/public/test/mock_render_process_host.h" |
| 19 #include "content/public/test/web_contents_tester.h" | 19 #include "content/public/test/web_contents_tester.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 21 |
| 22 #if defined(OS_ANDROID) | 22 #if defined(OS_ANDROID) |
| 23 #include "chrome/browser/infobars/infobar_service.h" | 23 #include "chrome/browser/infobars/infobar_service.h" |
| 24 #else | 24 #else |
| 25 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 25 #include "chrome/browser/permissions/permission_request_manager.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 class TestPermissionContext : public MidiPermissionContext { | 30 class TestPermissionContext : public MidiPermissionContext { |
| 31 public: | 31 public: |
| 32 explicit TestPermissionContext(Profile* profile) | 32 explicit TestPermissionContext(Profile* profile) |
| 33 : MidiPermissionContext(profile), | 33 : MidiPermissionContext(profile), |
| 34 permission_set_(false), | 34 permission_set_(false), |
| 35 permission_granted_(false), | 35 permission_granted_(false), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 protected: | 73 protected: |
| 74 MidiPermissionContextTests() = default; | 74 MidiPermissionContextTests() = default; |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 // ChromeRenderViewHostTestHarness: | 77 // ChromeRenderViewHostTestHarness: |
| 78 void SetUp() override { | 78 void SetUp() override { |
| 79 ChromeRenderViewHostTestHarness::SetUp(); | 79 ChromeRenderViewHostTestHarness::SetUp(); |
| 80 #if defined(OS_ANDROID) | 80 #if defined(OS_ANDROID) |
| 81 InfoBarService::CreateForWebContents(web_contents()); | 81 InfoBarService::CreateForWebContents(web_contents()); |
| 82 #else | 82 #else |
| 83 PermissionBubbleManager::CreateForWebContents(web_contents()); | 83 PermissionRequestManager::CreateForWebContents(web_contents()); |
| 84 #endif | 84 #endif |
| 85 } | 85 } |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(MidiPermissionContextTests); | 87 DISALLOW_COPY_AND_ASSIGN(MidiPermissionContextTests); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 // Web MIDI permission should be denied for insecure origin. | 90 // Web MIDI permission should be denied for insecure origin. |
| 91 TEST_F(MidiPermissionContextTests, TestInsecureRequestingUrl) { | 91 TEST_F(MidiPermissionContextTests, TestInsecureRequestingUrl) { |
| 92 TestPermissionContext permission_context(profile()); | 92 TestPermissionContext permission_context(profile()); |
| 93 GURL url("http://www.example.com"); | 93 GURL url("http://www.example.com"); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 ->GetContentSetting(insecure_url.GetOrigin(), | 139 ->GetContentSetting(insecure_url.GetOrigin(), |
| 140 secure_url.GetOrigin(), | 140 secure_url.GetOrigin(), |
| 141 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, | 141 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
| 142 std::string())); | 142 std::string())); |
| 143 | 143 |
| 144 EXPECT_EQ(CONTENT_SETTING_BLOCK, permission_context.GetPermissionStatus( | 144 EXPECT_EQ(CONTENT_SETTING_BLOCK, permission_context.GetPermissionStatus( |
| 145 insecure_url, insecure_url)); | 145 insecure_url, insecure_url)); |
| 146 EXPECT_EQ(CONTENT_SETTING_BLOCK, permission_context.GetPermissionStatus( | 146 EXPECT_EQ(CONTENT_SETTING_BLOCK, permission_context.GetPermissionStatus( |
| 147 insecure_url, secure_url)); | 147 insecure_url, secure_url)); |
| 148 } | 148 } |
| OLD | NEW |