| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/navigation_controller_android.h" | 5 #include "content/browser/frame_host/navigation_controller_android.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 ScopedJavaLocalRef<jstring> j_original_url( | 41 ScopedJavaLocalRef<jstring> j_original_url( |
| 42 ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec())); | 42 ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec())); |
| 43 ScopedJavaLocalRef<jstring> j_title( | 43 ScopedJavaLocalRef<jstring> j_title( |
| 44 ConvertUTF16ToJavaString(env, entry->GetTitle())); | 44 ConvertUTF16ToJavaString(env, entry->GetTitle())); |
| 45 ScopedJavaLocalRef<jobject> j_bitmap; | 45 ScopedJavaLocalRef<jobject> j_bitmap; |
| 46 const content::FaviconStatus& status = entry->GetFavicon(); | 46 const content::FaviconStatus& status = entry->GetFavicon(); |
| 47 if (status.valid && status.image.ToSkBitmap()->getSize() > 0) | 47 if (status.valid && status.image.ToSkBitmap()->getSize() > 0) |
| 48 j_bitmap = gfx::ConvertToJavaBitmap(status.image.ToSkBitmap()); | 48 j_bitmap = gfx::ConvertToJavaBitmap(status.image.ToSkBitmap()); |
| 49 | 49 |
| 50 return content::Java_NavigationControllerImpl_createNavigationEntry( | 50 return content::Java_NavigationControllerImpl_createNavigationEntry( |
| 51 env, | 51 env, index, j_url, j_virtual_url, j_original_url, j_title, j_bitmap, |
| 52 index, | |
| 53 j_url.obj(), | |
| 54 j_virtual_url.obj(), | |
| 55 j_original_url.obj(), | |
| 56 j_title.obj(), | |
| 57 j_bitmap.obj(), | |
| 58 entry->GetTransitionType()); | 52 entry->GetTransitionType()); |
| 59 } | 53 } |
| 60 | 54 |
| 61 static void AddNavigationEntryToHistory(JNIEnv* env, | 55 static void AddNavigationEntryToHistory(JNIEnv* env, |
| 62 jobject history, | 56 jobject history, |
| 63 content::NavigationEntry* entry, | 57 content::NavigationEntry* entry, |
| 64 int index) { | 58 int index) { |
| 65 content::Java_NavigationControllerImpl_addToNavigationHistory( | 59 content::Java_NavigationControllerImpl_addToNavigationHistory( |
| 66 env, | 60 env, history, CreateJavaNavigationEntry(env, entry, index)); |
| 67 history, | |
| 68 CreateJavaNavigationEntry(env, entry, index).obj()); | |
| 69 } | 61 } |
| 70 | 62 |
| 71 } // namespace | 63 } // namespace |
| 72 | 64 |
| 73 namespace content { | 65 namespace content { |
| 74 | 66 |
| 75 // static | 67 // static |
| 76 bool NavigationControllerAndroid::Register(JNIEnv* env) { | 68 bool NavigationControllerAndroid::Register(JNIEnv* env) { |
| 77 return RegisterNativesImpl(env); | 69 return RegisterNativesImpl(env); |
| 78 } | 70 } |
| 79 | 71 |
| 80 NavigationControllerAndroid::NavigationControllerAndroid( | 72 NavigationControllerAndroid::NavigationControllerAndroid( |
| 81 NavigationControllerImpl* navigation_controller) | 73 NavigationControllerImpl* navigation_controller) |
| 82 : navigation_controller_(navigation_controller) { | 74 : navigation_controller_(navigation_controller) { |
| 83 JNIEnv* env = AttachCurrentThread(); | 75 JNIEnv* env = AttachCurrentThread(); |
| 84 obj_.Reset(env, | 76 obj_.Reset(env, |
| 85 Java_NavigationControllerImpl_create( | 77 Java_NavigationControllerImpl_create( |
| 86 env, reinterpret_cast<intptr_t>(this)).obj()); | 78 env, reinterpret_cast<intptr_t>(this)).obj()); |
| 87 } | 79 } |
| 88 | 80 |
| 89 NavigationControllerAndroid::~NavigationControllerAndroid() { | 81 NavigationControllerAndroid::~NavigationControllerAndroid() { |
| 90 Java_NavigationControllerImpl_destroy(AttachCurrentThread(), obj_.obj()); | 82 Java_NavigationControllerImpl_destroy(AttachCurrentThread(), obj_); |
| 91 } | 83 } |
| 92 | 84 |
| 93 base::android::ScopedJavaLocalRef<jobject> | 85 base::android::ScopedJavaLocalRef<jobject> |
| 94 NavigationControllerAndroid::GetJavaObject() { | 86 NavigationControllerAndroid::GetJavaObject() { |
| 95 return base::android::ScopedJavaLocalRef<jobject>(obj_); | 87 return base::android::ScopedJavaLocalRef<jobject>(obj_); |
| 96 } | 88 } |
| 97 | 89 |
| 98 jboolean NavigationControllerAndroid::CanGoBack( | 90 jboolean NavigationControllerAndroid::CanGoBack( |
| 99 JNIEnv* env, | 91 JNIEnv* env, |
| 100 const JavaParamRef<jobject>& obj) { | 92 const JavaParamRef<jobject>& obj) { |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 const JavaParamRef<jobject>& obj, | 418 const JavaParamRef<jobject>& obj, |
| 427 jlong source_navigation_controller_android, | 419 jlong source_navigation_controller_android, |
| 428 jboolean replace_entry) { | 420 jboolean replace_entry) { |
| 429 navigation_controller_->CopyStateFromAndPrune( | 421 navigation_controller_->CopyStateFromAndPrune( |
| 430 reinterpret_cast<NavigationControllerAndroid*>( | 422 reinterpret_cast<NavigationControllerAndroid*>( |
| 431 source_navigation_controller_android)->navigation_controller_, | 423 source_navigation_controller_android)->navigation_controller_, |
| 432 replace_entry); | 424 replace_entry); |
| 433 } | 425 } |
| 434 | 426 |
| 435 } // namespace content | 427 } // namespace content |
| OLD | NEW |