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