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

Unified Diff: chrome/browser/ui/android/autofill/autofill_popup_view_android.cc

Issue 14018004: [Android] Refactor NativeView to be able to use it for AutofillDialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/android/autofill/autofill_popup_view_android.cc
diff --git a/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc b/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc
index 3abf4449f05e51cc2160eed6a9d57342addb47e6..ed4d06a3f0e8f9e05b02438adad8f69024fb7fc7 100644
--- a/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc
+++ b/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc
@@ -10,11 +10,10 @@
#include "chrome/browser/ui/autofill/autofill_popup_controller.h"
#include "content/public/browser/android/content_view_core.h"
#include "jni/AutofillPopupGlue_jni.h"
+#include "ui/android/view_android.h"
#include "ui/gfx/android/window_android.h"
#include "ui/gfx/rect.h"
-using base::android::MethodID;
-
namespace autofill {
AutofillPopupViewAndroid::AutofillPopupViewAndroid(
@@ -25,13 +24,13 @@ AutofillPopupViewAndroid::~AutofillPopupViewAndroid() {}
void AutofillPopupViewAndroid::Show() {
JNIEnv* env = base::android::AttachCurrentThread();
- content::ContentViewCore* content_view_core = controller_->container_view();
+ ui::ViewAndroid* view_android = controller_->container_view();
java_object_.Reset(Java_AutofillPopupGlue_create(
env,
reinterpret_cast<jint>(this),
- content_view_core->GetWindowAndroid()->GetJavaObject().obj(),
- content_view_core->GetContainerViewDelegate().obj()));
+ view_android->GetWindowAndroid()->GetJavaObject().obj(),
+ view_android->GetJavaObject().obj()));
UpdateBoundsAndRedrawPopup();
}
@@ -54,28 +53,24 @@ void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() {
controller_->element_bounds().height());
// We need an array of AutofillSuggestion.
- ScopedJavaLocalRef<jclass> autofill_suggestion_clazz =
- base::android::GetClass(env,
- "org/chromium/chrome/browser/autofill/AutofillSuggestion");
- ScopedJavaLocalRef<jobjectArray> data_array(env,
- env->NewObjectArray(controller_->names().size(),
- autofill_suggestion_clazz.obj(), NULL));
- base::android::CheckException(env);
- for (size_t i = 0; i < controller_->names().size(); ++i) {
+ size_t count = controller_->names().size();
+
+ ScopedJavaLocalRef<jobjectArray> data_array =
+ Java_AutofillPopupGlue_createAutofillSuggestionArray(env, count);
+
+ for (size_t i = 0; i < count; ++i) {
ScopedJavaLocalRef<jstring> name =
- base::android::ConvertUTF16ToJavaString(
- env, controller_->names()[i]);
+ base::android::ConvertUTF16ToJavaString(env, controller_->names()[i]);
ScopedJavaLocalRef<jstring> subtext =
- base::android::ConvertUTF16ToJavaString(
- env, controller_->subtexts()[i]);
- int identifier = controller_->identifiers()[i];
- ScopedJavaLocalRef<jobject> data =
- Java_AutofillPopupGlue_createAutofillSuggestion(env,
- name.obj(),
- subtext.obj(),
- identifier);
- env->SetObjectArrayElement(data_array.obj(), i, data.obj());
- base::android::CheckException(env);
+ base::android::ConvertUTF16ToJavaString(env,
+ controller_->subtexts()[i]);
+ Java_AutofillPopupGlue_addToAutofillSuggestionArray(
+ env,
+ data_array.obj(),
+ i,
+ name.obj(),
+ subtext.obj(),
+ controller_->identifiers()[i]);
}
Java_AutofillPopupGlue_show(env, java_object_.obj(), data_array.obj());

Powered by Google App Engine
This is Rietveld 408576698