Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_web_contents_delegate.h" | 5 #include "android_webview/native/aw_web_contents_delegate.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | |
| 8 #include "base/android/jni_string.h" | |
| 9 #include "googleurl/src/gurl.h" | |
| 10 #include "jni/AwWebContentsDelegate_jni.h" | |
| 11 | |
| 12 using base::android::AttachCurrentThread; | |
| 13 using base::android::ConvertUTF8ToJavaString; | |
| 14 using base::android::ScopedJavaLocalRef; | |
| 15 | |
| 7 namespace android_webview { | 16 namespace android_webview { |
| 8 | 17 |
| 9 AwWebContentsDelegate::AwWebContentsDelegate( | 18 AwWebContentsDelegate::AwWebContentsDelegate( |
| 10 JNIEnv* env, | 19 JNIEnv* env, |
| 11 jobject obj) | 20 jobject obj) |
| 12 : WebContentsDelegateAndroid(env, obj) { | 21 : WebContentsDelegateAndroid(env, obj) { |
| 13 } | 22 } |
| 14 | 23 |
| 15 AwWebContentsDelegate::~AwWebContentsDelegate() { | 24 AwWebContentsDelegate::~AwWebContentsDelegate() { |
| 16 } | 25 } |
| 17 | 26 |
| 27 bool AwWebContentsDelegate::ShouldIgnoreNavigation(const GURL& url) { | |
| 28 if (!url.is_valid()) | |
|
benm (inactive)
2012/09/19 11:04:04
braces?
mkosiba (inactive)
2012/09/25 18:01:47
optional according to the coding style.
| |
| 29 return false; | |
| 30 | |
| 31 JNIEnv* env = AttachCurrentThread(); | |
| 32 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | |
| 33 if (obj.is_null()) | |
| 34 return false; | |
| 35 | |
| 36 ScopedJavaLocalRef<jstring> jstring_url = | |
| 37 ConvertUTF8ToJavaString(env, url.spec()); | |
| 38 bool ret = Java_AwWebContentsDelegate_shouldIgnoreNavigation( | |
|
benm (inactive)
2012/09/19 11:04:04
nit: no need for local ret?
mkosiba (inactive)
2012/09/25 18:01:47
Done.
| |
| 39 env, obj.obj(), jstring_url.obj()); | |
| 40 return ret; | |
| 41 } | |
| 42 | |
| 43 // register native methods | |
| 44 bool RegisterAwWebContentsDelegate(JNIEnv* env) { | |
| 45 return RegisterNativesImpl(env) >= 0; | |
| 46 } | |
| 47 | |
| 18 } // namespace android_webview | 48 } // namespace android_webview |
| OLD | NEW |