| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/autofill_dialog_view_android.h" | 5 #include "chrome/browser/ui/android/autofill/autofill_dialog_view_android.h" |
| 6 #include "base/android/jni_android.h" | 6 #include "base/android/jni_android.h" |
| 7 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 void AutofillDialogViewAndroid::UpdateAccountChooser() { | 99 void AutofillDialogViewAndroid::UpdateAccountChooser() { |
| 100 JNIEnv* env = base::android::AttachCurrentThread(); | 100 JNIEnv* env = base::android::AttachCurrentThread(); |
| 101 std::vector<string16> account_names; | 101 std::vector<string16> account_names; |
| 102 int selected_account_index = -1; | 102 int selected_account_index = -1; |
| 103 | 103 |
| 104 ui::MenuModel* model = controller_->MenuModelForAccountChooser(); | 104 ui::MenuModel* model = controller_->MenuModelForAccountChooser(); |
| 105 if (!model || controller_->ShouldShowSpinner()) { | 105 if (!model || controller_->ShouldShowSpinner()) { |
| 106 account_names.push_back(controller_->AccountChooserText()); | 106 account_names.push_back(controller_->AccountChooserText()); |
| 107 selected_account_index = 0; | |
| 108 } else { | 107 } else { |
| 109 for (int i = 0; i < model->GetItemCount(); ++i) { | 108 for (int i = 0; i < model->GetItemCount(); ++i) { |
| 110 if (model->IsItemCheckedAt(i)) | 109 if (model->IsItemCheckedAt(i)) |
| 111 selected_account_index = i; | 110 selected_account_index = i; |
| 112 account_names.push_back(model->GetLabelAt(i)); | 111 account_names.push_back(model->GetLabelAt(i)); |
| 113 } | 112 } |
| 114 } | 113 } |
| 115 | 114 |
| 116 ScopedJavaLocalRef<jobjectArray> jaccount_names = | 115 ScopedJavaLocalRef<jobjectArray> jaccount_names = |
| 117 base::android::ToJavaArrayOfStrings(env, account_names); | 116 base::android::ToJavaArrayOfStrings(env, account_names); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 268 } |
| 270 | 269 |
| 271 ScopedJavaLocalRef<jstring> AutofillDialogViewAndroid::GetSaveLocallyText( | 270 ScopedJavaLocalRef<jstring> AutofillDialogViewAndroid::GetSaveLocallyText( |
| 272 JNIEnv* env, | 271 JNIEnv* env, |
| 273 jobject obj) { | 272 jobject obj) { |
| 274 return base::android::ConvertUTF16ToJavaString( | 273 return base::android::ConvertUTF16ToJavaString( |
| 275 env, | 274 env, |
| 276 controller_->SaveLocallyText()); | 275 controller_->SaveLocallyText()); |
| 277 } | 276 } |
| 278 | 277 |
| 278 ScopedJavaLocalRef<jstring> AutofillDialogViewAndroid::GetLegalDocumentsText( |
| 279 JNIEnv* env, |
| 280 jobject obj) { |
| 281 return base::android::ConvertUTF16ToJavaString( |
| 282 env, |
| 283 controller_->LegalDocumentsText()); |
| 284 } |
| 285 |
| 279 ScopedJavaLocalRef<jstring> AutofillDialogViewAndroid::GetProgressBarText( | 286 ScopedJavaLocalRef<jstring> AutofillDialogViewAndroid::GetProgressBarText( |
| 280 JNIEnv* env, | 287 JNIEnv* env, |
| 281 jobject obj) { | 288 jobject obj) { |
| 282 return base::android::ConvertUTF16ToJavaString( | 289 return base::android::ConvertUTF16ToJavaString( |
| 283 env, | 290 env, |
| 284 controller_->ProgressBarText()); | 291 controller_->ProgressBarText()); |
| 285 } | 292 } |
| 286 | 293 |
| 287 void AutofillDialogViewAndroid::AccountSelected(JNIEnv* env, jobject obj, | 294 void AutofillDialogViewAndroid::AccountSelected(JNIEnv* env, jobject obj, |
| 288 jint index) { | 295 jint index) { |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 | 752 |
| 746 if (label.empty()) | 753 if (label.empty()) |
| 747 return false; | 754 return false; |
| 748 | 755 |
| 749 *label_to_set = label; | 756 *label_to_set = label; |
| 750 *sublabel_to_set = sublabel; | 757 *sublabel_to_set = sublabel; |
| 751 *icon_to_set = icon; | 758 *icon_to_set = icon; |
| 752 return true; | 759 return true; |
| 753 } | 760 } |
| 754 } // namespace autofill | 761 } // namespace autofill |
| OLD | NEW |