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

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

Issue 23022006: Remove GetActiveEntry usage from content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing Save Page As code and test. Created 7 years, 3 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
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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 LoadUrl(params); 810 LoadUrl(params);
811 } 811 }
812 812
813 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { 813 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) {
814 return GetRenderProcessIdFromRenderViewHost( 814 return GetRenderProcessIdFromRenderViewHost(
815 web_contents_->GetRenderViewHost()); 815 web_contents_->GetRenderViewHost());
816 } 816 }
817 817
818 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL( 818 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL(
819 JNIEnv* env, jobject) const { 819 JNIEnv* env, jobject) const {
820 // The current users of the Java API expect to use the active entry
821 // rather than the visible entry, which is exposed by WebContents::GetURL.
822 content::NavigationEntry* entry = 820 content::NavigationEntry* entry =
823 web_contents_->GetController().GetActiveEntry(); 821 web_contents_->GetController().GetVisibleEntry();
824 GURL url = entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); 822 GURL url = entry ? entry->GetVirtualURL() : GURL::EmptyGURL();
Charlie Reis 2013/09/16 23:10:54 These lines can be replaced with web_contents_->Ge
nasko 2013/09/18 17:03:18 Very good point!
825 return ConvertUTF8ToJavaString(env, url.spec()); 823 return ConvertUTF8ToJavaString(env, url.spec());
826 } 824 }
827 825
828 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle( 826 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle(
829 JNIEnv* env, jobject obj) const { 827 JNIEnv* env, jobject obj) const {
830 return ConvertUTF16ToJavaString(env, GetWebContents()->GetTitle()); 828 return ConvertUTF16ToJavaString(env, GetWebContents()->GetTitle());
831 } 829 }
832 830
833 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) { 831 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) {
834 return GetWebContents()->GetBrowserContext()->IsOffTheRecord(); 832 return GetWebContents()->GetBrowserContext()->IsOffTheRecord();
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 1417
1420 AddNavigationEntryToHistory( 1418 AddNavigationEntryToHistory(
1421 env, obj, history, controller.GetEntryAtIndex(i), i); 1419 env, obj, history, controller.GetEntryAtIndex(i), i);
1422 num_added++; 1420 num_added++;
1423 } 1421 }
1424 } 1422 }
1425 1423
1426 ScopedJavaLocalRef<jstring> 1424 ScopedJavaLocalRef<jstring>
1427 ContentViewCoreImpl::GetOriginalUrlForActiveNavigationEntry(JNIEnv* env, 1425 ContentViewCoreImpl::GetOriginalUrlForActiveNavigationEntry(JNIEnv* env,
1428 jobject obj) { 1426 jobject obj) {
1429 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); 1427 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry();
1430 if (entry == NULL) 1428 if (entry == NULL)
1431 return ScopedJavaLocalRef<jstring>(env, NULL); 1429 return ScopedJavaLocalRef<jstring>(env, NULL);
1432 return ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec()); 1430 return ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec());
1433 } 1431 }
1434 1432
1435 int ContentViewCoreImpl::GetNativeImeAdapter(JNIEnv* env, jobject obj) { 1433 int ContentViewCoreImpl::GetNativeImeAdapter(JNIEnv* env, jobject obj) {
1436 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); 1434 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid();
1437 if (!rwhva) 1435 if (!rwhva)
1438 return 0; 1436 return 0;
1439 return rwhva->GetNativeImeAdapter(); 1437 return rwhva->GetNativeImeAdapter();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 base::Bind(&JavaScriptResultCallback, j_callback); 1492 base::Bind(&JavaScriptResultCallback, j_callback);
1495 1493
1496 rvh->ExecuteJavascriptInWebFrameCallbackResult( 1494 rvh->ExecuteJavascriptInWebFrameCallbackResult(
1497 string16(), // frame_xpath 1495 string16(), // frame_xpath
1498 ConvertJavaStringToUTF16(env, script), 1496 ConvertJavaStringToUTF16(env, script),
1499 c_callback); 1497 c_callback);
1500 } 1498 }
1501 1499
1502 bool ContentViewCoreImpl::GetUseDesktopUserAgent( 1500 bool ContentViewCoreImpl::GetUseDesktopUserAgent(
1503 JNIEnv* env, jobject obj) { 1501 JNIEnv* env, jobject obj) {
1504 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); 1502 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry();
1505 return entry && entry->GetIsOverridingUserAgent(); 1503 return entry && entry->GetIsOverridingUserAgent();
1506 } 1504 }
1507 1505
1508 void ContentViewCoreImpl::UpdateImeAdapter(int native_ime_adapter, 1506 void ContentViewCoreImpl::UpdateImeAdapter(int native_ime_adapter,
1509 int text_input_type, 1507 int text_input_type,
1510 const std::string& text, 1508 const std::string& text,
1511 int selection_start, 1509 int selection_start,
1512 int selection_end, 1510 int selection_end,
1513 int composition_start, 1511 int composition_start,
1514 int composition_end, 1512 int composition_end,
(...skipping 28 matching lines...) Expand all
1543 1541
1544 void ContentViewCoreImpl::SetUseDesktopUserAgent( 1542 void ContentViewCoreImpl::SetUseDesktopUserAgent(
1545 JNIEnv* env, 1543 JNIEnv* env,
1546 jobject obj, 1544 jobject obj,
1547 jboolean enabled, 1545 jboolean enabled,
1548 jboolean reload_on_state_change) { 1546 jboolean reload_on_state_change) {
1549 if (GetUseDesktopUserAgent(env, obj) == enabled) 1547 if (GetUseDesktopUserAgent(env, obj) == enabled)
1550 return; 1548 return;
1551 1549
1552 // Make sure the navigation entry actually exists. 1550 // Make sure the navigation entry actually exists.
1553 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); 1551 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry();
1554 if (!entry) 1552 if (!entry)
1555 return; 1553 return;
1556 1554
1557 // Set the flag in the NavigationEntry. 1555 // Set the flag in the NavigationEntry.
1558 entry->SetIsOverridingUserAgent(enabled); 1556 entry->SetIsOverridingUserAgent(enabled);
1559 1557
1560 // Send the override to the renderer. 1558 // Send the override to the renderer.
1561 if (reload_on_state_change) { 1559 if (reload_on_state_change) {
1562 // 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
1563 // navigation IPC message. 1561 // navigation IPC message.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 reinterpret_cast<ui::ViewAndroid*>(view_android), 1595 reinterpret_cast<ui::ViewAndroid*>(view_android),
1598 reinterpret_cast<ui::WindowAndroid*>(window_android)); 1596 reinterpret_cast<ui::WindowAndroid*>(window_android));
1599 return reinterpret_cast<jint>(view); 1597 return reinterpret_cast<jint>(view);
1600 } 1598 }
1601 1599
1602 bool RegisterContentViewCore(JNIEnv* env) { 1600 bool RegisterContentViewCore(JNIEnv* env) {
1603 return RegisterNativesImpl(env); 1601 return RegisterNativesImpl(env);
1604 } 1602 }
1605 1603
1606 } // namespace content 1604 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698