| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 ui::ViewAndroid* view_android = controller_->container_view(); | 62 ui::ViewAndroid* view_android = controller_->container_view(); |
| 63 | 63 |
| 64 DCHECK(view_android); | 64 DCHECK(view_android); |
| 65 | 65 |
| 66 popup_ = view_android->AcquireAnchorView(); | 66 popup_ = view_android->AcquireAnchorView(); |
| 67 const ScopedJavaLocalRef<jobject> view = popup_.view(); | 67 const ScopedJavaLocalRef<jobject> view = popup_.view(); |
| 68 if (view.is_null()) | 68 if (view.is_null()) |
| 69 return; | 69 return; |
| 70 JNIEnv* env = base::android::AttachCurrentThread(); | 70 JNIEnv* env = base::android::AttachCurrentThread(); |
| 71 java_object_.Reset(Java_PasswordGenerationPopupBridge_create( | 71 java_object_.Reset(Java_PasswordGenerationPopupBridge_create( |
| 72 env, view.obj(), reinterpret_cast<intptr_t>(this), | 72 env, view, reinterpret_cast<intptr_t>(this), |
| 73 view_android->GetWindowAndroid()->GetJavaObject().obj())); | 73 view_android->GetWindowAndroid()->GetJavaObject())); |
| 74 | 74 |
| 75 UpdateBoundsAndRedrawPopup(); | 75 UpdateBoundsAndRedrawPopup(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void PasswordGenerationPopupViewAndroid::Hide() { | 78 void PasswordGenerationPopupViewAndroid::Hide() { |
| 79 controller_ = NULL; | 79 controller_ = NULL; |
| 80 JNIEnv* env = base::android::AttachCurrentThread(); | 80 JNIEnv* env = base::android::AttachCurrentThread(); |
| 81 if (!java_object_.is_null()) { | 81 if (!java_object_.is_null()) { |
| 82 Java_PasswordGenerationPopupBridge_hide(env, java_object_.obj()); | 82 Java_PasswordGenerationPopupBridge_hide(env, java_object_); |
| 83 } else { | 83 } else { |
| 84 // Hide() should delete |this| either via Java dismiss or directly. | 84 // Hide() should delete |this| either via Java dismiss or directly. |
| 85 delete this; | 85 delete this; |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 gfx::Size PasswordGenerationPopupViewAndroid::GetPreferredSizeOfPasswordView() { | 89 gfx::Size PasswordGenerationPopupViewAndroid::GetPreferredSizeOfPasswordView() { |
| 90 static const int kUnusedSize = 0; | 90 static const int kUnusedSize = 0; |
| 91 return gfx::Size(kUnusedSize, kUnusedSize); | 91 return gfx::Size(kUnusedSize, kUnusedSize); |
| 92 } | 92 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 106 JNIEnv* env = base::android::AttachCurrentThread(); | 106 JNIEnv* env = base::android::AttachCurrentThread(); |
| 107 ScopedJavaLocalRef<jstring> password = | 107 ScopedJavaLocalRef<jstring> password = |
| 108 base::android::ConvertUTF16ToJavaString(env, controller_->password()); | 108 base::android::ConvertUTF16ToJavaString(env, controller_->password()); |
| 109 ScopedJavaLocalRef<jstring> suggestion = | 109 ScopedJavaLocalRef<jstring> suggestion = |
| 110 base::android::ConvertUTF16ToJavaString( | 110 base::android::ConvertUTF16ToJavaString( |
| 111 env, controller_->SuggestedText()); | 111 env, controller_->SuggestedText()); |
| 112 ScopedJavaLocalRef<jstring> help = | 112 ScopedJavaLocalRef<jstring> help = |
| 113 base::android::ConvertUTF16ToJavaString(env, controller_->HelpText()); | 113 base::android::ConvertUTF16ToJavaString(env, controller_->HelpText()); |
| 114 | 114 |
| 115 Java_PasswordGenerationPopupBridge_show( | 115 Java_PasswordGenerationPopupBridge_show( |
| 116 env, | 116 env, java_object_, controller_->IsRTL(), controller_->display_password(), |
| 117 java_object_.obj(), | 117 password, suggestion, help, controller_->HelpTextLinkRange().start(), |
| 118 controller_->IsRTL(), | |
| 119 controller_->display_password(), | |
| 120 password.obj(), | |
| 121 suggestion.obj(), | |
| 122 help.obj(), | |
| 123 controller_->HelpTextLinkRange().start(), | |
| 124 controller_->HelpTextLinkRange().end()); | 118 controller_->HelpTextLinkRange().end()); |
| 125 } | 119 } |
| 126 | 120 |
| 127 void PasswordGenerationPopupViewAndroid::PasswordSelectionUpdated() {} | 121 void PasswordGenerationPopupViewAndroid::PasswordSelectionUpdated() {} |
| 128 | 122 |
| 129 bool PasswordGenerationPopupViewAndroid::IsPointInPasswordBounds( | 123 bool PasswordGenerationPopupViewAndroid::IsPointInPasswordBounds( |
| 130 const gfx::Point& point) { | 124 const gfx::Point& point) { |
| 131 NOTREACHED(); | 125 NOTREACHED(); |
| 132 return false; | 126 return false; |
| 133 } | 127 } |
| 134 | 128 |
| 135 // static | 129 // static |
| 136 PasswordGenerationPopupView* PasswordGenerationPopupView::Create( | 130 PasswordGenerationPopupView* PasswordGenerationPopupView::Create( |
| 137 PasswordGenerationPopupController* controller) { | 131 PasswordGenerationPopupController* controller) { |
| 138 return new PasswordGenerationPopupViewAndroid(controller); | 132 return new PasswordGenerationPopupViewAndroid(controller); |
| 139 } | 133 } |
| 140 | 134 |
| 141 } // namespace autofill | 135 } // namespace autofill |
| OLD | NEW |