OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/cronet/android/cronet_url_request_context_adapter.h" | 5 #include "components/cronet/android/cronet_url_request_context_adapter.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 quic_hint.port); | 365 quic_hint.port); |
366 net::AlternativeService alternative_service( | 366 net::AlternativeService alternative_service( |
367 net::AlternateProtocol::QUIC, "", | 367 net::AlternateProtocol::QUIC, "", |
368 static_cast<uint16>(quic_hint.alternate_port)); | 368 static_cast<uint16>(quic_hint.alternate_port)); |
369 context_->http_server_properties()->SetAlternativeService( | 369 context_->http_server_properties()->SetAlternativeService( |
370 quic_hint_host_port_pair, alternative_service, 1.0f, | 370 quic_hint_host_port_pair, alternative_service, 1.0f, |
371 base::Time::Max()); | 371 base::Time::Max()); |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
| 375 // Iterate through HPKP configuration for every host. |
| 376 for (auto hpkp_itr = config->hpkp_list.begin(); |
| 377 hpkp_itr != config->hpkp_list.end(); ++hpkp_itr) { |
| 378 const URLRequestContextConfig::Hpkp& hpkp = **hpkp_itr; |
| 379 |
| 380 // Convert the vector of hash strings from the config to |
| 381 // a vector of HashValue objects. |
| 382 net::HashValueVector hash_value_vector; |
| 383 for (const auto& hash : hpkp.pin_hashes) { |
| 384 auto hash_value = net::HashValue(net::HASH_VALUE_SHA256); |
| 385 bool good_hash = hash_value.FromString(*hash); |
| 386 if (good_hash) { |
| 387 hash_value_vector.push_back(hash_value); |
| 388 } else { |
| 389 LOG(WARNING) << "Unable to add hash value " << *hash; |
| 390 } |
| 391 } |
| 392 |
| 393 // Add the host pinning. |
| 394 context_->transport_security_state()->AddHPKP(hpkp.host, base::Time::Max(), |
| 395 hpkp.include_subdomains, |
| 396 hash_value_vector, GURL()); |
| 397 } |
| 398 |
375 JNIEnv* env = base::android::AttachCurrentThread(); | 399 JNIEnv* env = base::android::AttachCurrentThread(); |
376 jcronet_url_request_context_.Reset(env, jcronet_url_request_context.obj()); | 400 jcronet_url_request_context_.Reset(env, jcronet_url_request_context.obj()); |
377 Java_CronetUrlRequestContext_initNetworkThread( | 401 Java_CronetUrlRequestContext_initNetworkThread( |
378 env, jcronet_url_request_context.obj()); | 402 env, jcronet_url_request_context.obj()); |
379 | 403 |
380 #if defined(DATA_REDUCTION_PROXY_SUPPORT) | 404 #if defined(DATA_REDUCTION_PROXY_SUPPORT) |
381 if (data_reduction_proxy_) | 405 if (data_reduction_proxy_) |
382 data_reduction_proxy_->Init(true, GetURLRequestContext()); | 406 data_reduction_proxy_->Init(true, GetURLRequestContext()); |
383 #endif | 407 #endif |
384 is_context_initialized_ = true; | 408 is_context_initialized_ = true; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 static jint SetMinLogLevel(JNIEnv* env, | 556 static jint SetMinLogLevel(JNIEnv* env, |
533 const JavaParamRef<jclass>& jcaller, | 557 const JavaParamRef<jclass>& jcaller, |
534 jint jlog_level) { | 558 jint jlog_level) { |
535 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); | 559 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); |
536 // MinLogLevel is global, shared by all URLRequestContexts. | 560 // MinLogLevel is global, shared by all URLRequestContexts. |
537 logging::SetMinLogLevel(static_cast<int>(jlog_level)); | 561 logging::SetMinLogLevel(static_cast<int>(jlog_level)); |
538 return old_log_level; | 562 return old_log_level; |
539 } | 563 } |
540 | 564 |
541 } // namespace cronet | 565 } // namespace cronet |
OLD | NEW |