OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 #include "content/public/browser/notification_source.h" | 134 #include "content/public/browser/notification_source.h" |
135 #include "content/public/browser/notification_types.h" | 135 #include "content/public/browser/notification_types.h" |
136 #include "content/public/browser/plugin_service.h" | 136 #include "content/public/browser/plugin_service.h" |
137 #include "content/public/browser/render_frame_host.h" | 137 #include "content/public/browser/render_frame_host.h" |
138 #include "content/public/browser/render_process_host.h" | 138 #include "content/public/browser/render_process_host.h" |
139 #include "content/public/browser/render_view_host.h" | 139 #include "content/public/browser/render_view_host.h" |
140 #include "content/public/browser/render_widget_host.h" | 140 #include "content/public/browser/render_widget_host.h" |
141 #include "content/public/browser/web_contents.h" | 141 #include "content/public/browser/web_contents.h" |
142 #include "content/public/common/content_constants.h" | 142 #include "content/public/common/content_constants.h" |
143 #include "content/public/common/content_paths.h" | 143 #include "content/public/common/content_paths.h" |
| 144 #include "content/public/common/content_switches.h" |
144 #include "content/public/common/process_type.h" | 145 #include "content/public/common/process_type.h" |
145 #include "content/public/common/result_codes.h" | 146 #include "content/public/common/result_codes.h" |
146 #include "content/public/common/url_constants.h" | 147 #include "content/public/common/url_constants.h" |
147 #include "content/public/common/webplugininfo.h" | 148 #include "content/public/common/webplugininfo.h" |
148 #include "content/public/test/browser_test_utils.h" | 149 #include "content/public/test/browser_test_utils.h" |
149 #include "content/public/test/download_test_observer.h" | 150 #include "content/public/test/download_test_observer.h" |
150 #include "content/public/test/mock_notification_observer.h" | 151 #include "content/public/test/mock_notification_observer.h" |
151 #include "content/public/test/test_navigation_observer.h" | 152 #include "content/public/test/test_navigation_observer.h" |
152 #include "content/public/test/test_utils.h" | 153 #include "content/public/test/test_utils.h" |
| 154 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 155 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
153 #include "extensions/browser/extension_dialog_auto_confirm.h" | 156 #include "extensions/browser/extension_dialog_auto_confirm.h" |
154 #include "extensions/browser/extension_host.h" | 157 #include "extensions/browser/extension_host.h" |
155 #include "extensions/browser/extension_prefs.h" | 158 #include "extensions/browser/extension_prefs.h" |
156 #include "extensions/browser/extension_registry.h" | 159 #include "extensions/browser/extension_registry.h" |
157 #include "extensions/browser/extension_system.h" | 160 #include "extensions/browser/extension_system.h" |
158 #include "extensions/browser/process_manager.h" | 161 #include "extensions/browser/process_manager.h" |
159 #include "extensions/browser/test_extension_registry_observer.h" | 162 #include "extensions/browser/test_extension_registry_observer.h" |
160 #include "extensions/browser/uninstall_reason.h" | 163 #include "extensions/browser/uninstall_reason.h" |
161 #include "extensions/common/constants.h" | 164 #include "extensions/common/constants.h" |
162 #include "extensions/common/extension.h" | 165 #include "extensions/common/extension.h" |
(...skipping 11 matching lines...) Expand all Loading... |
174 #include "net/url_request/url_request_filter.h" | 177 #include "net/url_request/url_request_filter.h" |
175 #include "net/url_request/url_request_interceptor.h" | 178 #include "net/url_request/url_request_interceptor.h" |
176 #include "policy/policy_constants.h" | 179 #include "policy/policy_constants.h" |
177 #include "testing/gmock/include/gmock/gmock.h" | 180 #include "testing/gmock/include/gmock/gmock.h" |
178 #include "testing/gtest/include/gtest/gtest.h" | 181 #include "testing/gtest/include/gtest/gtest.h" |
179 #include "third_party/WebKit/public/web/WebInputEvent.h" | 182 #include "third_party/WebKit/public/web/WebInputEvent.h" |
180 #include "ui/base/l10n/l10n_util.h" | 183 #include "ui/base/l10n/l10n_util.h" |
181 #include "ui/base/page_transition_types.h" | 184 #include "ui/base/page_transition_types.h" |
182 #include "ui/base/resource/resource_bundle.h" | 185 #include "ui/base/resource/resource_bundle.h" |
183 #include "url/gurl.h" | 186 #include "url/gurl.h" |
| 187 #include "url/origin.h" |
184 | 188 |
185 #if defined(OS_CHROMEOS) | 189 #if defined(OS_CHROMEOS) |
186 #include "ash/accelerators/accelerator_controller.h" | 190 #include "ash/accelerators/accelerator_controller.h" |
187 #include "ash/accelerators/accelerator_table.h" | 191 #include "ash/accelerators/accelerator_table.h" |
188 #include "ash/shell.h" | 192 #include "ash/shell.h" |
189 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 193 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
190 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 194 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
191 #include "chrome/browser/profiles/profile_manager.h" | 195 #include "chrome/browser/profiles/profile_manager.h" |
192 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" | 196 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" |
193 #include "chromeos/audio/cras_audio_handler.h" | 197 #include "chromeos/audio/cras_audio_handler.h" |
(...skipping 3452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3646 this)); | 3650 this)); |
3647 | 3651 |
3648 base::MessageLoop::current()->Run(); | 3652 base::MessageLoop::current()->Run(); |
3649 } | 3653 } |
3650 } | 3654 } |
3651 | 3655 |
3652 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, | 3656 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, |
3653 MediaStreamDevicesControllerBrowserTest, | 3657 MediaStreamDevicesControllerBrowserTest, |
3654 testing::Bool()); | 3658 testing::Bool()); |
3655 | 3659 |
| 3660 class WebBluetoothPolicyTest : public PolicyTest { |
| 3661 void SetUpCommandLine(base::CommandLine* command_line)override { |
| 3662 // This is needed while Web Bluetooth is an Origin Trial, but can go away |
| 3663 // once it ships globally. |
| 3664 command_line->AppendSwitch(switches::kEnableWebBluetooth); |
| 3665 PolicyTest::SetUpCommandLine(command_line); |
| 3666 } |
| 3667 }; |
| 3668 |
| 3669 IN_PROC_BROWSER_TEST_F(WebBluetoothPolicyTest, Block) { |
| 3670 // Fake the BluetoothAdapter to say it's present. |
| 3671 scoped_refptr<device::MockBluetoothAdapter> adapter = |
| 3672 new testing::NiceMock<device::MockBluetoothAdapter>; |
| 3673 EXPECT_CALL(*adapter, IsPresent()).WillRepeatedly(testing::Return(true)); |
| 3674 device::BluetoothAdapterFactory::SetAdapterForTesting(adapter); |
| 3675 |
| 3676 // Navigate to a secure context. |
| 3677 embedded_test_server()->ServeFilesFromSourceDirectory("content/test/data"); |
| 3678 ASSERT_TRUE(embedded_test_server()->Start()); |
| 3679 ui_test_utils::NavigateToURL( |
| 3680 browser(), |
| 3681 embedded_test_server()->GetURL("localhost", "/simple_page.html")); |
| 3682 content::WebContents* const web_contents = |
| 3683 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3684 EXPECT_THAT( |
| 3685 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize(), |
| 3686 testing::StartsWith("http://localhost:")); |
| 3687 |
| 3688 // Set the policy to block Web Bluetooth. |
| 3689 PolicyMap policies; |
| 3690 policies.Set(key::kDefaultWebBluetoothGuardSetting, POLICY_LEVEL_MANDATORY, |
| 3691 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3692 new base::FundamentalValue(2), nullptr); |
| 3693 UpdateProviderPolicy(policies); |
| 3694 |
| 3695 std::string rejection; |
| 3696 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 3697 web_contents, |
| 3698 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" |
| 3699 " .then(() => { domAutomationController.send('Success'); }," |
| 3700 " reason => {" |
| 3701 " domAutomationController.send(reason.name + ': ' + reason.message);" |
| 3702 " });", |
| 3703 &rejection)); |
| 3704 EXPECT_THAT(rejection, testing::MatchesRegex("NotFoundError: .*policy.*")); |
| 3705 } |
| 3706 |
3656 // Test that when extended reporting opt-in is disabled by policy, the | 3707 // Test that when extended reporting opt-in is disabled by policy, the |
3657 // opt-in checkbox does not appear on SSL blocking pages. | 3708 // opt-in checkbox does not appear on SSL blocking pages. |
3658 IN_PROC_BROWSER_TEST_F(PolicyTest, SafeBrowsingExtendedReportingOptInAllowed) { | 3709 IN_PROC_BROWSER_TEST_F(PolicyTest, SafeBrowsingExtendedReportingOptInAllowed) { |
3659 net::EmbeddedTestServer https_server_expired( | 3710 net::EmbeddedTestServer https_server_expired( |
3660 net::EmbeddedTestServer::TYPE_HTTPS); | 3711 net::EmbeddedTestServer::TYPE_HTTPS); |
3661 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); | 3712 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
3662 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); | 3713 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
3663 ASSERT_TRUE(https_server_expired.Start()); | 3714 ASSERT_TRUE(https_server_expired.Start()); |
3664 | 3715 |
3665 // Set the enterprise policy to disallow opt-in. | 3716 // Set the enterprise policy to disallow opt-in. |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3937 POLICY_SCOPE_USER, | 3988 POLICY_SCOPE_USER, |
3938 POLICY_SOURCE_CLOUD, | 3989 POLICY_SOURCE_CLOUD, |
3939 new base::FundamentalValue(false), | 3990 new base::FundamentalValue(false), |
3940 NULL); | 3991 NULL); |
3941 UpdateProviderPolicy(policies); | 3992 UpdateProviderPolicy(policies); |
3942 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 3993 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
3943 } | 3994 } |
3944 #endif // defined(OS_CHROMEOS) | 3995 #endif // defined(OS_CHROMEOS) |
3945 | 3996 |
3946 } // namespace policy | 3997 } // namespace policy |
OLD | NEW |