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 | |
mef
2015/11/02 17:56:56
nit: I believe (although I can't find proof ATM) t
kapishnikov
2015/11/02 22:45:49
Done.
| |
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 (auto hash_itr = hpkp.pin_hashes.begin(); | |
384 hash_itr != hpkp.pin_hashes.end(); ++hash_itr) { | |
385 const std::string& pin_hash = **hash_itr; | |
mef
2015/11/02 17:56:56
I think you can just inline this.
kapishnikov
2015/11/02 22:45:49
Done.
| |
386 auto hashValue = net::HashValue(net::HASH_VALUE_SHA256); | |
mef
2015/11/02 17:56:56
no camelCase for local variables.
kapishnikov
2015/11/02 22:45:49
Done.
| |
387 bool good_hash = hashValue.FromString(pin_hash); | |
388 if (good_hash) { | |
389 hash_value_vector.push_back(hashValue); | |
390 } else { | |
391 LOG(WARNING) << "Unable to add hash value " << pin_hash; | |
392 } | |
393 } | |
394 | |
395 // Add the host pinning | |
396 context_->transport_security_state()->AddHPKP(hpkp.host, base::Time::Max(), | |
397 hpkp.include_subdomains, | |
398 hash_value_vector, GURL()); | |
399 } | |
400 | |
375 JNIEnv* env = base::android::AttachCurrentThread(); | 401 JNIEnv* env = base::android::AttachCurrentThread(); |
376 jcronet_url_request_context_.Reset(env, jcronet_url_request_context.obj()); | 402 jcronet_url_request_context_.Reset(env, jcronet_url_request_context.obj()); |
377 Java_CronetUrlRequestContext_initNetworkThread( | 403 Java_CronetUrlRequestContext_initNetworkThread( |
378 env, jcronet_url_request_context.obj()); | 404 env, jcronet_url_request_context.obj()); |
379 | 405 |
380 #if defined(DATA_REDUCTION_PROXY_SUPPORT) | 406 #if defined(DATA_REDUCTION_PROXY_SUPPORT) |
381 if (data_reduction_proxy_) | 407 if (data_reduction_proxy_) |
382 data_reduction_proxy_->Init(true, GetURLRequestContext()); | 408 data_reduction_proxy_->Init(true, GetURLRequestContext()); |
383 #endif | 409 #endif |
384 is_context_initialized_ = true; | 410 is_context_initialized_ = true; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 static jint SetMinLogLevel(JNIEnv* env, | 558 static jint SetMinLogLevel(JNIEnv* env, |
533 const JavaParamRef<jclass>& jcaller, | 559 const JavaParamRef<jclass>& jcaller, |
534 jint jlog_level) { | 560 jint jlog_level) { |
535 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); | 561 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); |
536 // MinLogLevel is global, shared by all URLRequestContexts. | 562 // MinLogLevel is global, shared by all URLRequestContexts. |
537 logging::SetMinLogLevel(static_cast<int>(jlog_level)); | 563 logging::SetMinLogLevel(static_cast<int>(jlog_level)); |
538 return old_log_level; | 564 return old_log_level; |
539 } | 565 } |
540 | 566 |
541 } // namespace cronet | 567 } // namespace cronet |
OLD | NEW |