| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/android/autofill/password_generation_popup_view_andr
oid.h" | 5 #include "chrome/browser/ui/android/autofill/password_generation_popup_view_andr
oid.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 | 55 |
| 56 PasswordGenerationPopupViewAndroid::~PasswordGenerationPopupViewAndroid() {} | 56 PasswordGenerationPopupViewAndroid::~PasswordGenerationPopupViewAndroid() {} |
| 57 | 57 |
| 58 void PasswordGenerationPopupViewAndroid::Show() { | 58 void PasswordGenerationPopupViewAndroid::Show() { |
| 59 JNIEnv* env = base::android::AttachCurrentThread(); | 59 JNIEnv* env = base::android::AttachCurrentThread(); |
| 60 ui::ViewAndroid* view_android = controller_->container_view(); | 60 ui::ViewAndroid* view_android = controller_->container_view(); |
| 61 | 61 |
| 62 DCHECK(view_android); | 62 DCHECK(view_android); |
| 63 | 63 |
| 64 ScopedJavaLocalRef<jobject> anchor_view = |
| 65 view_android->AcquireAnchorView(controller_->element_bounds()); |
| 64 java_object_.Reset(Java_PasswordGenerationPopupBridge_create( | 66 java_object_.Reset(Java_PasswordGenerationPopupBridge_create( |
| 65 env, reinterpret_cast<intptr_t>(this), | 67 env, anchor_view.obj(), controller_->element_bounds().width(), |
| 68 reinterpret_cast<intptr_t>(this), |
| 66 view_android->GetWindowAndroid()->GetJavaObject().obj(), | 69 view_android->GetWindowAndroid()->GetJavaObject().obj(), |
| 67 view_android->GetViewAndroidDelegate().obj())); | 70 view_android->GetViewAndroidDelegate().obj())); |
| 68 | 71 |
| 69 UpdateBoundsAndRedrawPopup(); | 72 UpdateBoundsAndRedrawPopup(); |
| 70 } | 73 } |
| 71 | 74 |
| 72 void PasswordGenerationPopupViewAndroid::Hide() { | 75 void PasswordGenerationPopupViewAndroid::Hide() { |
| 73 controller_ = NULL; | 76 controller_ = NULL; |
| 74 JNIEnv* env = base::android::AttachCurrentThread(); | 77 JNIEnv* env = base::android::AttachCurrentThread(); |
| 75 Java_PasswordGenerationPopupBridge_hide(env, java_object_.obj()); | 78 Java_PasswordGenerationPopupBridge_hide(env, java_object_.obj()); |
| 76 } | 79 } |
| 77 | 80 |
| 78 gfx::Size PasswordGenerationPopupViewAndroid::GetPreferredSizeOfPasswordView() { | 81 gfx::Size PasswordGenerationPopupViewAndroid::GetPreferredSizeOfPasswordView() { |
| 79 static const int kUnusedSize = 0; | 82 static const int kUnusedSize = 0; |
| 80 return gfx::Size(kUnusedSize, kUnusedSize); | 83 return gfx::Size(kUnusedSize, kUnusedSize); |
| 81 } | 84 } |
| 82 | 85 |
| 83 void PasswordGenerationPopupViewAndroid::UpdateBoundsAndRedrawPopup() { | 86 void PasswordGenerationPopupViewAndroid::UpdateBoundsAndRedrawPopup() { |
| 84 JNIEnv* env = base::android::AttachCurrentThread(); | 87 JNIEnv* env = base::android::AttachCurrentThread(); |
| 85 Java_PasswordGenerationPopupBridge_setAnchorRect( | |
| 86 env, | |
| 87 java_object_.obj(), | |
| 88 controller_->element_bounds().x(), | |
| 89 controller_->element_bounds().y(), | |
| 90 controller_->element_bounds().width(), | |
| 91 controller_->element_bounds().height()); | |
| 92 | |
| 93 ScopedJavaLocalRef<jstring> password = | 88 ScopedJavaLocalRef<jstring> password = |
| 94 base::android::ConvertUTF16ToJavaString(env, controller_->password()); | 89 base::android::ConvertUTF16ToJavaString(env, controller_->password()); |
| 95 ScopedJavaLocalRef<jstring> suggestion = | 90 ScopedJavaLocalRef<jstring> suggestion = |
| 96 base::android::ConvertUTF16ToJavaString( | 91 base::android::ConvertUTF16ToJavaString( |
| 97 env, controller_->SuggestedText()); | 92 env, controller_->SuggestedText()); |
| 98 ScopedJavaLocalRef<jstring> help = | 93 ScopedJavaLocalRef<jstring> help = |
| 99 base::android::ConvertUTF16ToJavaString(env, controller_->HelpText()); | 94 base::android::ConvertUTF16ToJavaString(env, controller_->HelpText()); |
| 100 | 95 |
| 101 Java_PasswordGenerationPopupBridge_show( | 96 Java_PasswordGenerationPopupBridge_show( |
| 102 env, | 97 env, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 118 return false; | 113 return false; |
| 119 } | 114 } |
| 120 | 115 |
| 121 // static | 116 // static |
| 122 PasswordGenerationPopupView* PasswordGenerationPopupView::Create( | 117 PasswordGenerationPopupView* PasswordGenerationPopupView::Create( |
| 123 PasswordGenerationPopupController* controller) { | 118 PasswordGenerationPopupController* controller) { |
| 124 return new PasswordGenerationPopupViewAndroid(controller); | 119 return new PasswordGenerationPopupViewAndroid(controller); |
| 125 } | 120 } |
| 126 | 121 |
| 127 } // namespace autofill | 122 } // namespace autofill |
| OLD | NEW |