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

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

Issue 10830066: Non-functional cleanup in ContentViewCore (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 (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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 RenderWidgetHostView* rwhv = NULL; 113 RenderWidgetHostView* rwhv = NULL;
114 if (web_contents_) 114 if (web_contents_)
115 rwhv = web_contents_->GetRenderWidgetHostView(); 115 rwhv = web_contents_->GetRenderWidgetHostView();
116 return static_cast<RenderWidgetHostViewAndroid*>(rwhv); 116 return static_cast<RenderWidgetHostViewAndroid*>(rwhv);
117 } 117 }
118 118
119 // ---------------------------------------------------------------------------- 119 // ----------------------------------------------------------------------------
120 // Methods called from Java via JNI 120 // Methods called from Java via JNI
121 // ---------------------------------------------------------------------------- 121 // ----------------------------------------------------------------------------
122 122
123 void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env, jobject obj,
124 jintArray indices) {
125 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
126 web_contents_->GetRenderViewHost());
127 DCHECK(rvhi);
128 if (indices == NULL) {
129 rvhi->DidCancelPopupMenu();
130 return;
131 }
132
133 int selected_count = env->GetArrayLength(indices);
134 std::vector<int> selected_indices;
135 jint* indices_ptr = env->GetIntArrayElements(indices, NULL);
136 for (int i = 0; i < selected_count; ++i)
137 selected_indices.push_back(indices_ptr[i]);
138 env->ReleaseIntArrayElements(indices, indices_ptr, JNI_ABORT);
139 rvhi->DidSelectPopupMenuItems(selected_indices);
140 }
141
123 void ContentViewCoreImpl::LoadUrlWithoutUrlSanitization(JNIEnv* env, 142 void ContentViewCoreImpl::LoadUrlWithoutUrlSanitization(JNIEnv* env,
124 jobject, 143 jobject,
125 jstring jurl, 144 jstring jurl,
126 int page_transition) { 145 int page_transition) {
127 GURL url(base::android::ConvertJavaStringToUTF8(env, jurl)); 146 GURL url(base::android::ConvertJavaStringToUTF8(env, jurl));
128 147
129 LoadUrl(url, page_transition); 148 LoadUrl(url, page_transition);
130 } 149 }
131 150
132 void ContentViewCoreImpl::LoadUrlWithoutUrlSanitizationWithUserAgentOverride( 151 void ContentViewCoreImpl::LoadUrlWithoutUrlSanitizationWithUserAgentOverride(
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) { 505 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) {
487 JNIEnv* env = AttachCurrentThread(); 506 JNIEnv* env = AttachCurrentThread();
488 ScopedJavaLocalRef<jstring> jcontent_url = 507 ScopedJavaLocalRef<jstring> jcontent_url =
489 ConvertUTF8ToJavaString(env, content_url.spec()); 508 ConvertUTF8ToJavaString(env, content_url.spec());
490 Java_ContentViewCore_startContentIntent(env, 509 Java_ContentViewCore_startContentIntent(env,
491 java_object_->View(env).obj(), 510 java_object_->View(env).obj(),
492 jcontent_url.obj()); 511 jcontent_url.obj());
493 } 512 }
494 513
495 // -------------------------------------------------------------------------- 514 // --------------------------------------------------------------------------
496 // Methods called from Java via JNI
497 // --------------------------------------------------------------------------
498
499 void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env, jobject obj,
500 jintArray indices) {
501 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
502 web_contents_->GetRenderViewHost());
503 DCHECK(rvhi);
504 if (indices == NULL) {
505 rvhi->DidCancelPopupMenu();
506 return;
507 }
508
509 int selected_count = env->GetArrayLength(indices);
510 std::vector<int> selected_indices;
511 jint* indices_ptr = env->GetIntArrayElements(indices, NULL);
512 for (int i = 0; i < selected_count; ++i)
513 selected_indices.push_back(indices_ptr[i]);
514 env->ReleaseIntArrayElements(indices, indices_ptr, JNI_ABORT);
515 rvhi->DidSelectPopupMenuItems(selected_indices);
516 }
517
518 // --------------------------------------------------------------------------
519 // Methods called from native code 515 // Methods called from native code
520 // -------------------------------------------------------------------------- 516 // --------------------------------------------------------------------------
521 517
522 gfx::Rect ContentViewCoreImpl::GetBounds() const { 518 gfx::Rect ContentViewCoreImpl::GetBounds() const {
523 NOTIMPLEMENTED() << "not upstreamed yet"; 519 NOTIMPLEMENTED() << "not upstreamed yet";
524 return gfx::Rect(); 520 return gfx::Rect();
525 } 521 }
526 522
527 // ---------------------------------------------------------------------------- 523 // ----------------------------------------------------------------------------
528 524
529 bool RegisterContentViewCore(JNIEnv* env) { 525 bool RegisterContentViewCore(JNIEnv* env) {
530 if (!base::android::HasClass(env, kContentViewCoreClassPath)) { 526 if (!base::android::HasClass(env, kContentViewCoreClassPath)) {
531 DLOG(ERROR) << "Unable to find class ContentViewCore!"; 527 DLOG(ERROR) << "Unable to find class ContentViewCore!";
532 return false; 528 return false;
533 } 529 }
534 ScopedJavaLocalRef<jclass> clazz = GetClass(env, kContentViewCoreClassPath); 530 ScopedJavaLocalRef<jclass> clazz = GetClass(env, kContentViewCoreClassPath);
535 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { 531 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) {
536 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; 532 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!";
537 return false; 533 return false;
538 } 534 }
539 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); 535 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I");
540 536
541 return RegisterNativesImpl(env) >= 0; 537 return RegisterNativesImpl(env) >= 0;
542 } 538 }
543 539
544 } // namespace content 540 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698