Chromium Code Reviews| 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 popup_ = view_android->AcquireAnchorView(); | |
| 65 if (popup_.is_null()) | |
| 66 return; | |
| 64 java_object_.Reset(Java_PasswordGenerationPopupBridge_create( | 67 java_object_.Reset(Java_PasswordGenerationPopupBridge_create( |
| 65 env, reinterpret_cast<intptr_t>(this), | 68 env, popup_.view().obj(), controller_->element_bounds().width(), |
| 66 view_android->GetWindowAndroid()->GetJavaObject().obj(), | 69 reinterpret_cast<intptr_t>(this), |
| 67 view_android->GetViewAndroidDelegate().obj())); | 70 view_android->GetWindowAndroid()->GetJavaObject().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(); |
|
no sievers
2016/07/19 22:29:30
This needs to avoid the Java call now if |!java_ob
Jinsuk Kim
2016/07/20 00:55:18
Done.
| |
| 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( | 88 ui::ViewAndroid* view_android = controller_->container_view(); |
| 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 | 89 |
| 90 DCHECK(view_android); | |
| 91 view_android->SetAnchorRect(popup_.view(), controller_->element_bounds()); | |
| 93 ScopedJavaLocalRef<jstring> password = | 92 ScopedJavaLocalRef<jstring> password = |
| 94 base::android::ConvertUTF16ToJavaString(env, controller_->password()); | 93 base::android::ConvertUTF16ToJavaString(env, controller_->password()); |
| 95 ScopedJavaLocalRef<jstring> suggestion = | 94 ScopedJavaLocalRef<jstring> suggestion = |
| 96 base::android::ConvertUTF16ToJavaString( | 95 base::android::ConvertUTF16ToJavaString( |
| 97 env, controller_->SuggestedText()); | 96 env, controller_->SuggestedText()); |
| 98 ScopedJavaLocalRef<jstring> help = | 97 ScopedJavaLocalRef<jstring> help = |
| 99 base::android::ConvertUTF16ToJavaString(env, controller_->HelpText()); | 98 base::android::ConvertUTF16ToJavaString(env, controller_->HelpText()); |
| 100 | 99 |
|
no sievers
2016/07/19 22:29:30
same here
Jinsuk Kim
2016/07/20 00:55:18
Done.
| |
| 101 Java_PasswordGenerationPopupBridge_show( | 100 Java_PasswordGenerationPopupBridge_show( |
| 102 env, | 101 env, |
| 103 java_object_.obj(), | 102 java_object_.obj(), |
| 104 controller_->IsRTL(), | 103 controller_->IsRTL(), |
| 105 controller_->display_password(), | 104 controller_->display_password(), |
| 106 password.obj(), | 105 password.obj(), |
| 107 suggestion.obj(), | 106 suggestion.obj(), |
| 108 help.obj(), | 107 help.obj(), |
| 109 controller_->HelpTextLinkRange().start(), | 108 controller_->HelpTextLinkRange().start(), |
| 110 controller_->HelpTextLinkRange().end()); | 109 controller_->HelpTextLinkRange().end()); |
| 111 } | 110 } |
| 112 | 111 |
| 113 void PasswordGenerationPopupViewAndroid::PasswordSelectionUpdated() {} | 112 void PasswordGenerationPopupViewAndroid::PasswordSelectionUpdated() {} |
| 114 | 113 |
| 115 bool PasswordGenerationPopupViewAndroid::IsPointInPasswordBounds( | 114 bool PasswordGenerationPopupViewAndroid::IsPointInPasswordBounds( |
| 116 const gfx::Point& point) { | 115 const gfx::Point& point) { |
| 117 NOTREACHED(); | 116 NOTREACHED(); |
| 118 return false; | 117 return false; |
| 119 } | 118 } |
| 120 | 119 |
| 121 // static | 120 // static |
| 122 PasswordGenerationPopupView* PasswordGenerationPopupView::Create( | 121 PasswordGenerationPopupView* PasswordGenerationPopupView::Create( |
| 123 PasswordGenerationPopupController* controller) { | 122 PasswordGenerationPopupController* controller) { |
| 124 return new PasswordGenerationPopupViewAndroid(controller); | 123 return new PasswordGenerationPopupViewAndroid(controller); |
| 125 } | 124 } |
| 126 | 125 |
| 127 } // namespace autofill | 126 } // namespace autofill |
| OLD | NEW |