Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/ui/android/autofill/autofill_dialog_controller_android.cc

Issue 137723008: Remove DataModelWrapper from android build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: resurrect getinfo Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_controller_android. h" 5 #include "chrome/browser/ui/android/autofill/autofill_dialog_controller_android. h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/prefs/scoped_user_pref_update.h" 14 #include "base/prefs/scoped_user_pref_update.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/autofill/personal_data_manager_factory.h" 16 #include "chrome/browser/autofill/personal_data_manager_factory.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/ui/android/autofill/autofill_dialog_result.h" 20 #include "chrome/browser/ui/android/autofill/autofill_dialog_result.h"
21 #include "chrome/browser/ui/android/window_android_helper.h" 21 #include "chrome/browser/ui/android/window_android_helper.h"
22 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" 22 #include "chrome/browser/ui/autofill/autofill_dialog_common.h"
23 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
24 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
25 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
26 #include "components/autofill/content/browser/wallet/full_wallet.h" 25 #include "components/autofill/content/browser/wallet/full_wallet.h"
27 #include "components/autofill/core/browser/autofill_metrics.h" 26 #include "components/autofill/core/browser/autofill_metrics.h"
28 #include "components/autofill/core/browser/autofill_profile.h" 27 #include "components/autofill/core/browser/autofill_profile.h"
29 #include "components/autofill/core/browser/autofill_type.h" 28 #include "components/autofill/core/browser/autofill_type.h"
30 #include "components/autofill/core/browser/credit_card.h" 29 #include "components/autofill/core/browser/credit_card.h"
31 #include "components/autofill/core/browser/personal_data_manager.h" 30 #include "components/autofill/core/browser/personal_data_manager.h"
32 #include "components/autofill/core/common/form_data.h" 31 #include "components/autofill/core/common/form_data.h"
33 #include "components/user_prefs/pref_registry_syncable.h" 32 #include "components/user_prefs/pref_registry_syncable.h"
34 #include "content/public/browser/navigation_controller.h" 33 #include "content/public/browser/navigation_controller.h"
35 #include "content/public/browser/navigation_details.h" 34 #include "content/public/browser/navigation_details.h"
36 #include "content/public/browser/navigation_entry.h" 35 #include "content/public/browser/navigation_entry.h"
37 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
38 #include "grit/generated_resources.h" 37 #include "grit/generated_resources.h"
39 #include "jni/AutofillDialogControllerAndroid_jni.h" 38 #include "jni/AutofillDialogControllerAndroid_jni.h"
40 #include "ui/base/android/window_android.h" 39 #include "ui/base/android/window_android.h"
41 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/base/models/combobox_model.h" 41 #include "ui/base/models/combobox_model.h"
43 #include "ui/base/models/menu_model.h" 42 #include "ui/base/models/menu_model.h"
44 #include "ui/gfx/android/java_bitmap.h" 43 #include "ui/gfx/android/java_bitmap.h"
45 #include "ui/gfx/rect.h" 44 #include "ui/gfx/rect.h"
46 #include "url/gurl.h" 45 #include "url/gurl.h"
47 46
48 namespace autofill { 47 namespace autofill {
49 48
50 namespace { 49 namespace {
51 50
51 using wallet::FullWallet;
52
52 // Keys in kAutofillDialogDefaults pref dictionary (do not change these values). 53 // Keys in kAutofillDialogDefaults pref dictionary (do not change these values).
53 const char kLastUsedAccountName[] = "last_used_account_name"; 54 const char kLastUsedAccountName[] = "last_used_account_name";
54 const char kLastUsedChoiceIsAutofill[] = "last_used_choice_is_autofill"; 55 const char kLastUsedChoiceIsAutofill[] = "last_used_choice_is_autofill";
55 const char kLastUsedBillingAddressGuid[] = "last_used_billing"; 56 const char kLastUsedBillingAddressGuid[] = "last_used_billing";
56 const char kLastUsedShippingAddressGuid[] = "last_used_shipping"; 57 const char kLastUsedShippingAddressGuid[] = "last_used_shipping";
57 const char kLastUsedCreditCardGuid[] = "last_used_card"; 58 const char kLastUsedCreditCardGuid[] = "last_used_card";
58 59
59 scoped_ptr<DataModelWrapper> CreateWrapper( 60 base::string16 NullGetInfo(const AutofillType& type) {
60 DialogSection section, wallet::FullWallet* full_wallet) { 61 return base::string16();
61 if (section == SECTION_CC_BILLING) {
62 if (!full_wallet->billing_address())
63 return scoped_ptr<DataModelWrapper>();
64
65 return scoped_ptr<DataModelWrapper>(
66 new FullWalletBillingWrapper(full_wallet));
67 }
68 if (section == SECTION_SHIPPING) {
69 if (!full_wallet->shipping_address())
70 return scoped_ptr<DataModelWrapper>();
71
72 return scoped_ptr<DataModelWrapper>(
73 new FullWalletShippingWrapper(full_wallet));
74 }
75 NOTREACHED();
76 return scoped_ptr<DataModelWrapper>();
77 } 62 }
78 63
79 void FillOutputForSectionWithComparator( 64 void FillOutputForSectionWithComparator(
80 DialogSection section, 65 DialogSection section,
81 const DetailInputs& inputs, 66 const DetailInputs& inputs,
82 const InputFieldComparator& compare, 67 const FormStructure::InputFieldComparator& compare,
83 FormStructure& form_structure, 68 FormStructure& form_structure,
84 wallet::FullWallet* full_wallet, 69 FullWallet* full_wallet,
85 const base::string16& email_address) { 70 const base::string16& email_address) {
86 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section, full_wallet); 71 if ((section == SECTION_CC_BILLING && !full_wallet->billing_address()) ||
87 if (wrapper) 72 (section == SECTION_SHIPPING && !full_wallet->shipping_address())) {
88 wrapper->FillFormStructure(inputs, compare, &form_structure); 73 return;
74 }
75
76 base::Callback<base::string16(const AutofillType&)> get_info
77 base::Bind(&FullWallet::GetInfo,
78 base::Unretained(full_wallet),
79 g_browser_process->GetApplicationLocale());
80
81 std::vector<ServerFieldType> types = common::TypesFromInputs(inputs);
82 form_structure.FillFields(
83 types,
84 compare,
85 get_info,
86 g_browser_process->GetApplicationLocale());
89 } 87 }
90 88
91 void FillOutputForSection( 89 void FillOutputForSection(
92 DialogSection section, 90 DialogSection section,
93 FormStructure& form_structure, 91 FormStructure& form_structure,
94 wallet::FullWallet* full_wallet, 92 FullWallet* full_wallet,
95 const base::string16& email_address) { 93 const base::string16& email_address) {
96 DetailInputs inputs; 94 DetailInputs inputs;
97 common::BuildInputsForSection(section, "US", &inputs); 95 common::BuildInputsForSection(section, "US", &inputs);
98 96
99 FillOutputForSectionWithComparator( 97 FillOutputForSectionWithComparator(
100 section, inputs, 98 section, inputs,
101 base::Bind(common::ServerTypeMatchesField, section), 99 base::Bind(common::ServerTypeMatchesField, section),
102 form_structure, full_wallet, email_address); 100 form_structure, full_wallet, email_address);
103 101
104 if (section == SECTION_CC_BILLING) { 102 if (section == SECTION_CC_BILLING) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 form_structure_) || 243 form_structure_) ||
246 IsSectionInputUsedInFormStructure( 244 IsSectionInputUsedInFormStructure(
247 SECTION_SHIPPING, 245 SECTION_SHIPPING,
248 PHONE_HOME_WHOLE_NUMBER, 246 PHONE_HOME_WHOLE_NUMBER,
249 form_structure_); 247 form_structure_);
250 248
251 bool request_shipping_address = false; 249 bool request_shipping_address = false;
252 { 250 {
253 DetailInputs inputs; 251 DetailInputs inputs;
254 common::BuildInputsForSection(SECTION_SHIPPING, "US", &inputs); 252 common::BuildInputsForSection(SECTION_SHIPPING, "US", &inputs);
255 EmptyDataModelWrapper empty_wrapper; 253 request_shipping_address = form_structure_.FillFields(
256 request_shipping_address = empty_wrapper.FillFormStructure( 254 common::TypesFromInputs(inputs),
257 inputs,
258 base::Bind(common::ServerTypeMatchesField, SECTION_SHIPPING), 255 base::Bind(common::ServerTypeMatchesField, SECTION_SHIPPING),
259 &form_structure_); 256 base::Bind(NullGetInfo),
257 g_browser_process->GetApplicationLocale());
260 } 258 }
261 259
262 const bool incognito_mode = profile_->IsOffTheRecord(); 260 const bool incognito_mode = profile_->IsOffTheRecord();
263 261
264 bool last_used_choice_is_autofill = false; 262 bool last_used_choice_is_autofill = false;
265 base::string16 last_used_account_name; 263 base::string16 last_used_account_name;
266 std::string last_used_billing; 264 std::string last_used_billing;
267 std::string last_used_shipping; 265 std::string last_used_shipping;
268 std::string last_used_credit_card; 266 std::string last_used_credit_card;
269 { 267 {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 344
347 const base::string16 last_used_account_name = 345 const base::string16 last_used_account_name =
348 base::android::ConvertJavaStringToUTF16(env, jlast_used_account_name); 346 base::android::ConvertJavaStringToUTF16(env, jlast_used_account_name);
349 const std::string last_used_billing = 347 const std::string last_used_billing =
350 base::android::ConvertJavaStringToUTF8(env, jlast_used_billing); 348 base::android::ConvertJavaStringToUTF8(env, jlast_used_billing);
351 const std::string last_used_shipping = 349 const std::string last_used_shipping =
352 base::android::ConvertJavaStringToUTF8(env, jlast_used_shipping); 350 base::android::ConvertJavaStringToUTF8(env, jlast_used_shipping);
353 const std::string last_used_card = 351 const std::string last_used_card =
354 base::android::ConvertJavaStringToUTF8(env, jlast_used_card); 352 base::android::ConvertJavaStringToUTF8(env, jlast_used_card);
355 353
356 scoped_ptr<wallet::FullWallet> full_wallet = 354 scoped_ptr<FullWallet> full_wallet =
357 AutofillDialogResult::ConvertFromJava(env, wallet); 355 AutofillDialogResult::ConvertFromJava(env, wallet);
358 FillOutputForSection( 356 FillOutputForSection(
359 SECTION_CC_BILLING, form_structure_, full_wallet.get(), email); 357 SECTION_CC_BILLING, form_structure_, full_wallet.get(), email);
360 FillOutputForSection( 358 FillOutputForSection(
361 SECTION_SHIPPING, form_structure_, full_wallet.get(), email); 359 SECTION_SHIPPING, form_structure_, full_wallet.get(), email);
362 360
363 { 361 {
364 DictionaryPrefUpdate updater(profile_->GetPrefs(), 362 DictionaryPrefUpdate updater(profile_->GetPrefs(),
365 ::prefs::kAutofillDialogDefaults); 363 ::prefs::kAutofillDialogDefaults);
366 base::DictionaryValue* defaults = updater.Get(); 364 base::DictionaryValue* defaults = updater.Get();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 415
418 void AutofillDialogControllerAndroid::LogOnCancelMetrics() { 416 void AutofillDialogControllerAndroid::LogOnCancelMetrics() {
419 GetMetricLogger().LogDialogUiDuration( 417 GetMetricLogger().LogDialogUiDuration(
420 base::Time::Now() - dialog_shown_timestamp_, 418 base::Time::Now() - dialog_shown_timestamp_,
421 AutofillMetrics::DIALOG_CANCELED); 419 AutofillMetrics::DIALOG_CANCELED);
422 420
423 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_CANCELED); 421 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_CANCELED);
424 } 422 }
425 423
426 } // namespace autofill 424 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698