Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 25674019: Make sure to show the correct URL from CVC. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 return ConvertUTF8ToJavaString(env, GetWebContents()->GetURL().spec());
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());
831 } 826 }
832 827
833 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle( 828 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle(
834 JNIEnv* env, jobject obj) const { 829 JNIEnv* env, jobject obj) const {
835 return ConvertUTF16ToJavaString(env, GetWebContents()->GetTitle()); 830 return ConvertUTF16ToJavaString(env, GetWebContents()->GetTitle());
836 } 831 }
837 832
838 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) { 833 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) {
839 return GetWebContents()->GetBrowserContext()->IsOffTheRecord(); 834 return GetWebContents()->GetBrowserContext()->IsOffTheRecord();
840 } 835 }
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 1423
1429 AddNavigationEntryToHistory( 1424 AddNavigationEntryToHistory(
1430 env, obj, history, controller.GetEntryAtIndex(i), i); 1425 env, obj, history, controller.GetEntryAtIndex(i), i);
1431 num_added++; 1426 num_added++;
1432 } 1427 }
1433 } 1428 }
1434 1429
1435 ScopedJavaLocalRef<jstring> 1430 ScopedJavaLocalRef<jstring>
1436 ContentViewCoreImpl::GetOriginalUrlForActiveNavigationEntry(JNIEnv* env, 1431 ContentViewCoreImpl::GetOriginalUrlForActiveNavigationEntry(JNIEnv* env,
1437 jobject obj) { 1432 jobject obj) {
1438 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); 1433 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry();
1439 if (entry == NULL) 1434 if (entry == NULL)
1440 return ScopedJavaLocalRef<jstring>(env, NULL); 1435 return ScopedJavaLocalRef<jstring>(env, NULL);
1441 return ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec()); 1436 return ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec());
1442 } 1437 }
1443 1438
1444 int ContentViewCoreImpl::GetNativeImeAdapter(JNIEnv* env, jobject obj) { 1439 int ContentViewCoreImpl::GetNativeImeAdapter(JNIEnv* env, jobject obj) {
1445 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); 1440 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid();
1446 if (!rwhva) 1441 if (!rwhva)
1447 return 0; 1442 return 0;
1448 return rwhva->GetNativeImeAdapter(); 1443 return rwhva->GetNativeImeAdapter();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 base::Bind(&JavaScriptResultCallback, j_callback); 1494 base::Bind(&JavaScriptResultCallback, j_callback);
1500 1495
1501 rvh->ExecuteJavascriptInWebFrameCallbackResult( 1496 rvh->ExecuteJavascriptInWebFrameCallbackResult(
1502 string16(), // frame_xpath 1497 string16(), // frame_xpath
1503 ConvertJavaStringToUTF16(env, script), 1498 ConvertJavaStringToUTF16(env, script),
1504 c_callback); 1499 c_callback);
1505 } 1500 }
1506 1501
1507 bool ContentViewCoreImpl::GetUseDesktopUserAgent( 1502 bool ContentViewCoreImpl::GetUseDesktopUserAgent(
1508 JNIEnv* env, jobject obj) { 1503 JNIEnv* env, jobject obj) {
1509 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); 1504 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry();
1510 return entry && entry->GetIsOverridingUserAgent(); 1505 return entry && entry->GetIsOverridingUserAgent();
1511 } 1506 }
1512 1507
1513 void ContentViewCoreImpl::UpdateImeAdapter(int native_ime_adapter, 1508 void ContentViewCoreImpl::UpdateImeAdapter(int native_ime_adapter,
1514 int text_input_type, 1509 int text_input_type,
1515 const std::string& text, 1510 const std::string& text,
1516 int selection_start, 1511 int selection_start,
1517 int selection_end, 1512 int selection_end,
1518 int composition_start, 1513 int composition_start,
1519 int composition_end, 1514 int composition_end,
(...skipping 21 matching lines...) Expand all
1541 1536
1542 void ContentViewCoreImpl::SetUseDesktopUserAgent( 1537 void ContentViewCoreImpl::SetUseDesktopUserAgent(
1543 JNIEnv* env, 1538 JNIEnv* env,
1544 jobject obj, 1539 jobject obj,
1545 jboolean enabled, 1540 jboolean enabled,
1546 jboolean reload_on_state_change) { 1541 jboolean reload_on_state_change) {
1547 if (GetUseDesktopUserAgent(env, obj) == enabled) 1542 if (GetUseDesktopUserAgent(env, obj) == enabled)
1548 return; 1543 return;
1549 1544
1550 // Make sure the navigation entry actually exists. 1545 // Make sure the navigation entry actually exists.
1551 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); 1546 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry();
1552 if (!entry) 1547 if (!entry)
1553 return; 1548 return;
1554 1549
1555 // Set the flag in the NavigationEntry. 1550 // Set the flag in the NavigationEntry.
1556 entry->SetIsOverridingUserAgent(enabled); 1551 entry->SetIsOverridingUserAgent(enabled);
1557 1552
1558 // Send the override to the renderer. 1553 // Send the override to the renderer.
1559 if (reload_on_state_change) { 1554 if (reload_on_state_change) {
1560 // Reloading the page will send the override down as part of the 1555 // Reloading the page will send the override down as part of the
1561 // navigation IPC message. 1556 // navigation IPC message.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 reinterpret_cast<ui::ViewAndroid*>(view_android), 1595 reinterpret_cast<ui::ViewAndroid*>(view_android),
1601 reinterpret_cast<ui::WindowAndroid*>(window_android)); 1596 reinterpret_cast<ui::WindowAndroid*>(window_android));
1602 return reinterpret_cast<jint>(view); 1597 return reinterpret_cast<jint>(view);
1603 } 1598 }
1604 1599
1605 bool RegisterContentViewCore(JNIEnv* env) { 1600 bool RegisterContentViewCore(JNIEnv* env) {
1606 return RegisterNativesImpl(env); 1601 return RegisterNativesImpl(env);
1607 } 1602 }
1608 1603
1609 } // namespace content 1604 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698