| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 } | 679 } |
| 680 | 680 |
| 681 // Iterate through PKP configuration for every host. | 681 // Iterate through PKP configuration for every host. |
| 682 for (const auto& pkp : config->pkp_list) { | 682 for (const auto& pkp : config->pkp_list) { |
| 683 // Add the host pinning. | 683 // Add the host pinning. |
| 684 context_->transport_security_state()->AddHPKP( | 684 context_->transport_security_state()->AddHPKP( |
| 685 pkp->host, pkp->expiration_date, pkp->include_subdomains, | 685 pkp->host, pkp->expiration_date, pkp->include_subdomains, |
| 686 pkp->pin_hashes, GURL::EmptyGURL()); | 686 pkp->pin_hashes, GURL::EmptyGURL()); |
| 687 } | 687 } |
| 688 | 688 |
| 689 context_->transport_security_state() |
| 690 ->SetEnablePublicKeyPinningBypassForLocalTrustAnchors( |
| 691 config->bypass_public_key_pinning_for_local_trust_anchors); |
| 692 |
| 689 JNIEnv* env = base::android::AttachCurrentThread(); | 693 JNIEnv* env = base::android::AttachCurrentThread(); |
| 690 jcronet_url_request_context_.Reset(env, jcronet_url_request_context.obj()); | 694 jcronet_url_request_context_.Reset(env, jcronet_url_request_context.obj()); |
| 691 Java_CronetUrlRequestContext_initNetworkThread( | 695 Java_CronetUrlRequestContext_initNetworkThread( |
| 692 env, jcronet_url_request_context.obj()); | 696 env, jcronet_url_request_context.obj()); |
| 693 | 697 |
| 694 #if defined(DATA_REDUCTION_PROXY_SUPPORT) | 698 #if defined(DATA_REDUCTION_PROXY_SUPPORT) |
| 695 if (data_reduction_proxy_) | 699 if (data_reduction_proxy_) |
| 696 data_reduction_proxy_->Init(true, GetURLRequestContext()); | 700 data_reduction_proxy_->Init(true, GetURLRequestContext()); |
| 697 #endif | 701 #endif |
| 698 is_context_initialized_ = true; | 702 is_context_initialized_ = true; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 jboolean jsdch_enabled, | 837 jboolean jsdch_enabled, |
| 834 const JavaParamRef<jstring>& jdata_reduction_proxy_key, | 838 const JavaParamRef<jstring>& jdata_reduction_proxy_key, |
| 835 const JavaParamRef<jstring>& jdata_reduction_proxy_primary_proxy, | 839 const JavaParamRef<jstring>& jdata_reduction_proxy_primary_proxy, |
| 836 const JavaParamRef<jstring>& jdata_reduction_proxy_fallback_proxy, | 840 const JavaParamRef<jstring>& jdata_reduction_proxy_fallback_proxy, |
| 837 const JavaParamRef<jstring>& jdata_reduction_proxy_secure_proxy_check_url, | 841 const JavaParamRef<jstring>& jdata_reduction_proxy_secure_proxy_check_url, |
| 838 jboolean jdisable_cache, | 842 jboolean jdisable_cache, |
| 839 jint jhttp_cache_mode, | 843 jint jhttp_cache_mode, |
| 840 jlong jhttp_cache_max_size, | 844 jlong jhttp_cache_max_size, |
| 841 const JavaParamRef<jstring>& jexperimental_quic_connection_options, | 845 const JavaParamRef<jstring>& jexperimental_quic_connection_options, |
| 842 jlong jmock_cert_verifier, | 846 jlong jmock_cert_verifier, |
| 843 jboolean jenable_network_quality_estimator) { | 847 jboolean jenable_network_quality_estimator, |
| 848 jboolean jbypass_public_key_pinning_for_local_trust_anchors) { |
| 844 return reinterpret_cast<jlong>(new URLRequestContextConfig( | 849 return reinterpret_cast<jlong>(new URLRequestContextConfig( |
| 845 jquic_enabled, | 850 jquic_enabled, |
| 846 ConvertNullableJavaStringToUTF8(env, jquic_default_user_agent_id), | 851 ConvertNullableJavaStringToUTF8(env, jquic_default_user_agent_id), |
| 847 jhttp2_enabled, jsdch_enabled, | 852 jhttp2_enabled, jsdch_enabled, |
| 848 static_cast<URLRequestContextConfig::HttpCacheType>(jhttp_cache_mode), | 853 static_cast<URLRequestContextConfig::HttpCacheType>(jhttp_cache_mode), |
| 849 jhttp_cache_max_size, jdisable_cache, | 854 jhttp_cache_max_size, jdisable_cache, |
| 850 ConvertNullableJavaStringToUTF8(env, jstorage_path), | 855 ConvertNullableJavaStringToUTF8(env, jstorage_path), |
| 851 ConvertNullableJavaStringToUTF8(env, juser_agent), | 856 ConvertNullableJavaStringToUTF8(env, juser_agent), |
| 852 ConvertNullableJavaStringToUTF8(env, | 857 ConvertNullableJavaStringToUTF8(env, |
| 853 jexperimental_quic_connection_options), | 858 jexperimental_quic_connection_options), |
| 854 ConvertNullableJavaStringToUTF8(env, jdata_reduction_proxy_key), | 859 ConvertNullableJavaStringToUTF8(env, jdata_reduction_proxy_key), |
| 855 ConvertNullableJavaStringToUTF8(env, jdata_reduction_proxy_primary_proxy), | 860 ConvertNullableJavaStringToUTF8(env, jdata_reduction_proxy_primary_proxy), |
| 856 ConvertNullableJavaStringToUTF8(env, | 861 ConvertNullableJavaStringToUTF8(env, |
| 857 jdata_reduction_proxy_fallback_proxy), | 862 jdata_reduction_proxy_fallback_proxy), |
| 858 ConvertNullableJavaStringToUTF8( | 863 ConvertNullableJavaStringToUTF8( |
| 859 env, jdata_reduction_proxy_secure_proxy_check_url), | 864 env, jdata_reduction_proxy_secure_proxy_check_url), |
| 860 base::WrapUnique( | 865 base::WrapUnique( |
| 861 reinterpret_cast<net::CertVerifier*>(jmock_cert_verifier)), | 866 reinterpret_cast<net::CertVerifier*>(jmock_cert_verifier)), |
| 862 jenable_network_quality_estimator)); | 867 jenable_network_quality_estimator, |
| 868 jbypass_public_key_pinning_for_local_trust_anchors)); |
| 863 } | 869 } |
| 864 | 870 |
| 865 // Add a QUIC hint to a URLRequestContextConfig. | 871 // Add a QUIC hint to a URLRequestContextConfig. |
| 866 static void AddQuicHint(JNIEnv* env, | 872 static void AddQuicHint(JNIEnv* env, |
| 867 const JavaParamRef<jclass>& jcaller, | 873 const JavaParamRef<jclass>& jcaller, |
| 868 jlong jurl_request_context_config, | 874 jlong jurl_request_context_config, |
| 869 const JavaParamRef<jstring>& jhost, | 875 const JavaParamRef<jstring>& jhost, |
| 870 jint jport, | 876 jint jport, |
| 871 jint jalternate_port) { | 877 jint jalternate_port) { |
| 872 URLRequestContextConfig* config = | 878 URLRequestContextConfig* config = |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 JNIEnv* env, | 951 JNIEnv* env, |
| 946 const JavaParamRef<jclass>& jcaller) { | 952 const JavaParamRef<jclass>& jcaller) { |
| 947 base::StatisticsRecorder::Initialize(); | 953 base::StatisticsRecorder::Initialize(); |
| 948 std::vector<uint8_t> data; | 954 std::vector<uint8_t> data; |
| 949 if (!HistogramManager::GetInstance()->GetDeltas(&data)) | 955 if (!HistogramManager::GetInstance()->GetDeltas(&data)) |
| 950 return ScopedJavaLocalRef<jbyteArray>(); | 956 return ScopedJavaLocalRef<jbyteArray>(); |
| 951 return base::android::ToJavaByteArray(env, &data[0], data.size()); | 957 return base::android::ToJavaByteArray(env, &data[0], data.size()); |
| 952 } | 958 } |
| 953 | 959 |
| 954 } // namespace cronet | 960 } // namespace cronet |
| OLD | NEW |