| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/autofill/data_model_wrapper.h" | 5 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" | 11 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" |
| 12 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 12 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
| 13 #include "components/autofill/content/browser/wallet/full_wallet.h" | 13 #include "components/autofill/content/browser/wallet/full_wallet.h" |
| 14 #include "components/autofill/content/browser/wallet/wallet_address.h" | 14 #include "components/autofill/content/browser/wallet/wallet_address.h" |
| 15 #include "components/autofill/content/browser/wallet/wallet_items.h" | 15 #include "components/autofill/content/browser/wallet/wallet_items.h" |
| 16 #include "components/autofill/core/browser/autofill_data_model.h" | 16 #include "components/autofill/core/browser/autofill_data_model.h" |
| 17 #include "components/autofill/core/browser/autofill_field.h" | 17 #include "components/autofill/core/browser/autofill_field.h" |
| 18 #include "components/autofill/core/browser/autofill_profile.h" | 18 #include "components/autofill/core/browser/autofill_profile.h" |
| 19 #include "components/autofill/core/browser/autofill_type.h" | 19 #include "components/autofill/core/browser/autofill_type.h" |
| 20 #include "components/autofill/core/browser/credit_card.h" | 20 #include "components/autofill/core/browser/credit_card.h" |
| 21 #include "components/autofill/core/browser/form_structure.h" | 21 #include "components/autofill/core/browser/form_structure.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 23 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
| 24 | 24 |
| 25 namespace autofill { | 25 namespace autofill { |
| 26 | 26 |
| 27 DataModelWrapper::~DataModelWrapper() {} | 27 DataModelWrapper::~DataModelWrapper() {} |
| 28 | 28 |
| 29 void DataModelWrapper::FillInputs(DetailInputs* inputs) { | 29 void DataModelWrapper::FillInputs(DetailInputs* inputs, |
| 30 const std::string& country_code) { |
| 30 for (size_t i = 0; i < inputs->size(); ++i) { | 31 for (size_t i = 0; i < inputs->size(); ++i) { |
| 31 DetailInput* input = &(*inputs)[i]; | 32 DetailInput* input = &(*inputs)[i]; |
| 32 input->initial_value = common::GetHardcodedValueForType(input->type); | 33 input->initial_value = common::GetInitialValueForType(input->type, |
| 34 country_code); |
| 33 if (input->initial_value.empty()) | 35 if (input->initial_value.empty()) |
| 34 input->initial_value = GetInfo(AutofillType(input->type)); | 36 input->initial_value = GetInfo(AutofillType(input->type)); |
| 35 } | 37 } |
| 36 } | 38 } |
| 37 | 39 |
| 38 base::string16 DataModelWrapper::GetInfoForDisplay(const AutofillType& type) | 40 base::string16 DataModelWrapper::GetInfoForDisplay(const AutofillType& type) |
| 39 const { | 41 const { |
| 40 return GetInfo(type); | 42 return GetInfo(type); |
| 41 } | 43 } |
| 42 | 44 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 350 } |
| 349 | 351 |
| 350 FullWalletShippingWrapper::~FullWalletShippingWrapper() {} | 352 FullWalletShippingWrapper::~FullWalletShippingWrapper() {} |
| 351 | 353 |
| 352 base::string16 FullWalletShippingWrapper::GetInfo( | 354 base::string16 FullWalletShippingWrapper::GetInfo( |
| 353 const AutofillType& type) const { | 355 const AutofillType& type) const { |
| 354 return full_wallet_->shipping_address()->GetInfo( | 356 return full_wallet_->shipping_address()->GetInfo( |
| 355 type, g_browser_process->GetApplicationLocale()); | 357 type, g_browser_process->GetApplicationLocale()); |
| 356 } | 358 } |
| 357 | 359 |
| 358 DetailOutputWrapper::DetailOutputWrapper(const DetailOutputMap& outputs) | 360 SnapshotWrapper::SnapshotWrapper(const UserInputSnapshot& snapshot) |
| 359 : outputs_(outputs) {} | 361 : snapshot_(snapshot) {} |
| 360 | 362 |
| 361 DetailOutputWrapper::~DetailOutputWrapper() {} | 363 SnapshotWrapper::~SnapshotWrapper() {} |
| 362 | 364 |
| 363 base::string16 DetailOutputWrapper::GetInfo(const AutofillType& type) const { | 365 base::string16 SnapshotWrapper::GetInfo(const AutofillType& type) const { |
| 364 for (DetailOutputMap::const_iterator it = outputs_.begin(); | 366 for (UserInputSnapshot::const_iterator it = snapshot_.begin(); |
| 365 it != outputs_.end(); ++it) { | 367 it != snapshot_.end(); ++it) { |
| 366 if (type.server_type() == it->first->type) | 368 if (type.server_type() == it->first) |
| 367 return it->second; | 369 return it->second; |
| 368 } | 370 } |
| 369 return base::string16(); | 371 return base::string16(); |
| 370 } | 372 } |
| 371 | 373 |
| 372 } // namespace autofill | 374 } // namespace autofill |
| OLD | NEW |