Chromium Code Reviews| 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 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { | 796 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { |
| 797 return GetRenderProcessIdFromRenderViewHost( | 797 return GetRenderProcessIdFromRenderViewHost( |
| 798 web_contents_->GetRenderViewHost()); | 798 web_contents_->GetRenderViewHost()); |
| 799 } | 799 } |
| 800 | 800 |
| 801 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL( | 801 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL( |
| 802 JNIEnv* env, jobject) const { | 802 JNIEnv* env, jobject) const { |
| 803 // The current users of the Java API expect to use the active entry | 803 // The current users of the Java API expect to use the active entry |
| 804 // rather than the visible entry, which is exposed by WebContents::GetURL. | 804 // rather than the visible entry, which is exposed by WebContents::GetURL. |
| 805 content::NavigationEntry* entry = | 805 content::NavigationEntry* entry = |
| 806 web_contents_->GetController().GetActiveEntry(); | 806 web_contents_->GetController().GetVisibleEntry(); |
|
Charlie Reis
2013/08/16 22:10:14
This goes against the comment, which Martin Kosiba
mkosiba (inactive)
2013/08/19 14:49:38
Hey! Thanks for remembering about this! We use a t
nasko
2013/09/12 17:56:31
Done.
| |
| 807 GURL url = entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); | 807 GURL url = entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); |
| 808 return ConvertUTF8ToJavaString(env, url.spec()); | 808 return ConvertUTF8ToJavaString(env, url.spec()); |
| 809 } | 809 } |
| 810 | 810 |
| 811 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle( | 811 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle( |
| 812 JNIEnv* env, jobject obj) const { | 812 JNIEnv* env, jobject obj) const { |
| 813 return ConvertUTF16ToJavaString(env, GetWebContents()->GetTitle()); | 813 return ConvertUTF16ToJavaString(env, GetWebContents()->GetTitle()); |
| 814 } | 814 } |
| 815 | 815 |
| 816 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) { | 816 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) { |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1424 | 1424 |
| 1425 AddNavigationEntryToHistory( | 1425 AddNavigationEntryToHistory( |
| 1426 env, obj, history, controller.GetEntryAtIndex(i), i); | 1426 env, obj, history, controller.GetEntryAtIndex(i), i); |
| 1427 num_added++; | 1427 num_added++; |
| 1428 } | 1428 } |
| 1429 } | 1429 } |
| 1430 | 1430 |
| 1431 ScopedJavaLocalRef<jstring> | 1431 ScopedJavaLocalRef<jstring> |
| 1432 ContentViewCoreImpl::GetOriginalUrlForActiveNavigationEntry(JNIEnv* env, | 1432 ContentViewCoreImpl::GetOriginalUrlForActiveNavigationEntry(JNIEnv* env, |
| 1433 jobject obj) { | 1433 jobject obj) { |
| 1434 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); | 1434 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); |
|
mkosiba (inactive)
2013/08/19 14:49:38
@apiccion
FYI. This should be fine but just to be
nasko
2013/09/12 17:56:31
@mkosiba, @apiccion
What is the conclusion on this
| |
| 1435 if (entry == NULL) | 1435 if (entry == NULL) |
| 1436 return ScopedJavaLocalRef<jstring>(env, NULL); | 1436 return ScopedJavaLocalRef<jstring>(env, NULL); |
| 1437 return ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec()); | 1437 return ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec()); |
| 1438 } | 1438 } |
| 1439 | 1439 |
| 1440 int ContentViewCoreImpl::GetNativeImeAdapter(JNIEnv* env, jobject obj) { | 1440 int ContentViewCoreImpl::GetNativeImeAdapter(JNIEnv* env, jobject obj) { |
| 1441 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); | 1441 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); |
| 1442 if (!rwhva) | 1442 if (!rwhva) |
| 1443 return 0; | 1443 return 0; |
| 1444 return rwhva->GetNativeImeAdapter(); | 1444 return rwhva->GetNativeImeAdapter(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1491 base::Bind(&JavaScriptResultCallback, j_callback); | 1491 base::Bind(&JavaScriptResultCallback, j_callback); |
| 1492 | 1492 |
| 1493 host->ExecuteJavascriptInWebFrameCallbackResult( | 1493 host->ExecuteJavascriptInWebFrameCallbackResult( |
| 1494 string16(), // frame_xpath | 1494 string16(), // frame_xpath |
| 1495 ConvertJavaStringToUTF16(env, script), | 1495 ConvertJavaStringToUTF16(env, script), |
| 1496 c_callback); | 1496 c_callback); |
| 1497 } | 1497 } |
| 1498 | 1498 |
| 1499 bool ContentViewCoreImpl::GetUseDesktopUserAgent( | 1499 bool ContentViewCoreImpl::GetUseDesktopUserAgent( |
| 1500 JNIEnv* env, jobject obj) { | 1500 JNIEnv* env, jobject obj) { |
| 1501 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); | 1501 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); |
| 1502 return entry && entry->GetIsOverridingUserAgent(); | 1502 return entry && entry->GetIsOverridingUserAgent(); |
| 1503 } | 1503 } |
| 1504 | 1504 |
| 1505 void ContentViewCoreImpl::UpdateImeAdapter(int native_ime_adapter, | 1505 void ContentViewCoreImpl::UpdateImeAdapter(int native_ime_adapter, |
| 1506 int text_input_type, | 1506 int text_input_type, |
| 1507 const std::string& text, | 1507 const std::string& text, |
| 1508 int selection_start, | 1508 int selection_start, |
| 1509 int selection_end, | 1509 int selection_end, |
| 1510 int composition_start, | 1510 int composition_start, |
| 1511 int composition_end, | 1511 int composition_end, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1540 | 1540 |
| 1541 void ContentViewCoreImpl::SetUseDesktopUserAgent( | 1541 void ContentViewCoreImpl::SetUseDesktopUserAgent( |
| 1542 JNIEnv* env, | 1542 JNIEnv* env, |
| 1543 jobject obj, | 1543 jobject obj, |
| 1544 jboolean enabled, | 1544 jboolean enabled, |
| 1545 jboolean reload_on_state_change) { | 1545 jboolean reload_on_state_change) { |
| 1546 if (GetUseDesktopUserAgent(env, obj) == enabled) | 1546 if (GetUseDesktopUserAgent(env, obj) == enabled) |
| 1547 return; | 1547 return; |
| 1548 | 1548 |
| 1549 // Make sure the navigation entry actually exists. | 1549 // Make sure the navigation entry actually exists. |
| 1550 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); | 1550 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); |
|
mkosiba (inactive)
2013/08/19 14:49:38
@dfalcantara:
FYI. I think this should be fine for
gone
2013/08/19 18:40:39
Should be alright if the visible entry updates bef
nasko
2013/09/12 17:56:31
Done.
| |
| 1551 if (!entry) | 1551 if (!entry) |
| 1552 return; | 1552 return; |
| 1553 | 1553 |
| 1554 // Set the flag in the NavigationEntry. | 1554 // Set the flag in the NavigationEntry. |
| 1555 entry->SetIsOverridingUserAgent(enabled); | 1555 entry->SetIsOverridingUserAgent(enabled); |
| 1556 | 1556 |
| 1557 // Send the override to the renderer. | 1557 // Send the override to the renderer. |
| 1558 if (reload_on_state_change) { | 1558 if (reload_on_state_change) { |
| 1559 // Reloading the page will send the override down as part of the | 1559 // Reloading the page will send the override down as part of the |
| 1560 // navigation IPC message. | 1560 // navigation IPC message. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1594 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1594 reinterpret_cast<ui::ViewAndroid*>(view_android), |
| 1595 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1595 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
| 1596 return reinterpret_cast<jint>(view); | 1596 return reinterpret_cast<jint>(view); |
| 1597 } | 1597 } |
| 1598 | 1598 |
| 1599 bool RegisterContentViewCore(JNIEnv* env) { | 1599 bool RegisterContentViewCore(JNIEnv* env) { |
| 1600 return RegisterNativesImpl(env); | 1600 return RegisterNativesImpl(env); |
| 1601 } | 1601 } |
| 1602 | 1602 |
| 1603 } // namespace content | 1603 } // namespace content |
| OLD | NEW |