Chromium Code Reviews| 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_array.h" |
| 11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 12 #include "content/browser/frame_host/navigation_controller_impl.h" | |
| 12 #include "content/browser/frame_host/navigation_entry_impl.h" | 13 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 13 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
| 14 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/render_view_host.h" |
|
nasko
2016/04/08 22:32:35
Why is this header needed? I don't see any new cod
aelias_OOO_until_Jul13
2016/04/08 23:31:36
Removed.
| |
| 15 #include "content/public/browser/ssl_host_state_delegate.h" | 16 #include "content/public/browser/ssl_host_state_delegate.h" |
| 16 #include "jni/NavigationControllerImpl_jni.h" | 17 #include "jni/NavigationControllerImpl_jni.h" |
| 17 #include "net/base/data_url.h" | 18 #include "net/base/data_url.h" |
| 18 #include "ui/gfx/android/java_bitmap.h" | 19 #include "ui/gfx/android/java_bitmap.h" |
| 19 | 20 |
| 20 using base::android::AttachCurrentThread; | 21 using base::android::AttachCurrentThread; |
| 21 using base::android::ConvertJavaStringToUTF16; | 22 using base::android::ConvertJavaStringToUTF16; |
| 22 using base::android::ConvertJavaStringToUTF8; | 23 using base::android::ConvertJavaStringToUTF8; |
| 23 using base::android::ConvertUTF16ToJavaString; | 24 using base::android::ConvertUTF16ToJavaString; |
| 24 using base::android::ConvertUTF8ToJavaString; | 25 using base::android::ConvertUTF8ToJavaString; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 } // namespace | 70 } // namespace |
| 70 | 71 |
| 71 namespace content { | 72 namespace content { |
| 72 | 73 |
| 73 // static | 74 // static |
| 74 bool NavigationControllerAndroid::Register(JNIEnv* env) { | 75 bool NavigationControllerAndroid::Register(JNIEnv* env) { |
| 75 return RegisterNativesImpl(env); | 76 return RegisterNativesImpl(env); |
| 76 } | 77 } |
| 77 | 78 |
| 78 NavigationControllerAndroid::NavigationControllerAndroid( | 79 NavigationControllerAndroid::NavigationControllerAndroid( |
| 79 NavigationController* navigation_controller) | 80 NavigationControllerImpl* navigation_controller) |
| 80 : navigation_controller_(navigation_controller) { | 81 : navigation_controller_(navigation_controller) { |
| 81 JNIEnv* env = AttachCurrentThread(); | 82 JNIEnv* env = AttachCurrentThread(); |
| 82 obj_.Reset(env, | 83 obj_.Reset(env, |
| 83 Java_NavigationControllerImpl_create( | 84 Java_NavigationControllerImpl_create( |
| 84 env, reinterpret_cast<intptr_t>(this)).obj()); | 85 env, reinterpret_cast<intptr_t>(this)).obj()); |
| 85 } | 86 } |
| 86 | 87 |
| 87 NavigationControllerAndroid::~NavigationControllerAndroid() { | 88 NavigationControllerAndroid::~NavigationControllerAndroid() { |
| 88 Java_NavigationControllerImpl_destroy(AttachCurrentThread(), obj_.obj()); | 89 Java_NavigationControllerImpl_destroy(AttachCurrentThread(), obj_.obj()); |
| 89 } | 90 } |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 if (GetUseDesktopUserAgent(env, obj) == enabled) | 349 if (GetUseDesktopUserAgent(env, obj) == enabled) |
| 349 return; | 350 return; |
| 350 | 351 |
| 351 // Make sure the navigation entry actually exists. | 352 // Make sure the navigation entry actually exists. |
| 352 NavigationEntry* entry = navigation_controller_->GetVisibleEntry(); | 353 NavigationEntry* entry = navigation_controller_->GetVisibleEntry(); |
| 353 if (!entry) | 354 if (!entry) |
| 354 return; | 355 return; |
| 355 | 356 |
| 356 // Set the flag in the NavigationEntry. | 357 // Set the flag in the NavigationEntry. |
| 357 entry->SetIsOverridingUserAgent(enabled); | 358 entry->SetIsOverridingUserAgent(enabled); |
| 359 navigation_controller_->delegate()->UpdateOverridingUserAgent(); | |
| 358 | 360 |
| 359 // Send the override to the renderer. | 361 // Send the override to the renderer. |
| 360 if (reload_on_state_change) { | 362 if (reload_on_state_change) { |
| 361 // Reloading the page will send the override down as part of the | 363 // Reloading the page will send the override down as part of the |
| 362 // navigation IPC message. | 364 // navigation IPC message. |
| 363 navigation_controller_->ReloadOriginalRequestURL(false); | 365 navigation_controller_->ReloadOriginalRequestURL(false); |
| 364 } | 366 } |
| 365 } | 367 } |
| 366 | 368 |
| 367 base::android::ScopedJavaLocalRef<jobject> | 369 base::android::ScopedJavaLocalRef<jobject> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 const JavaParamRef<jobject>& obj, | 430 const JavaParamRef<jobject>& obj, |
| 429 jlong source_navigation_controller_android, | 431 jlong source_navigation_controller_android, |
| 430 jboolean replace_entry) { | 432 jboolean replace_entry) { |
| 431 navigation_controller_->CopyStateFromAndPrune( | 433 navigation_controller_->CopyStateFromAndPrune( |
| 432 reinterpret_cast<NavigationControllerAndroid*>( | 434 reinterpret_cast<NavigationControllerAndroid*>( |
| 433 source_navigation_controller_android)->navigation_controller_, | 435 source_navigation_controller_android)->navigation_controller_, |
| 434 replace_entry); | 436 replace_entry); |
| 435 } | 437 } |
| 436 | 438 |
| 437 } // namespace content | 439 } // namespace content |
| OLD | NEW |