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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 #include "components/search/search.h" | 112 #include "components/search/search.h" |
113 #include "components/search_engines/template_url.h" | 113 #include "components/search_engines/template_url.h" |
114 #include "components/search_engines/template_url_service.h" | 114 #include "components/search_engines/template_url_service.h" |
115 #include "components/security_interstitials/core/controller_client.h" | 115 #include "components/security_interstitials/core/controller_client.h" |
116 #include "components/ssl_config/ssl_config_prefs.h" | 116 #include "components/ssl_config/ssl_config_prefs.h" |
117 #include "components/strings/grit/components_strings.h" | 117 #include "components/strings/grit/components_strings.h" |
118 #include "components/translate/core/browser/language_state.h" | 118 #include "components/translate/core/browser/language_state.h" |
119 #include "components/translate/core/browser/translate_infobar_delegate.h" | 119 #include "components/translate/core/browser/translate_infobar_delegate.h" |
120 #include "components/variations/service/variations_service.h" | 120 #include "components/variations/service/variations_service.h" |
121 #include "components/version_info/version_info.h" | 121 #include "components/version_info/version_info.h" |
| 122 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h" |
| 123 #include "content/common/bluetooth/bluetooth_messages.h" |
122 #include "content/public/browser/browser_child_process_host_iterator.h" | 124 #include "content/public/browser/browser_child_process_host_iterator.h" |
123 #include "content/public/browser/browser_context.h" | 125 #include "content/public/browser/browser_context.h" |
124 #include "content/public/browser/browser_thread.h" | 126 #include "content/public/browser/browser_thread.h" |
125 #include "content/public/browser/child_process_data.h" | 127 #include "content/public/browser/child_process_data.h" |
126 #include "content/public/browser/download_item.h" | 128 #include "content/public/browser/download_item.h" |
127 #include "content/public/browser/download_manager.h" | 129 #include "content/public/browser/download_manager.h" |
128 #include "content/public/browser/gpu_data_manager.h" | 130 #include "content/public/browser/gpu_data_manager.h" |
129 #include "content/public/browser/interstitial_page.h" | 131 #include "content/public/browser/interstitial_page.h" |
130 #include "content/public/browser/notification_details.h" | 132 #include "content/public/browser/notification_details.h" |
131 #include "content/public/browser/notification_observer.h" | 133 #include "content/public/browser/notification_observer.h" |
(...skipping 11 matching lines...) Expand all Loading... |
143 #include "content/public/common/content_paths.h" | 145 #include "content/public/common/content_paths.h" |
144 #include "content/public/common/process_type.h" | 146 #include "content/public/common/process_type.h" |
145 #include "content/public/common/result_codes.h" | 147 #include "content/public/common/result_codes.h" |
146 #include "content/public/common/url_constants.h" | 148 #include "content/public/common/url_constants.h" |
147 #include "content/public/common/webplugininfo.h" | 149 #include "content/public/common/webplugininfo.h" |
148 #include "content/public/test/browser_test_utils.h" | 150 #include "content/public/test/browser_test_utils.h" |
149 #include "content/public/test/download_test_observer.h" | 151 #include "content/public/test/download_test_observer.h" |
150 #include "content/public/test/mock_notification_observer.h" | 152 #include "content/public/test/mock_notification_observer.h" |
151 #include "content/public/test/test_navigation_observer.h" | 153 #include "content/public/test/test_navigation_observer.h" |
152 #include "content/public/test/test_utils.h" | 154 #include "content/public/test/test_utils.h" |
| 155 #include "content/public/test/web_contents_tester.h" |
| 156 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
153 #include "extensions/browser/extension_dialog_auto_confirm.h" | 157 #include "extensions/browser/extension_dialog_auto_confirm.h" |
154 #include "extensions/browser/extension_host.h" | 158 #include "extensions/browser/extension_host.h" |
155 #include "extensions/browser/extension_prefs.h" | 159 #include "extensions/browser/extension_prefs.h" |
156 #include "extensions/browser/extension_registry.h" | 160 #include "extensions/browser/extension_registry.h" |
157 #include "extensions/browser/extension_system.h" | 161 #include "extensions/browser/extension_system.h" |
158 #include "extensions/browser/process_manager.h" | 162 #include "extensions/browser/process_manager.h" |
159 #include "extensions/browser/test_extension_registry_observer.h" | 163 #include "extensions/browser/test_extension_registry_observer.h" |
160 #include "extensions/browser/uninstall_reason.h" | 164 #include "extensions/browser/uninstall_reason.h" |
161 #include "extensions/common/constants.h" | 165 #include "extensions/common/constants.h" |
162 #include "extensions/common/extension.h" | 166 #include "extensions/common/extension.h" |
163 #include "extensions/common/extension_set.h" | 167 #include "extensions/common/extension_set.h" |
164 #include "extensions/common/manifest_handlers/shared_module_info.h" | 168 #include "extensions/common/manifest_handlers/shared_module_info.h" |
| 169 #include "ipc/ipc_test_sink.h" |
| 170 #include "ipc/message_filter.h" |
165 #include "net/base/net_errors.h" | 171 #include "net/base/net_errors.h" |
166 #include "net/base/net_util.h" | 172 #include "net/base/net_util.h" |
167 #include "net/base/url_util.h" | 173 #include "net/base/url_util.h" |
168 #include "net/http/http_stream_factory.h" | 174 #include "net/http/http_stream_factory.h" |
169 #include "net/ssl/ssl_config.h" | 175 #include "net/ssl/ssl_config.h" |
170 #include "net/ssl/ssl_config_service.h" | 176 #include "net/ssl/ssl_config_service.h" |
171 #include "net/test/embedded_test_server/embedded_test_server.h" | 177 #include "net/test/embedded_test_server/embedded_test_server.h" |
172 #include "net/test/url_request/url_request_failed_job.h" | 178 #include "net/test/url_request/url_request_failed_job.h" |
173 #include "net/test/url_request/url_request_mock_http_job.h" | 179 #include "net/test/url_request/url_request_mock_http_job.h" |
174 #include "net/url_request/url_request.h" | 180 #include "net/url_request/url_request.h" |
(...skipping 3472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3647 this)); | 3653 this)); |
3648 | 3654 |
3649 base::MessageLoop::current()->Run(); | 3655 base::MessageLoop::current()->Run(); |
3650 } | 3656 } |
3651 } | 3657 } |
3652 | 3658 |
3653 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, | 3659 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, |
3654 MediaStreamDevicesControllerBrowserTest, | 3660 MediaStreamDevicesControllerBrowserTest, |
3655 testing::Bool()); | 3661 testing::Bool()); |
3656 | 3662 |
| 3663 class OriginTest : public InProcessBrowserTest { |
| 3664 void SetUpOnMainThread() override { |
| 3665 ASSERT_TRUE(embedded_test_server()->Start()); |
| 3666 } |
| 3667 }; |
| 3668 IN_PROC_BROWSER_TEST_F(OriginTest, CanNavigate) { |
| 3669 ui_test_utils::NavigateToURL( |
| 3670 browser(), |
| 3671 embedded_test_server()->GetURL("localhost", "/simple_page.html")); |
| 3672 content::WebContents* web_contents = |
| 3673 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3674 |
| 3675 ASSERT_EQ("http://localhost:33158", |
| 3676 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize()); |
| 3677 } |
| 3678 |
| 3679 class WebBluetoothPolicyTest : public PolicyTest { |
| 3680 void SetUpOnMainThread() override { |
| 3681 PolicyTest::SetUpOnMainThread(); |
| 3682 ASSERT_TRUE(embedded_test_server()->Start()); |
| 3683 } |
| 3684 }; |
| 3685 |
| 3686 class WaitForRequestDeviceMessage : public IPC::Listener { |
| 3687 public: |
| 3688 explicit WaitForRequestDeviceMessage( |
| 3689 scoped_refptr<content::MessageLoopRunner> runner) |
| 3690 : runner_(runner) {} |
| 3691 |
| 3692 bool OnMessageReceived(const IPC::Message& msg) override { |
| 3693 if (msg.type() == BluetoothMsg_RequestDeviceError::ID || |
| 3694 msg.type() == BluetoothMsg_RequestDeviceSuccess::ID) { |
| 3695 BrowserThread::PostTask( |
| 3696 BrowserThread::UI, FROM_HERE, |
| 3697 base::Bind(&content::MessageLoopRunner::Quit, runner_)); |
| 3698 } |
| 3699 return false; // Store the message in the sink. |
| 3700 } |
| 3701 |
| 3702 private: |
| 3703 scoped_refptr<content::MessageLoopRunner> runner_; |
| 3704 }; |
| 3705 |
| 3706 IN_PROC_BROWSER_TEST_F(WebBluetoothPolicyTest, Block) { |
| 3707 PolicyMap policies; |
| 3708 policies.Set(key::kDefaultWebBluetoothGuardSetting, POLICY_LEVEL_MANDATORY, |
| 3709 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3710 new base::FundamentalValue(2), nullptr); |
| 3711 UpdateProviderPolicy(policies); |
| 3712 |
| 3713 ui_test_utils::NavigateToURL( |
| 3714 browser(), |
| 3715 embedded_test_server()->GetURL("localhost", "/simple_page.html")); |
| 3716 content::WebContents* web_contents = |
| 3717 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3718 ASSERT_THAT( |
| 3719 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize(), |
| 3720 testing::StartsWith("http://localhost:")); |
| 3721 |
| 3722 IPC::TestSink sink; |
| 3723 scoped_refptr<content::BluetoothDispatcherHost> bluetooth = |
| 3724 new content::BluetoothDispatcherHost( |
| 3725 web_contents->GetRenderProcessHost()->GetID()); |
| 3726 bluetooth->GetFilter()->OnFilterAdded(&sink); |
| 3727 |
| 3728 scoped_refptr<device::MockBluetoothAdapter> adapter = |
| 3729 new testing::NiceMock<device::MockBluetoothAdapter>; |
| 3730 EXPECT_CALL(*adapter, IsPresent()).WillRepeatedly(testing::Return(true)); |
| 3731 bluetooth->SetBluetoothAdapterForTesting(adapter); |
| 3732 |
| 3733 std::vector<content::BluetoothScanFilter> scan_filters; |
| 3734 content::BluetoothScanFilter scan_filter; |
| 3735 scan_filter.name = "Hello"; |
| 3736 scan_filters.push_back(scan_filter); |
| 3737 |
| 3738 scoped_refptr<content::MessageLoopRunner> request_device_runner = |
| 3739 new content::MessageLoopRunner; |
| 3740 WaitForRequestDeviceMessage waiter(request_device_runner); |
| 3741 sink.AddFilter(&waiter); |
| 3742 |
| 3743 bluetooth->OnMessageReceived(BluetoothHostMsg_RequestDevice( |
| 3744 1, 1, web_contents->GetMainFrame()->GetRoutingID(), scan_filters, |
| 3745 std::vector<device::BluetoothUUID>())); |
| 3746 |
| 3747 request_device_runner->Run(); |
| 3748 |
| 3749 // Make sure no more IPCs arrive in the TestSink. |
| 3750 web_contents = nullptr; |
| 3751 browser()->tab_strip_model()->CloseAllTabs(); |
| 3752 |
| 3753 const IPC::Message* response_msg = |
| 3754 sink.GetUniqueMessageMatching(BluetoothMsg_RequestDeviceError::ID); |
| 3755 ASSERT_TRUE(response_msg); |
| 3756 BluetoothMsg_RequestDeviceError::Param response; |
| 3757 BluetoothMsg_RequestDeviceError::Read(response_msg, &response); |
| 3758 EXPECT_EQ(blink::WebBluetoothError::ChooserDisabled, base::get<2>(response)); |
| 3759 |
| 3760 bluetooth->SetBluetoothAdapterForTesting(nullptr); |
| 3761 } |
| 3762 |
3657 // Test that when extended reporting opt-in is disabled by policy, the | 3763 // Test that when extended reporting opt-in is disabled by policy, the |
3658 // opt-in checkbox does not appear on SSL blocking pages. | 3764 // opt-in checkbox does not appear on SSL blocking pages. |
3659 IN_PROC_BROWSER_TEST_F(PolicyTest, SafeBrowsingExtendedReportingOptInAllowed) { | 3765 IN_PROC_BROWSER_TEST_F(PolicyTest, SafeBrowsingExtendedReportingOptInAllowed) { |
3660 net::EmbeddedTestServer https_server_expired( | 3766 net::EmbeddedTestServer https_server_expired( |
3661 net::EmbeddedTestServer::TYPE_HTTPS); | 3767 net::EmbeddedTestServer::TYPE_HTTPS); |
3662 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); | 3768 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
3663 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); | 3769 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
3664 ASSERT_TRUE(https_server_expired.Start()); | 3770 ASSERT_TRUE(https_server_expired.Start()); |
3665 | 3771 |
3666 // Set the enterprise policy to disallow opt-in. | 3772 // Set the enterprise policy to disallow opt-in. |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3938 POLICY_SCOPE_USER, | 4044 POLICY_SCOPE_USER, |
3939 POLICY_SOURCE_CLOUD, | 4045 POLICY_SOURCE_CLOUD, |
3940 new base::FundamentalValue(false), | 4046 new base::FundamentalValue(false), |
3941 NULL); | 4047 NULL); |
3942 UpdateProviderPolicy(policies); | 4048 UpdateProviderPolicy(policies); |
3943 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 4049 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
3944 } | 4050 } |
3945 #endif // defined(OS_CHROMEOS) | 4051 #endif // defined(OS_CHROMEOS) |
3946 | 4052 |
3947 } // namespace policy | 4053 } // namespace policy |
OLD | NEW |