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

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: rebase 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
« no previous file with comments | « chrome/browser/platform_util_android.cc ('k') | content/browser/android/content_view_core_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 29f92ae2c2a30919dbfa7af3da77150cedaad46a..6acc0c88d0ac2617561df63aa3439e553d150f6d 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/android/window_android.h"
#include "ui/gfx/rect.h"
-using base::android::MethodID;
-
namespace autofill {
AutofillPopupViewAndroid::AutofillPopupViewAndroid(
@@ -25,13 +24,15 @@ 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();
+
+ DCHECK(view_android);
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 +55,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());
« no previous file with comments | « chrome/browser/platform_util_android.cc ('k') | content/browser/android/content_view_core_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698