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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 base::android::ConvertJavaStringToUTF8(env, user_agent_override); | 741 base::android::ConvertJavaStringToUTF8(env, user_agent_override); |
742 web_contents_->SetUserAgentOverride(override); | 742 web_contents_->SetUserAgentOverride(override); |
743 bool override_used = !override.empty(); | 743 bool override_used = !override.empty(); |
744 const NavigationController& controller = web_contents_->GetController(); | 744 const NavigationController& controller = web_contents_->GetController(); |
745 for (int i = 0; i < controller.GetEntryCount(); ++i) | 745 for (int i = 0; i < controller.GetEntryCount(); ++i) |
746 controller.GetEntryAtIndex(i)->SetIsOverridingUserAgent(override_used); | 746 controller.GetEntryAtIndex(i)->SetIsOverridingUserAgent(override_used); |
747 } | 747 } |
748 | 748 |
749 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL( | 749 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL( |
750 JNIEnv* env, jobject) const { | 750 JNIEnv* env, jobject) const { |
751 return ConvertUTF8ToJavaString(env, GetWebContents()->GetURL().spec()); | 751 // The current users of the Java API expect to use the active entry |
| 752 // rather than the visible entry, which is exposed by WebContents::GetURL. |
| 753 content::NavigationEntry* entry = |
| 754 web_contents_->GetController().GetActiveEntry(); |
| 755 GURL url = entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); |
| 756 return ConvertUTF8ToJavaString(env, url.spec()); |
752 } | 757 } |
753 | 758 |
754 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle( | 759 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle( |
755 JNIEnv* env, jobject obj) const { | 760 JNIEnv* env, jobject obj) const { |
756 return ConvertUTF16ToJavaString(env, GetWebContents()->GetTitle()); | 761 return ConvertUTF16ToJavaString(env, GetWebContents()->GetTitle()); |
757 } | 762 } |
758 | 763 |
759 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) { | 764 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) { |
760 return GetWebContents()->GetBrowserContext()->IsOffTheRecord(); | 765 return GetWebContents()->GetBrowserContext()->IsOffTheRecord(); |
761 } | 766 } |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 reinterpret_cast<WebContents*>(native_web_contents), | 1448 reinterpret_cast<WebContents*>(native_web_contents), |
1444 reinterpret_cast<ui::WindowAndroid*>(native_window)); | 1449 reinterpret_cast<ui::WindowAndroid*>(native_window)); |
1445 return reinterpret_cast<jint>(view); | 1450 return reinterpret_cast<jint>(view); |
1446 } | 1451 } |
1447 | 1452 |
1448 bool RegisterContentViewCore(JNIEnv* env) { | 1453 bool RegisterContentViewCore(JNIEnv* env) { |
1449 return RegisterNativesImpl(env); | 1454 return RegisterNativesImpl(env); |
1450 } | 1455 } |
1451 | 1456 |
1452 } // namespace content | 1457 } // namespace content |
OLD | NEW |