| 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_array.h" |
| 10 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/strings/string16.h" |
| 12 #include "content/browser/frame_host/navigation_controller_impl.h" | 14 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 13 #include "content/browser/frame_host/navigation_entry_impl.h" | 15 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 14 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 15 #include "content/public/browser/ssl_host_state_delegate.h" | 17 #include "content/public/browser/ssl_host_state_delegate.h" |
| 16 #include "content/public/common/resource_request_body.h" | 18 #include "content/public/common/resource_request_body.h" |
| 17 #include "jni/NavigationControllerImpl_jni.h" | 19 #include "jni/NavigationControllerImpl_jni.h" |
| 18 #include "net/base/data_url.h" | 20 #include "net/base/data_url.h" |
| 19 #include "ui/gfx/android/java_bitmap.h" | 21 #include "ui/gfx/android/java_bitmap.h" |
| 20 | 22 |
| 21 using base::android::AttachCurrentThread; | 23 using base::android::AttachCurrentThread; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 43 ConvertUTF8ToJavaString(env, entry->GetVirtualURL().spec())); | 45 ConvertUTF8ToJavaString(env, entry->GetVirtualURL().spec())); |
| 44 ScopedJavaLocalRef<jstring> j_original_url( | 46 ScopedJavaLocalRef<jstring> j_original_url( |
| 45 ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec())); | 47 ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec())); |
| 46 ScopedJavaLocalRef<jstring> j_title( | 48 ScopedJavaLocalRef<jstring> j_title( |
| 47 ConvertUTF16ToJavaString(env, entry->GetTitle())); | 49 ConvertUTF16ToJavaString(env, entry->GetTitle())); |
| 48 ScopedJavaLocalRef<jobject> j_bitmap; | 50 ScopedJavaLocalRef<jobject> j_bitmap; |
| 49 const content::FaviconStatus& status = entry->GetFavicon(); | 51 const content::FaviconStatus& status = entry->GetFavicon(); |
| 50 if (status.valid && status.image.ToSkBitmap()->getSize() > 0) | 52 if (status.valid && status.image.ToSkBitmap()->getSize() > 0) |
| 51 j_bitmap = gfx::ConvertToJavaBitmap(status.image.ToSkBitmap()); | 53 j_bitmap = gfx::ConvertToJavaBitmap(status.image.ToSkBitmap()); |
| 52 | 54 |
| 55 std::vector<std::string> extra_data_keys; |
| 56 std::vector<base::string16> extra_data_values; |
| 57 for (const auto& pair : entry->GetExtraData()) { |
| 58 extra_data_keys.push_back(pair.first); |
| 59 extra_data_values.push_back(pair.second); |
| 60 } |
| 61 ScopedJavaLocalRef<jobjectArray> j_extra_data_keys( |
| 62 base::android::ToJavaArrayOfStrings(env, extra_data_keys)); |
| 63 ScopedJavaLocalRef<jobjectArray> j_extra_data_values( |
| 64 base::android::ToJavaArrayOfStrings(env, extra_data_values)); |
| 65 |
| 53 return content::Java_NavigationControllerImpl_createNavigationEntry( | 66 return content::Java_NavigationControllerImpl_createNavigationEntry( |
| 54 env, index, j_url, j_virtual_url, j_original_url, j_title, j_bitmap, | 67 env, index, j_url, j_virtual_url, j_original_url, j_title, j_bitmap, |
| 55 entry->GetTransitionType()); | 68 entry->GetTransitionType(), j_extra_data_keys, j_extra_data_values); |
| 56 } | 69 } |
| 57 | 70 |
| 58 static void AddNavigationEntryToHistory(JNIEnv* env, | 71 static void AddNavigationEntryToHistory(JNIEnv* env, |
| 59 const JavaRef<jobject>& history, | 72 const JavaRef<jobject>& history, |
| 60 content::NavigationEntry* entry, | 73 content::NavigationEntry* entry, |
| 61 int index) { | 74 int index) { |
| 62 content::Java_NavigationControllerImpl_addToNavigationHistory( | 75 content::Java_NavigationControllerImpl_addToNavigationHistory( |
| 63 env, history, CreateJavaNavigationEntry(env, entry, index)); | 76 env, history, CreateJavaNavigationEntry(env, entry, index)); |
| 64 } | 77 } |
| 65 | 78 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 JNIEnv* env, | 433 JNIEnv* env, |
| 421 const JavaParamRef<jobject>& obj, | 434 const JavaParamRef<jobject>& obj, |
| 422 jlong source_navigation_controller_android, | 435 jlong source_navigation_controller_android, |
| 423 jboolean replace_entry) { | 436 jboolean replace_entry) { |
| 424 navigation_controller_->CopyStateFromAndPrune( | 437 navigation_controller_->CopyStateFromAndPrune( |
| 425 reinterpret_cast<NavigationControllerAndroid*>( | 438 reinterpret_cast<NavigationControllerAndroid*>( |
| 426 source_navigation_controller_android)->navigation_controller_, | 439 source_navigation_controller_android)->navigation_controller_, |
| 427 replace_entry); | 440 replace_entry); |
| 428 } | 441 } |
| 429 | 442 |
| 443 void NavigationControllerAndroid::SetEntryExtraData( |
| 444 JNIEnv* env, |
| 445 const JavaParamRef<jobject>& obj, |
| 446 jint index, |
| 447 const JavaParamRef<jstring>& jkey, |
| 448 const JavaParamRef<jstring>& jvalue) { |
| 449 if (index < 0 || index >= navigation_controller_->GetEntryCount()) |
| 450 return; |
| 451 |
| 452 std::string key = base::android::ConvertJavaStringToUTF8(env, jkey); |
| 453 base::string16 value = base::android::ConvertJavaStringToUTF16(env, jvalue); |
| 454 navigation_controller_->GetEntryAtIndex(index)->SetExtraData(key, value); |
| 455 } |
| 456 |
| 430 } // namespace content | 457 } // namespace content |
| OLD | NEW |