| 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_version_info_values.h" | 9 #include "android_webview/common/aw_version_info_values.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 void NotifyClientCertificatesChanged() { | 34 void NotifyClientCertificatesChanged() { |
| 35 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 35 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 36 net::CertDatabase::GetInstance()->OnAndroidKeyStoreChanged(); | 36 net::CertDatabase::GetInstance()->OnAndroidKeyStoreChanged(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 // static | 41 // static |
| 42 void ClearClientCertPreferences(JNIEnv* env, jclass, jobject callback) { | 42 void ClearClientCertPreferences(JNIEnv* env, |
| 43 const JavaParamRef<jclass>&, |
| 44 const JavaParamRef<jobject>& callback) { |
| 43 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 45 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 44 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); | 46 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); |
| 45 j_callback->Reset(env, callback); | 47 j_callback->Reset(env, callback); |
| 46 BrowserThread::PostTaskAndReply( | 48 BrowserThread::PostTaskAndReply( |
| 47 BrowserThread::IO, | 49 BrowserThread::IO, |
| 48 FROM_HERE, | 50 FROM_HERE, |
| 49 base::Bind(&NotifyClientCertificatesChanged), | 51 base::Bind(&NotifyClientCertificatesChanged), |
| 50 base::Bind(&ClientCertificatesCleared, base::Owned(j_callback))); | 52 base::Bind(&ClientCertificatesCleared, base::Owned(j_callback))); |
| 51 } | 53 } |
| 52 | 54 |
| 53 // static | 55 // static |
| 54 void SetDataReductionProxyKey(JNIEnv* env, jclass, jstring key) { | 56 void SetDataReductionProxyKey(JNIEnv* env, |
| 57 const JavaParamRef<jclass>&, |
| 58 const JavaParamRef<jstring>& key) { |
| 55 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); | 59 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); |
| 56 DCHECK(browser_context); | 60 DCHECK(browser_context); |
| 57 DCHECK(browser_context->GetRequestContext()); | 61 DCHECK(browser_context->GetRequestContext()); |
| 58 // The following call to GetRequestContext() could possibly be the first such | 62 // The following call to GetRequestContext() could possibly be the first such |
| 59 // call, which means AwURLRequestContextGetter::InitializeURLRequestContext | 63 // call, which means AwURLRequestContextGetter::InitializeURLRequestContext |
| 60 // will be called on IO thread as a result. | 64 // will be called on IO thread as a result. |
| 61 AwURLRequestContextGetter* aw_url_request_context_getter = | 65 AwURLRequestContextGetter* aw_url_request_context_getter = |
| 62 static_cast<AwURLRequestContextGetter*>( | 66 static_cast<AwURLRequestContextGetter*>( |
| 63 browser_context->GetRequestContext()); | 67 browser_context->GetRequestContext()); |
| 64 | 68 |
| 65 // This PostTask has to be called after GetRequestContext, because SetKeyOnIO | 69 // This PostTask has to be called after GetRequestContext, because SetKeyOnIO |
| 66 // needs a valid DataReductionProxyRequestOptions object. | 70 // needs a valid DataReductionProxyRequestOptions object. |
| 67 BrowserThread::PostTask(BrowserThread::IO, | 71 BrowserThread::PostTask(BrowserThread::IO, |
| 68 FROM_HERE, | 72 FROM_HERE, |
| 69 base::Bind(&AwURLRequestContextGetter::SetKeyOnIO, | 73 base::Bind(&AwURLRequestContextGetter::SetKeyOnIO, |
| 70 aw_url_request_context_getter, | 74 aw_url_request_context_getter, |
| 71 ConvertJavaStringToUTF8(env, key))); | 75 ConvertJavaStringToUTF8(env, key))); |
| 72 } | 76 } |
| 73 | 77 |
| 74 // static | 78 // static |
| 75 void SetDataReductionProxyEnabled(JNIEnv* env, jclass, jboolean enabled) { | 79 void SetDataReductionProxyEnabled(JNIEnv* env, |
| 80 const JavaParamRef<jclass>&, |
| 81 jboolean enabled) { |
| 76 AwBrowserContext::SetDataReductionProxyEnabled(enabled); | 82 AwBrowserContext::SetDataReductionProxyEnabled(enabled); |
| 77 } | 83 } |
| 78 | 84 |
| 79 // static | 85 // static |
| 80 ScopedJavaLocalRef<jstring> GetUnreachableWebDataUrl(JNIEnv* env, jclass) { | 86 ScopedJavaLocalRef<jstring> GetUnreachableWebDataUrl( |
| 87 JNIEnv* env, |
| 88 const JavaParamRef<jclass>&) { |
| 81 return base::android::ConvertUTF8ToJavaString( | 89 return base::android::ConvertUTF8ToJavaString( |
| 82 env, content::kUnreachableWebDataURL); | 90 env, content::kUnreachableWebDataURL); |
| 83 } | 91 } |
| 84 | 92 |
| 85 // static | 93 // static |
| 86 void SetRecordFullDocument(JNIEnv* env, jclass, jboolean record_full_document) { | 94 void SetRecordFullDocument(JNIEnv* env, |
| 95 const JavaParamRef<jclass>&, |
| 96 jboolean record_full_document) { |
| 87 content::SynchronousCompositor::SetRecordFullDocument(record_full_document); | 97 content::SynchronousCompositor::SetRecordFullDocument(record_full_document); |
| 88 } | 98 } |
| 89 | 99 |
| 90 // static | 100 // static |
| 91 void SetLegacyCacheRemovalDelayForTest(JNIEnv*, jclass, jlong delay_ms) { | 101 void SetLegacyCacheRemovalDelayForTest(JNIEnv*, |
| 102 const JavaParamRef<jclass>&, |
| 103 jlong delay_ms) { |
| 92 AwBrowserContext::SetLegacyCacheRemovalDelayForTest(delay_ms); | 104 AwBrowserContext::SetLegacyCacheRemovalDelayForTest(delay_ms); |
| 93 } | 105 } |
| 94 | 106 |
| 95 // static | 107 // static |
| 96 ScopedJavaLocalRef<jstring> GetProductVersion(JNIEnv* env, jclass) { | 108 ScopedJavaLocalRef<jstring> GetProductVersion(JNIEnv* env, |
| 109 const JavaParamRef<jclass>&) { |
| 97 return base::android::ConvertUTF8ToJavaString(env, PRODUCT_VERSION); | 110 return base::android::ConvertUTF8ToJavaString(env, PRODUCT_VERSION); |
| 98 } | 111 } |
| 99 | 112 |
| 100 bool RegisterAwContentsStatics(JNIEnv* env) { | 113 bool RegisterAwContentsStatics(JNIEnv* env) { |
| 101 return RegisterNativesImpl(env); | 114 return RegisterNativesImpl(env); |
| 102 } | 115 } |
| 103 | 116 |
| 104 } // namespace android_webview | 117 } // namespace android_webview |
| OLD | NEW |