Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: android_webview/native/aw_contents.cc

Issue 10946008: Componentize IgnoreNavigationResourceThrottle and add chrome and webview specific implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed presubmit warning for jni_generator.py Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.h" 5 #include "android_webview/native/aw_contents.h"
6 6
7 #include "android_webview/browser/net_disk_cache_remover.h" 7 #include "android_webview/browser/net_disk_cache_remover.h"
8 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" 8 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h"
9 #include "android_webview/native/aw_browser_dependency_factory.h" 9 #include "android_webview/native/aw_browser_dependency_factory.h"
10 #include "android_webview/native/aw_contents_container.h" 10 #include "android_webview/native/aw_contents_container.h"
11 #include "android_webview/native/aw_contents_io_thread_client_impl.h" 11 #include "android_webview/native/aw_contents_io_thread_client_impl.h"
12 #include "android_webview/native/aw_web_contents_delegate.h" 12 #include "android_webview/native/aw_web_contents_delegate.h"
13 #include "base/android/jni_android.h" 13 #include "base/android/jni_android.h"
14 #include "base/android/jni_array.h" 14 #include "base/android/jni_array.h"
15 #include "base/android/jni_string.h" 15 #include "base/android/jni_string.h"
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/supports_user_data.h" 18 #include "base/supports_user_data.h"
19 #include "chrome/browser/component/navigation_interception/intercept_navigation_ delegate.h"
19 #include "content/public/browser/android/content_view_core.h" 20 #include "content/public/browser/android/content_view_core.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/cert_store.h" 22 #include "content/public/browser/cert_store.h"
22 #include "content/public/browser/navigation_entry.h" 23 #include "content/public/browser/navigation_entry.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
24 #include "content/public/common/ssl_status.h" 25 #include "content/public/common/ssl_status.h"
25 #include "jni/AwContents_jni.h" 26 #include "jni/AwContents_jni.h"
26 #include "net/base/x509_certificate.h" 27 #include "net/base/x509_certificate.h"
27 28
28 using base::android::AttachCurrentThread; 29 using base::android::AttachCurrentThread;
29 using base::android::ConvertJavaStringToUTF16; 30 using base::android::ConvertJavaStringToUTF16;
30 using base::android::ConvertJavaStringToUTF8; 31 using base::android::ConvertJavaStringToUTF8;
31 using base::android::ConvertUTF16ToJavaString; 32 using base::android::ConvertUTF16ToJavaString;
32 using base::android::ConvertUTF8ToJavaString; 33 using base::android::ConvertUTF8ToJavaString;
33 using base::android::JavaRef; 34 using base::android::JavaRef;
34 using base::android::ScopedJavaGlobalRef; 35 using base::android::ScopedJavaGlobalRef;
35 using base::android::ScopedJavaLocalRef; 36 using base::android::ScopedJavaLocalRef;
36 using content::BrowserThread; 37 using content::BrowserThread;
37 using content::ContentViewCore; 38 using content::ContentViewCore;
38 using content::WebContents; 39 using content::WebContents;
40 using navigation_interception::InterceptNavigationDelegate;
39 41
40 namespace android_webview { 42 namespace android_webview {
41 43
42 namespace { 44 namespace {
43 45
44 const void* kAwContentsUserDataKey = &kAwContentsUserDataKey; 46 const void* kAwContentsUserDataKey = &kAwContentsUserDataKey;
45 47
46 class AwContentsUserData : public base::SupportsUserData::Data { 48 class AwContentsUserData : public base::SupportsUserData::Data {
47 public: 49 public:
48 AwContentsUserData(AwContents* ptr) : contents_(ptr) {} 50 AwContentsUserData(AwContents* ptr) : contents_(ptr) {}
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 jrealm.obj()); 214 jrealm.obj());
213 } 215 }
214 216
215 void AwContents::SetIoThreadClient(JNIEnv* env, jobject obj, jobject client) { 217 void AwContents::SetIoThreadClient(JNIEnv* env, jobject obj, jobject client) {
216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
217 content::WebContents* web_contents = contents_container_->GetWebContents(); 219 content::WebContents* web_contents = contents_container_->GetWebContents();
218 AwContentsIoThreadClientImpl::Associate( 220 AwContentsIoThreadClientImpl::Associate(
219 web_contents, ScopedJavaLocalRef<jobject>(env, client)); 221 web_contents, ScopedJavaLocalRef<jobject>(env, client));
220 } 222 }
221 223
224 void AwContents::SetInterceptNavigationDelegate(JNIEnv* env,
225 jobject obj,
226 jobject delegate) {
227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
228 content::WebContents* web_contents = contents_container_->GetWebContents();
229 InterceptNavigationDelegate::Associate(
230 web_contents,
231 make_scoped_ptr(new InterceptNavigationDelegate(env, delegate)));
232 }
233
222 static jint Init(JNIEnv* env, 234 static jint Init(JNIEnv* env,
223 jobject obj, 235 jobject obj,
224 jobject web_contents_delegate, 236 jobject web_contents_delegate,
225 jboolean private_browsing) { 237 jboolean private_browsing) {
226 AwContents* tab = new AwContents(env, obj, web_contents_delegate, 238 AwContents* tab = new AwContents(env, obj, web_contents_delegate,
227 private_browsing); 239 private_browsing);
228 return reinterpret_cast<jint>(tab); 240 return reinterpret_cast<jint>(tab);
229 } 241 }
230 242
231 bool RegisterAwContents(JNIEnv* env) { 243 bool RegisterAwContents(JNIEnv* env) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 return ScopedJavaLocalRef<jbyteArray>(); 312 return ScopedJavaLocalRef<jbyteArray>();
301 313
302 // Convert the certificate and return it 314 // Convert the certificate and return it
303 std::string der_string; 315 std::string der_string;
304 net::X509Certificate::GetDEREncoded(cert->os_cert_handle(), &der_string); 316 net::X509Certificate::GetDEREncoded(cert->os_cert_handle(), &der_string);
305 return base::android::ToJavaByteArray(env, 317 return base::android::ToJavaByteArray(env,
306 reinterpret_cast<const uint8*>(der_string.data()), der_string.length()); 318 reinterpret_cast<const uint8*>(der_string.data()), der_string.length());
307 } 319 }
308 320
309 } // namespace android_webview 321 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698