| 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 "content/browser/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL( | 230 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL( |
| 231 JNIEnv* env, jobject) const { | 231 JNIEnv* env, jobject) const { |
| 232 return ConvertUTF8ToJavaString(env, web_contents()->GetURL().spec()); | 232 return ConvertUTF8ToJavaString(env, web_contents()->GetURL().spec()); |
| 233 } | 233 } |
| 234 | 234 |
| 235 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle( | 235 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle( |
| 236 JNIEnv* env, jobject obj) const { | 236 JNIEnv* env, jobject obj) const { |
| 237 return ConvertUTF16ToJavaString(env, web_contents()->GetTitle()); | 237 return ConvertUTF16ToJavaString(env, web_contents()->GetTitle()); |
| 238 } | 238 } |
| 239 | 239 |
| 240 jdouble ContentViewCoreImpl::GetLoadProgress(JNIEnv* env, jobject obj) const { | |
| 241 // An empty page never loads anything and always has a progress of 0. | |
| 242 // We report 1 in that case so the UI does not assume the page is loading. | |
| 243 if (web_contents()->GetURL().is_empty() || !content_view_client_.get()) | |
| 244 return static_cast<jdouble>(1.0); | |
| 245 return static_cast<jdouble>(content_view_client_->GetLoadProgress()); | |
| 246 } | |
| 247 | |
| 248 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) { | 240 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) { |
| 249 return web_contents()->GetBrowserContext()->IsOffTheRecord(); | 241 return web_contents()->GetBrowserContext()->IsOffTheRecord(); |
| 250 } | 242 } |
| 251 | 243 |
| 252 jboolean ContentViewCoreImpl::TouchEvent(JNIEnv* env, | 244 jboolean ContentViewCoreImpl::TouchEvent(JNIEnv* env, |
| 253 jobject obj, | 245 jobject obj, |
| 254 jlong time_ms, | 246 jlong time_ms, |
| 255 jint type, | 247 jint type, |
| 256 jobjectArray pts) { | 248 jobjectArray pts) { |
| 257 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 249 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 } | 381 } |
| 390 | 382 |
| 391 jboolean ContentViewCoreImpl::NeedsReload(JNIEnv* env, jobject obj) { | 383 jboolean ContentViewCoreImpl::NeedsReload(JNIEnv* env, jobject obj) { |
| 392 return web_contents_->GetController().NeedsReload(); | 384 return web_contents_->GetController().NeedsReload(); |
| 393 } | 385 } |
| 394 | 386 |
| 395 void ContentViewCoreImpl::SetClient(JNIEnv* env, jobject obj, jobject jclient) { | 387 void ContentViewCoreImpl::SetClient(JNIEnv* env, jobject obj, jobject jclient) { |
| 396 scoped_ptr<ContentViewClient> client( | 388 scoped_ptr<ContentViewClient> client( |
| 397 ContentViewClient::CreateNativeContentViewClient(env, jclient)); | 389 ContentViewClient::CreateNativeContentViewClient(env, jclient)); |
| 398 | 390 |
| 399 web_contents_->SetDelegate(client.get()); | |
| 400 | |
| 401 content_view_client_.swap(client); | 391 content_view_client_.swap(client); |
| 402 } | 392 } |
| 403 | 393 |
| 404 void ContentViewCoreImpl::AddJavascriptInterface( | 394 void ContentViewCoreImpl::AddJavascriptInterface( |
| 405 JNIEnv* env, | 395 JNIEnv* env, |
| 406 jobject /* obj */, | 396 jobject /* obj */, |
| 407 jobject object, | 397 jobject object, |
| 408 jstring name, | 398 jstring name, |
| 409 jboolean require_annotation) { | 399 jboolean require_annotation) { |
| 410 ScopedJavaLocalRef<jobject> scoped_object(env, object); | 400 ScopedJavaLocalRef<jobject> scoped_object(env, object); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 616 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
| 627 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 617 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
| 628 return false; | 618 return false; |
| 629 } | 619 } |
| 630 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 620 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
| 631 | 621 |
| 632 return RegisterNativesImpl(env) >= 0; | 622 return RegisterNativesImpl(env) >= 0; |
| 633 } | 623 } |
| 634 | 624 |
| 635 } // namespace content | 625 } // namespace content |
| OLD | NEW |