Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 #include "content/public/test/browser_test_utils.h" | 99 #include "content/public/test/browser_test_utils.h" |
| 100 #include "content/public/test/test_navigation_observer.h" | 100 #include "content/public/test/test_navigation_observer.h" |
| 101 #include "extensions/browser/extension_registry.h" | 101 #include "extensions/browser/extension_registry.h" |
| 102 #include "extensions/browser/extension_system.h" | 102 #include "extensions/browser/extension_system.h" |
| 103 #include "extensions/browser/uninstall_reason.h" | 103 #include "extensions/browser/uninstall_reason.h" |
| 104 #include "extensions/common/constants.h" | 104 #include "extensions/common/constants.h" |
| 105 #include "extensions/common/extension.h" | 105 #include "extensions/common/extension.h" |
| 106 #include "extensions/common/extension_set.h" | 106 #include "extensions/common/extension_set.h" |
| 107 #include "net/base/net_errors.h" | 107 #include "net/base/net_errors.h" |
| 108 #include "net/dns/mock_host_resolver.h" | 108 #include "net/dns/mock_host_resolver.h" |
| 109 #include "net/ssl/ssl_connection_status_flags.h" | 109 #include "net/ssl/ssl_connection_status_flags.h" |
|
msw
2016/04/18 22:09:06
nit: remove
| |
| 110 #include "net/test/embedded_test_server/embedded_test_server.h" | 110 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 111 #include "net/test/embedded_test_server/request_handler_util.h" | 111 #include "net/test/embedded_test_server/request_handler_util.h" |
| 112 #include "net/test/spawned_test_server/spawned_test_server.h" | 112 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 113 #include "net/test/url_request/url_request_mock_http_job.h" | 113 #include "net/test/url_request/url_request_mock_http_job.h" |
| 114 #include "net/url_request/url_request_filter.h" | 114 #include "net/url_request/url_request_filter.h" |
| 115 #include "net/url_request/url_request_test_util.h" | 115 #include "net/url_request/url_request_test_util.h" |
| 116 #include "ui/base/l10n/l10n_util.h" | 116 #include "ui/base/l10n/l10n_util.h" |
| 117 #include "ui/base/page_transition_types.h" | 117 #include "ui/base/page_transition_types.h" |
| 118 | 118 |
| 119 #if defined(OS_MACOSX) | 119 #if defined(OS_MACOSX) |
| (...skipping 2967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3087 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 3087 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
| 3088 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 3088 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 3089 VALID_CERTIFICATE, browser()); | 3089 VALID_CERTIFICATE, browser()); |
| 3090 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3090 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 3091 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3091 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 3092 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3092 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 3093 } | 3093 } |
| 3094 | 3094 |
| 3095 namespace { | 3095 namespace { |
| 3096 | 3096 |
| 3097 // A URLRequestMockHTTPJob that mocks an SSL connection with an | |
| 3098 // obsolete protocol version. | |
| 3099 class URLRequestNonsecureConnection : public net::URLRequestMockHTTPJob { | |
| 3100 public: | |
| 3101 void GetResponseInfo(net::HttpResponseInfo* info) override { | |
| 3102 info->ssl_info.connection_status = (net::SSL_CONNECTION_VERSION_TLS1_1 | |
| 3103 << net::SSL_CONNECTION_VERSION_SHIFT); | |
| 3104 // TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 from | |
| 3105 // http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-par ameters-4 | |
| 3106 const uint16_t ciphersuite = 0xc02f; | |
| 3107 net::SSLConnectionStatusSetCipherSuite(ciphersuite, | |
| 3108 &info->ssl_info.connection_status); | |
| 3109 } | |
| 3110 | |
| 3111 protected: | |
| 3112 ~URLRequestNonsecureConnection() override {} | |
| 3113 | |
| 3114 private: | |
| 3115 DISALLOW_COPY_AND_ASSIGN(URLRequestNonsecureConnection); | |
| 3116 }; | |
| 3117 | |
| 3118 class BrowserTestNonsecureURLRequest : public BrowserTest { | 3097 class BrowserTestNonsecureURLRequest : public BrowserTest { |
| 3119 public: | 3098 public: |
| 3120 BrowserTestNonsecureURLRequest() : BrowserTest() {} | 3099 BrowserTestNonsecureURLRequest() : BrowserTest() {} |
| 3121 void SetUpOnMainThread() override { | 3100 void SetUpOnMainThread() override { |
| 3122 base::FilePath root_http; | 3101 base::FilePath root_http; |
| 3123 PathService::Get(chrome::DIR_TEST_DATA, &root_http); | 3102 PathService::Get(chrome::DIR_TEST_DATA, &root_http); |
| 3124 content::BrowserThread::PostTask( | 3103 content::BrowserThread::PostTask( |
| 3125 content::BrowserThread::IO, FROM_HERE, | 3104 content::BrowserThread::IO, FROM_HERE, |
| 3126 base::Bind( | 3105 base::Bind( |
| 3127 &URLRequestNonsecureConnection::AddUrlHandlers, root_http, | 3106 &net::URLRequestMockHTTPJob::AddUrlHandlers, root_http, |
| 3128 make_scoped_refptr(content::BrowserThread::GetBlockingPool()))); | 3107 make_scoped_refptr(content::BrowserThread::GetBlockingPool()))); |
| 3129 } | 3108 } |
| 3130 | 3109 |
| 3131 private: | 3110 private: |
| 3132 DISALLOW_COPY_AND_ASSIGN(BrowserTestNonsecureURLRequest); | 3111 DISALLOW_COPY_AND_ASSIGN(BrowserTestNonsecureURLRequest); |
| 3133 }; | 3112 }; |
| 3134 | 3113 |
| 3135 } // namespace | 3114 } // namespace |
| 3136 | 3115 |
| 3137 // Tests that a nonsecure connection does not get a secure connection | 3116 // Tests that a nonsecure connection does not get a secure connection |
| 3138 // explanation. | 3117 // explanation. |
| 3139 IN_PROC_BROWSER_TEST_F(BrowserTestNonsecureURLRequest, | 3118 IN_PROC_BROWSER_TEST_F(BrowserTestNonsecureURLRequest, |
| 3140 SecurityStyleChangedObserverNonsecureConnection) { | 3119 SecurityStyleChangedObserverNonsecureConnection) { |
| 3141 content::WebContents* web_contents = | 3120 content::WebContents* web_contents = |
| 3142 browser()->tab_strip_model()->GetActiveWebContents(); | 3121 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3143 SecurityStyleTestObserver observer(web_contents); | 3122 SecurityStyleTestObserver observer(web_contents); |
| 3144 | 3123 |
| 3145 ui_test_utils::NavigateToURL( | 3124 ui_test_utils::NavigateToURL( |
| 3146 browser(), URLRequestNonsecureConnection::GetMockHttpsUrl(std::string())); | 3125 browser(), net::URLRequestMockHTTPJob::GetMockHttpsUrl(std::string())); |
| 3147 for (const auto& explanation : | 3126 for (const auto& explanation : |
| 3148 observer.latest_explanations().secure_explanations) { | 3127 observer.latest_explanations().secure_explanations) { |
| 3149 EXPECT_NE(l10n_util::GetStringUTF8(IDS_SECURE_PROTOCOL_AND_CIPHERSUITE), | 3128 EXPECT_NE(l10n_util::GetStringUTF8(IDS_SECURE_PROTOCOL_AND_CIPHERSUITE), |
| 3150 explanation.summary); | 3129 explanation.summary); |
| 3151 } | 3130 } |
| 3152 } | 3131 } |
| 3153 | 3132 |
| 3154 namespace { | 3133 namespace { |
| 3155 class JSBooleanResultGetter { | 3134 class JSBooleanResultGetter { |
| 3156 public: | 3135 public: |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3299 Browser* browser = new Browser(params); | 3278 Browser* browser = new Browser(params); |
| 3300 gfx::Rect bounds = browser->window()->GetBounds(); | 3279 gfx::Rect bounds = browser->window()->GetBounds(); |
| 3301 | 3280 |
| 3302 // Should be EXPECT_EQ, but this width is inconsistent across platforms. | 3281 // Should be EXPECT_EQ, but this width is inconsistent across platforms. |
| 3303 // See https://crbug.com/567925. | 3282 // See https://crbug.com/567925. |
| 3304 EXPECT_GE(bounds.width(), 100); | 3283 EXPECT_GE(bounds.width(), 100); |
| 3305 EXPECT_EQ(122, bounds.height()); | 3284 EXPECT_EQ(122, bounds.height()); |
| 3306 browser->window()->Close(); | 3285 browser->window()->Close(); |
| 3307 } | 3286 } |
| 3308 } | 3287 } |
| OLD | NEW |