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 <stdint.h> | 5 #include <stdint.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "content/browser/frame_host/interstitial_page_impl.h" | 13 #include "content/browser/frame_host/interstitial_page_impl.h" |
14 #include "content/browser/frame_host/navigation_entry_impl.h" | 14 #include "content/browser/frame_host/navigation_entry_impl.h" |
15 #include "content/browser/frame_host/render_frame_host_impl.h" | 15 #include "content/browser/frame_host/render_frame_host_impl.h" |
16 #include "content/browser/frame_host/render_frame_proxy_host.h" | 16 #include "content/browser/frame_host/render_frame_proxy_host.h" |
17 #include "content/browser/media/audio_stream_monitor.h" | 17 #include "content/browser/media/audio_stream_monitor.h" |
18 #include "content/browser/media/media_web_contents_observer.h" | 18 #include "content/browser/media/media_web_contents_observer.h" |
19 #include "content/browser/renderer_host/render_view_host_impl.h" | 19 #include "content/browser/renderer_host/render_view_host_impl.h" |
20 #include "content/browser/site_instance_impl.h" | 20 #include "content/browser/site_instance_impl.h" |
21 #include "content/browser/ssl/ssl_policy.h" | |
22 #include "content/browser/webui/content_web_ui_controller_factory.h" | 21 #include "content/browser/webui/content_web_ui_controller_factory.h" |
23 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 22 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
24 #include "content/common/frame_messages.h" | 23 #include "content/common/frame_messages.h" |
25 #include "content/common/input/synthetic_web_input_event_builders.h" | 24 #include "content/common/input/synthetic_web_input_event_builders.h" |
26 #include "content/common/media/media_player_delegate_messages.h" | 25 #include "content/common/media/media_player_delegate_messages.h" |
| 26 #include "content/common/security_style_util.h" |
27 #include "content/common/site_isolation_policy.h" | 27 #include "content/common/site_isolation_policy.h" |
28 #include "content/common/view_messages.h" | 28 #include "content/common/view_messages.h" |
| 29 #include "content/public/browser/content_browser_client.h" |
29 #include "content/public/browser/global_request_id.h" | 30 #include "content/public/browser/global_request_id.h" |
30 #include "content/public/browser/interstitial_page_delegate.h" | 31 #include "content/public/browser/interstitial_page_delegate.h" |
31 #include "content/public/browser/javascript_dialog_manager.h" | 32 #include "content/public/browser/javascript_dialog_manager.h" |
32 #include "content/public/browser/navigation_details.h" | 33 #include "content/public/browser/navigation_details.h" |
33 #include "content/public/browser/notification_details.h" | 34 #include "content/public/browser/notification_details.h" |
34 #include "content/public/browser/notification_source.h" | 35 #include "content/public/browser/notification_source.h" |
35 #include "content/public/browser/render_widget_host_view.h" | 36 #include "content/public/browser/render_widget_host_view.h" |
| 37 #include "content/public/browser/resource_request_details.h" |
| 38 #include "content/public/browser/ssl_host_state_delegate.h" |
36 #include "content/public/browser/storage_partition.h" | 39 #include "content/public/browser/storage_partition.h" |
37 #include "content/public/browser/web_contents_delegate.h" | 40 #include "content/public/browser/web_contents_delegate.h" |
38 #include "content/public/browser/web_contents_observer.h" | 41 #include "content/public/browser/web_contents_observer.h" |
39 #include "content/public/browser/web_ui_controller.h" | 42 #include "content/public/browser/web_ui_controller.h" |
40 #include "content/public/common/bindings_policy.h" | 43 #include "content/public/common/bindings_policy.h" |
41 #include "content/public/common/browser_side_navigation_policy.h" | 44 #include "content/public/common/browser_side_navigation_policy.h" |
42 #include "content/public/common/content_constants.h" | 45 #include "content/public/common/content_constants.h" |
43 #include "content/public/common/url_constants.h" | 46 #include "content/public/common/url_constants.h" |
44 #include "content/public/test/mock_render_process_host.h" | 47 #include "content/public/test/mock_render_process_host.h" |
45 #include "content/public/test/test_browser_context.h" | 48 #include "content/public/test/test_browser_context.h" |
(...skipping 3324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3370 | 3373 |
3371 // Test that if a resource is loaded with empty security info, the SSLManager | 3374 // Test that if a resource is loaded with empty security info, the SSLManager |
3372 // does not mistakenly think it has seen a good certificate and thus forget any | 3375 // does not mistakenly think it has seen a good certificate and thus forget any |
3373 // user exceptions for that host. See https://crbug.com/516808. | 3376 // user exceptions for that host. See https://crbug.com/516808. |
3374 TEST_F(WebContentsImplTest, LoadResourceWithEmptySecurityInfo) { | 3377 TEST_F(WebContentsImplTest, LoadResourceWithEmptySecurityInfo) { |
3375 WebContentsImplTestBrowserClient browser_client; | 3378 WebContentsImplTestBrowserClient browser_client; |
3376 SetBrowserClientForTesting(&browser_client); | 3379 SetBrowserClientForTesting(&browser_client); |
3377 | 3380 |
3378 scoped_refptr<net::X509Certificate> cert = | 3381 scoped_refptr<net::X509Certificate> cert = |
3379 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); | 3382 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); |
3380 SSLPolicyBackend* backend = contents()->controller_.ssl_manager()->backend(); | |
3381 const GURL test_url("https://example.test"); | 3383 const GURL test_url("https://example.test"); |
3382 | 3384 |
3383 backend->AllowCertForHost(*cert, test_url.host(), 1); | 3385 SSLHostStateDelegate* state_delegate = |
3384 EXPECT_TRUE(backend->HasAllowException(test_url.host())); | 3386 contents()->controller_.GetBrowserContext()->GetSSLHostStateDelegate(); |
| 3387 ASSERT_TRUE(state_delegate); |
| 3388 state_delegate->AllowCert(test_url.host(), *cert.get(), 1); |
| 3389 EXPECT_TRUE(state_delegate->HasAllowException(test_url.host())); |
| 3390 contents()->controller_.ssl_manager()->DidStartResourceResponse(test_url, |
| 3391 false, 0); |
3385 | 3392 |
3386 contents()->controller_.ssl_manager()->policy()->OnRequestStarted( | 3393 EXPECT_TRUE(state_delegate->HasAllowException(test_url.host())); |
3387 test_url, 0, 0); | |
3388 | |
3389 EXPECT_TRUE(backend->HasAllowException(test_url.host())); | |
3390 | 3394 |
3391 DeleteContents(); | 3395 DeleteContents(); |
3392 } | 3396 } |
3393 | 3397 |
3394 namespace { | 3398 namespace { |
3395 | 3399 |
3396 class TestJavaScriptDialogManager : public JavaScriptDialogManager { | 3400 class TestJavaScriptDialogManager : public JavaScriptDialogManager { |
3397 public: | 3401 public: |
3398 TestJavaScriptDialogManager() {} | 3402 TestJavaScriptDialogManager() {} |
3399 ~TestJavaScriptDialogManager() override {} | 3403 ~TestJavaScriptDialogManager() override {} |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3447 // An automatic navigation. | 3451 // An automatic navigation. |
3448 main_test_rfh()->SendNavigateWithModificationCallback( | 3452 main_test_rfh()->SendNavigateWithModificationCallback( |
3449 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); | 3453 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); |
3450 | 3454 |
3451 EXPECT_EQ(1u, dialog_manager.reset_count()); | 3455 EXPECT_EQ(1u, dialog_manager.reset_count()); |
3452 | 3456 |
3453 contents()->SetJavaScriptDialogManagerForTesting(nullptr); | 3457 contents()->SetJavaScriptDialogManagerForTesting(nullptr); |
3454 } | 3458 } |
3455 | 3459 |
3456 } // namespace content | 3460 } // namespace content |
OLD | NEW |