| 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 java_object_.Reset(Java_AutofillDialogGlue_create( | 40 java_object_.Reset(Java_AutofillDialogGlue_create( |
| 44 env, | 41 env, |
| 45 reinterpret_cast<jint>(this), | 42 reinterpret_cast<jint>(this), |
| 46 WindowAndroidHelper::FromWebContents(controller_->web_contents())-> | 43 WindowAndroidHelper::FromWebContents(controller_->web_contents())-> |
| 47 GetWindowAndroid()->GetJavaObject().obj(), | 44 GetWindowAndroid()->GetJavaObject().obj())); |
| 48 use_billing_for_shipping_text.obj())); | |
| 49 } | 45 } |
| 50 | 46 |
| 51 void AutofillDialogViewAndroid::Hide() { | 47 void AutofillDialogViewAndroid::Hide() { |
| 52 NOTIMPLEMENTED(); | 48 NOTIMPLEMENTED(); |
| 53 } | 49 } |
| 54 | 50 |
| 55 void AutofillDialogViewAndroid::UpdateNotificationArea() { | 51 void AutofillDialogViewAndroid::UpdateNotificationArea() { |
| 56 JNIEnv* env = base::android::AttachCurrentThread(); | 52 JNIEnv* env = base::android::AttachCurrentThread(); |
| 57 std::vector<DialogNotification> notifications = | 53 std::vector<DialogNotification> notifications = |
| 58 controller_->CurrentNotifications(); | 54 controller_->CurrentNotifications(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 197 } |
| 202 } | 198 } |
| 203 | 199 |
| 204 string16 AutofillDialogViewAndroid::GetCvc() { | 200 string16 AutofillDialogViewAndroid::GetCvc() { |
| 205 JNIEnv* env = base::android::AttachCurrentThread(); | 201 JNIEnv* env = base::android::AttachCurrentThread(); |
| 206 ScopedJavaLocalRef<jstring> cvc = | 202 ScopedJavaLocalRef<jstring> cvc = |
| 207 Java_AutofillDialogGlue_getCvc(env, java_object_.obj()); | 203 Java_AutofillDialogGlue_getCvc(env, java_object_.obj()); |
| 208 return base::android::ConvertJavaStringToUTF16(env, cvc.obj()); | 204 return base::android::ConvertJavaStringToUTF16(env, cvc.obj()); |
| 209 } | 205 } |
| 210 | 206 |
| 211 bool AutofillDialogViewAndroid::UseBillingForShipping() { | |
| 212 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 213 return Java_AutofillDialogGlue_shouldUseBillingForShipping( | |
| 214 env, java_object_.obj()); | |
| 215 } | |
| 216 | |
| 217 bool AutofillDialogViewAndroid::SaveDetailsLocally() { | 207 bool AutofillDialogViewAndroid::SaveDetailsLocally() { |
| 218 JNIEnv* env = base::android::AttachCurrentThread(); | 208 JNIEnv* env = base::android::AttachCurrentThread(); |
| 219 return Java_AutofillDialogGlue_shouldSaveDetailsLocally(env, | 209 return Java_AutofillDialogGlue_shouldSaveDetailsLocally(env, |
| 220 java_object_.obj()); | 210 java_object_.obj()); |
| 221 } | 211 } |
| 222 | 212 |
| 223 const content::NavigationController* AutofillDialogViewAndroid::ShowSignIn() { | 213 const content::NavigationController* AutofillDialogViewAndroid::ShowSignIn() { |
| 224 NOTIMPLEMENTED(); | 214 NOTIMPLEMENTED(); |
| 225 return NULL; | 215 return NULL; |
| 226 } | 216 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 ui::MenuModel* model = controller_->MenuModelForAccountChooser(); | 304 ui::MenuModel* model = controller_->MenuModelForAccountChooser(); |
| 315 if (!model) | 305 if (!model) |
| 316 return; | 306 return; |
| 317 | 307 |
| 318 model->ActivatedAt(index); | 308 model->ActivatedAt(index); |
| 319 } | 309 } |
| 320 | 310 |
| 321 void AutofillDialogViewAndroid::EditingStart(JNIEnv* env, jobject obj, | 311 void AutofillDialogViewAndroid::EditingStart(JNIEnv* env, jobject obj, |
| 322 jint jsection) { | 312 jint jsection) { |
| 323 const DialogSection section = static_cast<DialogSection>(jsection); | 313 const DialogSection section = static_cast<DialogSection>(jsection); |
| 314 // TODO(estade): respect |suggestion_state.text_style|. |
| 324 const SuggestionState& suggestion_state = | 315 const SuggestionState& suggestion_state = |
| 325 controller_->SuggestionStateForSection(section); | 316 controller_->SuggestionStateForSection(section); |
| 326 if (suggestion_state.text.empty()) { | 317 if (suggestion_state.text.empty()) { |
| 327 // The section is already in the editing mode, or it's the "Add...". | 318 // The section is already in the editing mode, or it's the "Add...". |
| 328 return; | 319 return; |
| 329 } | 320 } |
| 330 | 321 |
| 331 controller_->EditClickedForSection(section); | 322 controller_->EditClickedForSection(section); |
| 332 } | 323 } |
| 333 | 324 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 env, error_array.obj(), i, invalid_inputs[i], error_text.obj()); | 435 env, error_array.obj(), i, invalid_inputs[i], error_text.obj()); |
| 445 } | 436 } |
| 446 Java_AutofillDialogGlue_updateSectionErrors(env, | 437 Java_AutofillDialogGlue_updateSectionErrors(env, |
| 447 java_object_.obj(), | 438 java_object_.obj(), |
| 448 section, | 439 section, |
| 449 error_array.obj()); | 440 error_array.obj()); |
| 450 return false; | 441 return false; |
| 451 } | 442 } |
| 452 | 443 |
| 453 } // namespace autofill | 444 } // namespace autofill |
| OLD | NEW |