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 3483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3646 this)); | 3649 this)); |
3647 | 3650 |
3648 base::MessageLoop::current()->Run(); | 3651 base::MessageLoop::current()->Run(); |
3649 } | 3652 } |
3650 } | 3653 } |
3651 | 3654 |
3652 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, | 3655 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, |
3653 MediaStreamDevicesControllerBrowserTest, | 3656 MediaStreamDevicesControllerBrowserTest, |
3654 testing::Bool()); | 3657 testing::Bool()); |
3655 | 3658 |
3659 class WebBluetoothPolicyTest : public PolicyTest { | |
3660 void SetUpCommandLine(base::CommandLine* command_line)override { | |
3661 // This is needed while Web Bluetooth is an Origin Trial, but can go away | |
3662 // once it ships globally. | |
3663 command_line->AppendSwitch(switches::kEnableWebBluetooth); | |
3664 PolicyTest::SetUpCommandLine(command_line); | |
3665 } | |
3666 }; | |
3667 | |
3668 IN_PROC_BROWSER_TEST_F(WebBluetoothPolicyTest, Block) { | |
3669 // Fake the BluetoothAdapter to say it's present. | |
3670 scoped_refptr<device::MockBluetoothAdapter> adapter = | |
3671 new testing::NiceMock<device::MockBluetoothAdapter>; | |
3672 EXPECT_CALL(*adapter, IsPresent()).WillRepeatedly(testing::Return(true)); | |
3673 device::BluetoothAdapterFactory::SetAdapterForTesting(adapter); | |
3674 | |
3675 // Navigate to a secure context. | |
3676 embedded_test_server()->ServeFilesFromSourceDirectory("content/test/data"); | |
3677 ASSERT_TRUE(embedded_test_server()->Start()); | |
3678 ui_test_utils::NavigateToURL( | |
3679 browser(), | |
3680 embedded_test_server()->GetURL("localhost", "/simple_page.html")); | |
3681 content::WebContents* const web_contents = | |
bartfab (slow)
2016/02/26 18:00:45
Nit: const pointer
Jeffrey Yasskin
2016/02/26 18:21:25
Nope, GetMainFrame() is non-const.
| |
3682 browser()->tab_strip_model()->GetActiveWebContents(); | |
3683 ASSERT_THAT( | |
bartfab (slow)
2016/02/26 18:00:45
Nit: Would an EXPECT not be sufficient here?
Jeffrey Yasskin
2016/02/26 18:21:25
We won't get useful errors from the rest of the te
| |
3684 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize(), | |
bartfab (slow)
2016/02/26 18:00:45
Nit: #include "url/origin.h"
Jeffrey Yasskin
2016/02/26 18:21:25
Done.
| |
3685 testing::StartsWith("http://localhost:")); | |
3686 | |
3687 // Set the policy to block Web Bluetooth. | |
3688 PolicyMap policies; | |
3689 policies.Set(key::kDefaultWebBluetoothGuardSetting, POLICY_LEVEL_MANDATORY, | |
3690 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | |
3691 new base::FundamentalValue(2), nullptr); | |
3692 UpdateProviderPolicy(policies); | |
3693 | |
3694 std::string rejection; | |
3695 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | |
3696 web_contents, | |
3697 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" | |
3698 ".then(() => { domAutomationController.send('Success'); }," | |
bartfab (slow)
2016/02/26 18:00:45
Nit: Indentation.
Jeffrey Yasskin
2016/02/26 18:21:25
Heh, I have no idea how to indent .then() calls. I
bartfab (slow)
2016/02/26 18:24:54
I have no idea either, but zero spaces seemed like
| |
3699 " reason => {" | |
3700 " domAutomationController.send(reason.name + ': ' + reason.message);" | |
3701 "});", | |
3702 &rejection)); | |
3703 EXPECT_THAT(rejection, testing::MatchesRegex("NotFoundError: .*policy.*")); | |
3704 } | |
3705 | |
3656 // Test that when extended reporting opt-in is disabled by policy, the | 3706 // Test that when extended reporting opt-in is disabled by policy, the |
3657 // opt-in checkbox does not appear on SSL blocking pages. | 3707 // opt-in checkbox does not appear on SSL blocking pages. |
3658 IN_PROC_BROWSER_TEST_F(PolicyTest, SafeBrowsingExtendedReportingOptInAllowed) { | 3708 IN_PROC_BROWSER_TEST_F(PolicyTest, SafeBrowsingExtendedReportingOptInAllowed) { |
3659 net::EmbeddedTestServer https_server_expired( | 3709 net::EmbeddedTestServer https_server_expired( |
3660 net::EmbeddedTestServer::TYPE_HTTPS); | 3710 net::EmbeddedTestServer::TYPE_HTTPS); |
3661 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); | 3711 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
3662 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); | 3712 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
3663 ASSERT_TRUE(https_server_expired.Start()); | 3713 ASSERT_TRUE(https_server_expired.Start()); |
3664 | 3714 |
3665 // Set the enterprise policy to disallow opt-in. | 3715 // 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, | 3987 POLICY_SCOPE_USER, |
3938 POLICY_SOURCE_CLOUD, | 3988 POLICY_SOURCE_CLOUD, |
3939 new base::FundamentalValue(false), | 3989 new base::FundamentalValue(false), |
3940 NULL); | 3990 NULL); |
3941 UpdateProviderPolicy(policies); | 3991 UpdateProviderPolicy(policies); |
3942 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 3992 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
3943 } | 3993 } |
3944 #endif // defined(OS_CHROMEOS) | 3994 #endif // defined(OS_CHROMEOS) |
3945 | 3995 |
3946 } // namespace policy | 3996 } // namespace policy |
OLD | NEW |