OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 LoadUrl(params); | 815 LoadUrl(params); |
816 } | 816 } |
817 | 817 |
818 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { | 818 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { |
819 return GetRenderProcessIdFromRenderViewHost( | 819 return GetRenderProcessIdFromRenderViewHost( |
820 web_contents_->GetRenderViewHost()); | 820 web_contents_->GetRenderViewHost()); |
821 } | 821 } |
822 | 822 |
823 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL( | 823 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL( |
824 JNIEnv* env, jobject) const { | 824 JNIEnv* env, jobject) const { |
825 // The current users of the Java API expect to use the active entry | 825 GURL url = web_contents_->GetVisibleURL(); |
826 // rather than the visible entry, which is exposed by WebContents::GetURL. | |
827 content::NavigationEntry* entry = | |
828 web_contents_->GetController().GetActiveEntry(); | |
829 GURL url = entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); | |
830 return ConvertUTF8ToJavaString(env, url.spec()); | 826 return ConvertUTF8ToJavaString(env, url.spec()); |
831 } | 827 } |
832 | 828 |
833 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle( | 829 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle( |
834 JNIEnv* env, jobject obj) const { | 830 JNIEnv* env, jobject obj) const { |
835 return ConvertUTF16ToJavaString(env, GetWebContents()->GetTitle()); | 831 return ConvertUTF16ToJavaString(env, GetWebContents()->GetTitle()); |
836 } | 832 } |
837 | 833 |
838 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) { | 834 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) { |
839 return GetWebContents()->GetBrowserContext()->IsOffTheRecord(); | 835 return GetWebContents()->GetBrowserContext()->IsOffTheRecord(); |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 | 1424 |
1429 AddNavigationEntryToHistory( | 1425 AddNavigationEntryToHistory( |
1430 env, obj, history, controller.GetEntryAtIndex(i), i); | 1426 env, obj, history, controller.GetEntryAtIndex(i), i); |
1431 num_added++; | 1427 num_added++; |
1432 } | 1428 } |
1433 } | 1429 } |
1434 | 1430 |
1435 ScopedJavaLocalRef<jstring> | 1431 ScopedJavaLocalRef<jstring> |
1436 ContentViewCoreImpl::GetOriginalUrlForActiveNavigationEntry(JNIEnv* env, | 1432 ContentViewCoreImpl::GetOriginalUrlForActiveNavigationEntry(JNIEnv* env, |
1437 jobject obj) { | 1433 jobject obj) { |
1438 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); | 1434 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); |
1439 if (entry == NULL) | 1435 if (entry == NULL) |
1440 return ScopedJavaLocalRef<jstring>(env, NULL); | 1436 return ScopedJavaLocalRef<jstring>(env, NULL); |
1441 return ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec()); | 1437 return ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec()); |
1442 } | 1438 } |
1443 | 1439 |
1444 int ContentViewCoreImpl::GetNativeImeAdapter(JNIEnv* env, jobject obj) { | 1440 int ContentViewCoreImpl::GetNativeImeAdapter(JNIEnv* env, jobject obj) { |
1445 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); | 1441 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); |
1446 if (!rwhva) | 1442 if (!rwhva) |
1447 return 0; | 1443 return 0; |
1448 return rwhva->GetNativeImeAdapter(); | 1444 return rwhva->GetNativeImeAdapter(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 base::Bind(&JavaScriptResultCallback, j_callback); | 1499 base::Bind(&JavaScriptResultCallback, j_callback); |
1504 | 1500 |
1505 rvh->ExecuteJavascriptInWebFrameCallbackResult( | 1501 rvh->ExecuteJavascriptInWebFrameCallbackResult( |
1506 string16(), // frame_xpath | 1502 string16(), // frame_xpath |
1507 ConvertJavaStringToUTF16(env, script), | 1503 ConvertJavaStringToUTF16(env, script), |
1508 c_callback); | 1504 c_callback); |
1509 } | 1505 } |
1510 | 1506 |
1511 bool ContentViewCoreImpl::GetUseDesktopUserAgent( | 1507 bool ContentViewCoreImpl::GetUseDesktopUserAgent( |
1512 JNIEnv* env, jobject obj) { | 1508 JNIEnv* env, jobject obj) { |
1513 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); | 1509 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); |
1514 return entry && entry->GetIsOverridingUserAgent(); | 1510 return entry && entry->GetIsOverridingUserAgent(); |
1515 } | 1511 } |
1516 | 1512 |
1517 void ContentViewCoreImpl::UpdateImeAdapter(int native_ime_adapter, | 1513 void ContentViewCoreImpl::UpdateImeAdapter(int native_ime_adapter, |
1518 int text_input_type, | 1514 int text_input_type, |
1519 const std::string& text, | 1515 const std::string& text, |
1520 int selection_start, | 1516 int selection_start, |
1521 int selection_end, | 1517 int selection_end, |
1522 int composition_start, | 1518 int composition_start, |
1523 int composition_end, | 1519 int composition_end, |
(...skipping 21 matching lines...) Expand all Loading... |
1545 | 1541 |
1546 void ContentViewCoreImpl::SetUseDesktopUserAgent( | 1542 void ContentViewCoreImpl::SetUseDesktopUserAgent( |
1547 JNIEnv* env, | 1543 JNIEnv* env, |
1548 jobject obj, | 1544 jobject obj, |
1549 jboolean enabled, | 1545 jboolean enabled, |
1550 jboolean reload_on_state_change) { | 1546 jboolean reload_on_state_change) { |
1551 if (GetUseDesktopUserAgent(env, obj) == enabled) | 1547 if (GetUseDesktopUserAgent(env, obj) == enabled) |
1552 return; | 1548 return; |
1553 | 1549 |
1554 // Make sure the navigation entry actually exists. | 1550 // Make sure the navigation entry actually exists. |
1555 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); | 1551 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); |
1556 if (!entry) | 1552 if (!entry) |
1557 return; | 1553 return; |
1558 | 1554 |
1559 // Set the flag in the NavigationEntry. | 1555 // Set the flag in the NavigationEntry. |
1560 entry->SetIsOverridingUserAgent(enabled); | 1556 entry->SetIsOverridingUserAgent(enabled); |
1561 | 1557 |
1562 // Send the override to the renderer. | 1558 // Send the override to the renderer. |
1563 if (reload_on_state_change) { | 1559 if (reload_on_state_change) { |
1564 // Reloading the page will send the override down as part of the | 1560 // Reloading the page will send the override down as part of the |
1565 // navigation IPC message. | 1561 // navigation IPC message. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1600 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1605 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1601 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1606 return reinterpret_cast<jint>(view); | 1602 return reinterpret_cast<jint>(view); |
1607 } | 1603 } |
1608 | 1604 |
1609 bool RegisterContentViewCore(JNIEnv* env) { | 1605 bool RegisterContentViewCore(JNIEnv* env) { |
1610 return RegisterNativesImpl(env); | 1606 return RegisterNativesImpl(env); |
1611 } | 1607 } |
1612 | 1608 |
1613 } // namespace content | 1609 } // namespace content |
OLD | NEW |