| 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 "android_webview/native/aw_contents_statics.h" | 5 #include "android_webview/native/aw_contents_statics.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
| 8 #include "android_webview/browser/net/aw_url_request_context_getter.h" | 8 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
| 9 #include "android_webview/common/aw_crash_handler.h" | 9 #include "android_webview/common/aw_crash_handler.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth
_request_handler.h" | 13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ
est_options.h" |
| 14 #include "content/public/browser/android/synchronous_compositor.h" | 14 #include "content/public/browser/android/synchronous_compositor.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
| 17 #include "jni/AwContentsStatics_jni.h" | 17 #include "jni/AwContentsStatics_jni.h" |
| 18 #include "net/cert/cert_database.h" | 18 #include "net/cert/cert_database.h" |
| 19 | 19 |
| 20 using base::android::AttachCurrentThread; | 20 using base::android::AttachCurrentThread; |
| 21 using base::android::ConvertJavaStringToUTF8; | 21 using base::android::ConvertJavaStringToUTF8; |
| 22 using base::android::ScopedJavaGlobalRef; | 22 using base::android::ScopedJavaGlobalRef; |
| 23 using content::BrowserThread; | 23 using content::BrowserThread; |
| 24 using data_reduction_proxy::DataReductionProxyAuthRequestHandler; | |
| 25 | 24 |
| 26 namespace android_webview { | 25 namespace android_webview { |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| 30 void ClientCertificatesCleared(ScopedJavaGlobalRef<jobject>* callback) { | 29 void ClientCertificatesCleared(ScopedJavaGlobalRef<jobject>* callback) { |
| 31 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 30 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 32 JNIEnv* env = AttachCurrentThread(); | 31 JNIEnv* env = AttachCurrentThread(); |
| 33 Java_AwContentsStatics_clientCertificatesCleared(env, callback->obj()); | 32 Java_AwContentsStatics_clientCertificatesCleared(env, callback->obj()); |
| 34 } | 33 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 53 } | 52 } |
| 54 | 53 |
| 55 // static | 54 // static |
| 56 void SetDataReductionProxyKey(JNIEnv* env, jclass, jstring key) { | 55 void SetDataReductionProxyKey(JNIEnv* env, jclass, jstring key) { |
| 57 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); | 56 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); |
| 58 DCHECK(browser_context); | 57 DCHECK(browser_context); |
| 59 DCHECK(browser_context->GetRequestContext()); | 58 DCHECK(browser_context->GetRequestContext()); |
| 60 // The following call to GetRequestContext() could possibly be the first such | 59 // The following call to GetRequestContext() could possibly be the first such |
| 61 // call, which means AwURLRequestContextGetter::InitializeURLRequestContext | 60 // call, which means AwURLRequestContextGetter::InitializeURLRequestContext |
| 62 // will be called on IO thread as a result. InitializeURLRequestContext() | 61 // will be called on IO thread as a result. InitializeURLRequestContext() |
| 63 // will initialize DataReductionProxyAuthRequestHandler. | 62 // will initialize DataReductionProxyRequestOptions. |
| 64 AwURLRequestContextGetter* aw_url_request_context_getter = | 63 AwURLRequestContextGetter* aw_url_request_context_getter = |
| 65 static_cast<AwURLRequestContextGetter*>( | 64 static_cast<AwURLRequestContextGetter*>( |
| 66 browser_context->GetRequestContext()); | 65 browser_context->GetRequestContext()); |
| 67 | 66 |
| 68 // This PostTask has to be called after GetRequestContext, because SetKeyOnIO | 67 // This PostTask has to be called after GetRequestContext, because SetKeyOnIO |
| 69 // needs a valid DataReductionProxyAuthRequestHandler object. | 68 // needs a valid DataReductionProxyRequestOptions object. |
| 70 BrowserThread::PostTask(BrowserThread::IO, | 69 BrowserThread::PostTask(BrowserThread::IO, |
| 71 FROM_HERE, | 70 FROM_HERE, |
| 72 base::Bind(&AwURLRequestContextGetter::SetKeyOnIO, | 71 base::Bind(&AwURLRequestContextGetter::SetKeyOnIO, |
| 73 aw_url_request_context_getter, | 72 aw_url_request_context_getter, |
| 74 ConvertJavaStringToUTF8(env, key))); | 73 ConvertJavaStringToUTF8(env, key))); |
| 75 } | 74 } |
| 76 | 75 |
| 77 // static | 76 // static |
| 78 void SetDataReductionProxyEnabled(JNIEnv* env, jclass, jboolean enabled) { | 77 void SetDataReductionProxyEnabled(JNIEnv* env, jclass, jboolean enabled) { |
| 79 AwBrowserContext::SetDataReductionProxyEnabled(enabled); | 78 AwBrowserContext::SetDataReductionProxyEnabled(enabled); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 99 // static | 98 // static |
| 100 void SetLegacyCacheRemovalDelayForTest(JNIEnv*, jclass, jlong delay_ms) { | 99 void SetLegacyCacheRemovalDelayForTest(JNIEnv*, jclass, jlong delay_ms) { |
| 101 AwBrowserContext::SetLegacyCacheRemovalDelayForTest(delay_ms); | 100 AwBrowserContext::SetLegacyCacheRemovalDelayForTest(delay_ms); |
| 102 } | 101 } |
| 103 | 102 |
| 104 bool RegisterAwContentsStatics(JNIEnv* env) { | 103 bool RegisterAwContentsStatics(JNIEnv* env) { |
| 105 return RegisterNativesImpl(env); | 104 return RegisterNativesImpl(env); |
| 106 } | 105 } |
| 107 | 106 |
| 108 } // namespace android_webview | 107 } // namespace android_webview |
| OLD | NEW |