Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "extensions/browser/api/web_request/web_request_event_details.h" | 5 #include "extensions/browser/api/web_request/web_request_event_details.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
| 11 #include "content/public/browser/resource_request_info.h" | 11 #include "content/public/browser/resource_request_info.h" |
| 12 #include "content/public/common/child_process_host.h" | 12 #include "content/public/common/child_process_host.h" |
| 13 #include "extensions/browser/api/web_request/upload_data_presenter.h" | 13 #include "extensions/browser/api/web_request/upload_data_presenter.h" |
| 14 #include "extensions/browser/api/web_request/web_request_api_constants.h" | 14 #include "extensions/browser/api/web_request/web_request_api_constants.h" |
| 15 #include "extensions/browser/api/web_request/web_request_api_helpers.h" | 15 #include "extensions/browser/api/web_request/web_request_api_helpers.h" |
| 16 #include "ipc/ipc_message.h" | 16 #include "ipc/ipc_message.h" |
| 17 #include "net/base/auth.h" | 17 #include "net/base/auth.h" |
| 18 #include "net/base/upload_data_stream.h" | 18 #include "net/base/upload_data_stream.h" |
| 19 #include "net/http/http_request_headers.h" | 19 #include "net/http/http_request_headers.h" |
| 20 #include "net/http/http_response_headers.h" | 20 #include "net/http/http_response_headers.h" |
| 21 #include "net/ssl/ssl_cipher_suite_names.h" | |
| 22 #include "net/ssl/ssl_connection_status_flags.h" | |
| 21 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
| 24 #include "third_party/boringssl/src/include/openssl/ssl.h" | |
| 22 | 25 |
| 23 using extension_web_request_api_helpers::ExtraInfoSpec; | 26 using extension_web_request_api_helpers::ExtraInfoSpec; |
| 24 | 27 |
| 25 namespace helpers = extension_web_request_api_helpers; | 28 namespace helpers = extension_web_request_api_helpers; |
| 26 namespace keys = extension_web_request_api_constants; | 29 namespace keys = extension_web_request_api_constants; |
| 27 | 30 |
| 28 namespace extensions { | 31 namespace extensions { |
| 29 | 32 |
| 30 WebRequestEventDetails::WebRequestEventDetails(const net::URLRequest* request, | 33 WebRequestEventDetails::WebRequestEventDetails(const net::URLRequest* request, |
| 31 int extra_info_spec) | 34 int extra_info_spec) |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 : extra_info_spec_(0), render_process_id_(0), render_frame_id_(0) {} | 232 : extra_info_spec_(0), render_process_id_(0), render_frame_id_(0) {} |
| 230 | 233 |
| 231 void WebRequestEventDetails::OnDeterminedFrameData( | 234 void WebRequestEventDetails::OnDeterminedFrameData( |
| 232 std::unique_ptr<WebRequestEventDetails> self, | 235 std::unique_ptr<WebRequestEventDetails> self, |
| 233 const DeterminedFrameDataCallback& callback, | 236 const DeterminedFrameDataCallback& callback, |
| 234 const ExtensionApiFrameIdMap::FrameData& frame_data) { | 237 const ExtensionApiFrameIdMap::FrameData& frame_data) { |
| 235 SetFrameData(frame_data); | 238 SetFrameData(frame_data); |
| 236 callback.Run(std::move(self)); | 239 callback.Run(std::move(self)); |
| 237 } | 240 } |
| 238 | 241 |
| 242 void WebRequestEventDetails::SetSSLInfo(const net::URLRequest* request) { | |
| 243 const net::SSLInfo ssl_info = request->ssl_info(); | |
| 244 base::DictionaryValue* info_dict = new base::DictionaryValue(); | |
| 245 | |
| 246 const char* ssl_version; | |
| 247 net::SSLVersionToString(&ssl_version, net::SSLConnectionStatusToVersion( | |
| 248 ssl_info.connection_status)); | |
| 249 if (strncmp(ssl_version, "?", 1) == 0) | |
| 250 ssl_version = "UNKNOWN"; | |
| 251 info_dict->SetString(keys::kSSLVersionKey, ssl_version); | |
| 252 | |
| 253 const SSL_CIPHER* cipher = SSL_get_cipher_by_value( | |
| 254 net::SSLConnectionStatusToCipherSuite(ssl_info.connection_status)); | |
| 255 char* cipher_name = SSL_CIPHER_get_rfc_name(cipher); | |
| 256 if (cipher_name) { | |
| 257 std::string rfc_name = std::string(cipher_name); | |
| 258 OPENSSL_free(cipher_name); | |
| 259 info_dict->SetString(keys::kCipherSuiteKey, rfc_name); | |
| 260 } | |
| 261 | |
| 262 base::DictionaryValue* built_dict = new base::DictionaryValue(); | |
| 263 built_dict->SetBoolean(keys::kCertificateIssuedByKnownRootKey, | |
| 264 ssl_info.is_issued_by_known_root); | |
|
Ryan Sleevi
2017/01/31 21:37:56
I'm very concerned about exposing this (or any oth
| |
| 265 built_dict->Set(keys::kChainKey, | |
| 266 helpers::ExtractCertificateChain(ssl_info.cert)); | |
| 267 | |
| 268 built_dict->SetBoolean( | |
| 269 keys::kCertificateValidKey, | |
| 270 ssl_info.is_valid() && !net::IsCertStatusError(ssl_info.cert_status)); | |
|
Ryan Sleevi
2017/01/31 21:37:56
I'm uncomfortable with us surfacing this as if it
| |
| 271 if (net::IsCertStatusError(ssl_info.cert_status)) { | |
| 272 std::string error = net::ErrorToShortString( | |
| 273 net::MapCertStatusToNetError(ssl_info.cert_status)); | |
| 274 built_dict->SetString(keys::kErrorKey, error); | |
|
Ryan Sleevi
2017/01/31 21:37:56
This is an explicit non-goal; we do not want the e
| |
| 275 } | |
| 276 | |
| 277 built_dict->SetBoolean(keys::kEVCertificateKey, | |
| 278 (ssl_info.cert_status & net::CERT_STATUS_IS_EV)); | |
|
Ryan Sleevi
2017/01/31 21:37:56
Can you explain why this is necessary? This repres
| |
| 279 | |
| 280 info_dict->Set(keys::kBuiltChainKey, built_dict); | |
| 281 info_dict->Set(keys::kSentChainKey, | |
| 282 helpers::ExtractCertificateChain(ssl_info.unverified_cert)); | |
| 283 | |
| 284 dict_.Set(keys::kSSLInfoKey, info_dict); | |
| 285 } | |
| 286 | |
| 239 } // namespace extensions | 287 } // namespace extensions |
| OLD | NEW |