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 19 matching lines...) Expand all Loading... |
30 // AutofillDialogView ---------------------------------------------------------- | 30 // AutofillDialogView ---------------------------------------------------------- |
31 | 31 |
32 AutofillDialogViewAndroid::AutofillDialogViewAndroid( | 32 AutofillDialogViewAndroid::AutofillDialogViewAndroid( |
33 AutofillDialogController* controller) | 33 AutofillDialogController* controller) |
34 : controller_(controller) {} | 34 : controller_(controller) {} |
35 | 35 |
36 AutofillDialogViewAndroid::~AutofillDialogViewAndroid() {} | 36 AutofillDialogViewAndroid::~AutofillDialogViewAndroid() {} |
37 | 37 |
38 void AutofillDialogViewAndroid::Show() { | 38 void AutofillDialogViewAndroid::Show() { |
39 JNIEnv* env = base::android::AttachCurrentThread(); | 39 JNIEnv* env = base::android::AttachCurrentThread(); |
40 ScopedJavaLocalRef<jstring> use_billing_for_shipping_text = | |
41 base::android::ConvertUTF16ToJavaString( | |
42 env, controller_->UseBillingForShippingText()); | |
43 ScopedJavaLocalRef<jstring> save_locally_text = | 40 ScopedJavaLocalRef<jstring> save_locally_text = |
44 base::android::ConvertUTF16ToJavaString( | 41 base::android::ConvertUTF16ToJavaString( |
45 env, controller_->SaveLocallyText()); | 42 env, controller_->SaveLocallyText()); |
46 java_object_.Reset(Java_AutofillDialogGlue_create( | 43 java_object_.Reset(Java_AutofillDialogGlue_create( |
47 env, | 44 env, |
48 reinterpret_cast<jint>(this), | 45 reinterpret_cast<jint>(this), |
49 WindowAndroidHelper::FromWebContents(controller_->web_contents())-> | 46 WindowAndroidHelper::FromWebContents(controller_->web_contents())-> |
50 GetWindowAndroid()->GetJavaObject().obj(), | 47 GetWindowAndroid()->GetJavaObject().obj(), |
51 use_billing_for_shipping_text.obj(), | |
52 save_locally_text.obj())); | 48 save_locally_text.obj())); |
53 } | 49 } |
54 | 50 |
55 void AutofillDialogViewAndroid::Hide() { | 51 void AutofillDialogViewAndroid::Hide() { |
56 NOTIMPLEMENTED(); | 52 NOTIMPLEMENTED(); |
57 } | 53 } |
58 | 54 |
59 void AutofillDialogViewAndroid::UpdateNotificationArea() { | 55 void AutofillDialogViewAndroid::UpdateNotificationArea() { |
60 JNIEnv* env = base::android::AttachCurrentThread(); | 56 JNIEnv* env = base::android::AttachCurrentThread(); |
61 std::vector<DialogNotification> notifications = | 57 std::vector<DialogNotification> notifications = |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 env, java_object_.obj(), controller_->ShouldOfferToSaveInChrome()); | 208 env, java_object_.obj(), controller_->ShouldOfferToSaveInChrome()); |
213 } | 209 } |
214 | 210 |
215 string16 AutofillDialogViewAndroid::GetCvc() { | 211 string16 AutofillDialogViewAndroid::GetCvc() { |
216 JNIEnv* env = base::android::AttachCurrentThread(); | 212 JNIEnv* env = base::android::AttachCurrentThread(); |
217 ScopedJavaLocalRef<jstring> cvc = | 213 ScopedJavaLocalRef<jstring> cvc = |
218 Java_AutofillDialogGlue_getCvc(env, java_object_.obj()); | 214 Java_AutofillDialogGlue_getCvc(env, java_object_.obj()); |
219 return base::android::ConvertJavaStringToUTF16(env, cvc.obj()); | 215 return base::android::ConvertJavaStringToUTF16(env, cvc.obj()); |
220 } | 216 } |
221 | 217 |
222 bool AutofillDialogViewAndroid::UseBillingForShipping() { | |
223 JNIEnv* env = base::android::AttachCurrentThread(); | |
224 return Java_AutofillDialogGlue_shouldUseBillingForShipping( | |
225 env, java_object_.obj()); | |
226 } | |
227 | |
228 bool AutofillDialogViewAndroid::SaveDetailsLocally() { | 218 bool AutofillDialogViewAndroid::SaveDetailsLocally() { |
229 JNIEnv* env = base::android::AttachCurrentThread(); | 219 JNIEnv* env = base::android::AttachCurrentThread(); |
230 return Java_AutofillDialogGlue_shouldSaveDetailsLocally(env, | 220 return Java_AutofillDialogGlue_shouldSaveDetailsLocally(env, |
231 java_object_.obj()); | 221 java_object_.obj()); |
232 } | 222 } |
233 | 223 |
234 const content::NavigationController* AutofillDialogViewAndroid::ShowSignIn() { | 224 const content::NavigationController* AutofillDialogViewAndroid::ShowSignIn() { |
235 NOTIMPLEMENTED(); | 225 NOTIMPLEMENTED(); |
236 return NULL; | 226 return NULL; |
237 } | 227 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 ui::MenuModel* model = controller_->MenuModelForAccountChooser(); | 316 ui::MenuModel* model = controller_->MenuModelForAccountChooser(); |
327 if (!model) | 317 if (!model) |
328 return; | 318 return; |
329 | 319 |
330 model->ActivatedAt(index); | 320 model->ActivatedAt(index); |
331 } | 321 } |
332 | 322 |
333 void AutofillDialogViewAndroid::EditingStart(JNIEnv* env, jobject obj, | 323 void AutofillDialogViewAndroid::EditingStart(JNIEnv* env, jobject obj, |
334 jint jsection) { | 324 jint jsection) { |
335 const DialogSection section = static_cast<DialogSection>(jsection); | 325 const DialogSection section = static_cast<DialogSection>(jsection); |
| 326 // TODO(estade): respect |suggestion_state.text_style|. |
336 const SuggestionState& suggestion_state = | 327 const SuggestionState& suggestion_state = |
337 controller_->SuggestionStateForSection(section); | 328 controller_->SuggestionStateForSection(section); |
338 if (suggestion_state.text.empty()) { | 329 if (suggestion_state.text.empty()) { |
339 // The section is already in the editing mode, or it's the "Add...". | 330 // The section is already in the editing mode, or it's the "Add...". |
340 return; | 331 return; |
341 } | 332 } |
342 | 333 |
343 controller_->EditClickedForSection(section); | 334 controller_->EditClickedForSection(section); |
344 } | 335 } |
345 | 336 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 env, error_array.obj(), i, invalid_inputs[i], error_text.obj()); | 447 env, error_array.obj(), i, invalid_inputs[i], error_text.obj()); |
457 } | 448 } |
458 Java_AutofillDialogGlue_updateSectionErrors(env, | 449 Java_AutofillDialogGlue_updateSectionErrors(env, |
459 java_object_.obj(), | 450 java_object_.obj(), |
460 section, | 451 section, |
461 error_array.obj()); | 452 error_array.obj()); |
462 return false; | 453 return false; |
463 } | 454 } |
464 | 455 |
465 } // namespace autofill | 456 } // namespace autofill |
OLD | NEW |