| 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/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/content_settings/host_content_settings_map_factory.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/browser/permissions/permission_infobar_manager.h" |
| 10 #include "chrome/browser/permissions/permission_request_id.h" | 11 #include "chrome/browser/permissions/permission_request_id.h" |
| 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 13 #include "components/content_settings/core/browser/host_content_settings_map.h" | 14 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 14 #include "components/content_settings/core/common/content_settings.h" | 15 #include "components/content_settings/core/common/content_settings.h" |
| 15 #include "components/content_settings/core/common/content_settings_types.h" | 16 #include "components/content_settings/core/common/content_settings_types.h" |
| 16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/test/mock_render_process_host.h" | 18 #include "content/public/test/mock_render_process_host.h" |
| 18 #include "content/public/test/web_contents_tester.h" | 19 #include "content/public/test/web_contents_tester.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 EXPECT_EQ(CONTENT_SETTING_ASK, | 88 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 88 permission_context.GetPermissionStatus(secure_url, secure_url)); | 89 permission_context.GetPermissionStatus(secure_url, secure_url)); |
| 89 } | 90 } |
| 90 | 91 |
| 91 private: | 92 private: |
| 92 // ChromeRenderViewHostTestHarness: | 93 // ChromeRenderViewHostTestHarness: |
| 93 void SetUp() override { | 94 void SetUp() override { |
| 94 ChromeRenderViewHostTestHarness::SetUp(); | 95 ChromeRenderViewHostTestHarness::SetUp(); |
| 95 #if defined(OS_ANDROID) | 96 #if defined(OS_ANDROID) |
| 96 InfoBarService::CreateForWebContents(web_contents()); | 97 InfoBarService::CreateForWebContents(web_contents()); |
| 98 PermissionInfoBarManager::CreateForWebContents(web_contents()); |
| 97 #else | 99 #else |
| 98 PermissionBubbleManager::CreateForWebContents(web_contents()); | 100 PermissionBubbleManager::CreateForWebContents(web_contents()); |
| 99 #endif | 101 #endif |
| 100 } | 102 } |
| 101 | 103 |
| 102 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicePermissionContextTests); | 104 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicePermissionContextTests); |
| 103 }; | 105 }; |
| 104 | 106 |
| 105 // MEDIASTREAM_MIC permission status should be ask for insecure origin to | 107 // MEDIASTREAM_MIC permission status should be ask for insecure origin to |
| 106 // accommodate the usage case of Flash. | 108 // accommodate the usage case of Flash. |
| 107 TEST_F(MediaStreamDevicePermissionContextTests, TestMicInsecureQueryingUrl) { | 109 TEST_F(MediaStreamDevicePermissionContextTests, TestMicInsecureQueryingUrl) { |
| 108 TestInsecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 110 TestInsecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 109 } | 111 } |
| 110 | 112 |
| 111 // MEDIASTREAM_CAMERA permission status should be ask for insecure origin to | 113 // MEDIASTREAM_CAMERA permission status should be ask for insecure origin to |
| 112 // accommodate the usage case of Flash. | 114 // accommodate the usage case of Flash. |
| 113 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraInsecureQueryingUrl) { | 115 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraInsecureQueryingUrl) { |
| 114 TestInsecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 116 TestInsecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 115 } | 117 } |
| 116 | 118 |
| 117 // MEDIASTREAM_MIC permission status should be ask for Secure origin. | 119 // MEDIASTREAM_MIC permission status should be ask for Secure origin. |
| 118 TEST_F(MediaStreamDevicePermissionContextTests, TestMicSecureQueryingUrl) { | 120 TEST_F(MediaStreamDevicePermissionContextTests, TestMicSecureQueryingUrl) { |
| 119 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 121 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 120 } | 122 } |
| 121 | 123 |
| 122 // MEDIASTREAM_CAMERA permission status should be ask for Secure origin. | 124 // MEDIASTREAM_CAMERA permission status should be ask for Secure origin. |
| 123 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraSecureQueryingUrl) { | 125 TEST_F(MediaStreamDevicePermissionContextTests, TestCameraSecureQueryingUrl) { |
| 124 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 126 TestSecureQueryingUrl(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 125 } | 127 } |
| OLD | NEW |