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

Side by Side Diff: chrome/browser/ui/autofill/data_model_wrapper.cc

Issue 15892013: Make suggestions invalid when no phone number is attached to an address. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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 (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/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" 10 #include "chrome/browser/ui/autofill/autofill_dialog_models.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 WalletAddressWrapper::WalletAddressWrapper( 156 WalletAddressWrapper::WalletAddressWrapper(
157 const wallet::Address* address) : address_(address) {} 157 const wallet::Address* address) : address_(address) {}
158 158
159 WalletAddressWrapper::~WalletAddressWrapper() {} 159 WalletAddressWrapper::~WalletAddressWrapper() {}
160 160
161 string16 WalletAddressWrapper::GetInfo(AutofillFieldType type) { 161 string16 WalletAddressWrapper::GetInfo(AutofillFieldType type) {
162 return address_->GetInfo(type, g_browser_process->GetApplicationLocale()); 162 return address_->GetInfo(type, g_browser_process->GetApplicationLocale());
163 } 163 }
164 164
165 string16 WalletAddressWrapper::GetDisplayText() { 165 string16 WalletAddressWrapper::GetDisplayText() {
166 if (!address_->is_complete_address()) 166 if (!address_->is_complete_address() ||
167 GetInfo(PHONE_HOME_WHOLE_NUMBER).empty()) {
167 return string16(); 168 return string16();
169 }
168 170
169 return DataModelWrapper::GetDisplayText(); 171 return DataModelWrapper::GetDisplayText();
170 } 172 }
171 173
172 // WalletInstrumentWrapper 174 // WalletInstrumentWrapper
173 175
174 WalletInstrumentWrapper::WalletInstrumentWrapper( 176 WalletInstrumentWrapper::WalletInstrumentWrapper(
175 const wallet::WalletItems::MaskedInstrument* instrument) 177 const wallet::WalletItems::MaskedInstrument* instrument)
176 : instrument_(instrument) {} 178 : instrument_(instrument) {}
177 179
178 WalletInstrumentWrapper::~WalletInstrumentWrapper() {} 180 WalletInstrumentWrapper::~WalletInstrumentWrapper() {}
179 181
180 string16 WalletInstrumentWrapper::GetInfo(AutofillFieldType type) { 182 string16 WalletInstrumentWrapper::GetInfo(AutofillFieldType type) {
181 if (type == CREDIT_CARD_EXP_MONTH) 183 if (type == CREDIT_CARD_EXP_MONTH)
182 return MonthComboboxModel::FormatMonth(instrument_->expiration_month()); 184 return MonthComboboxModel::FormatMonth(instrument_->expiration_month());
183 185
184 return instrument_->GetInfo(type, g_browser_process->GetApplicationLocale()); 186 return instrument_->GetInfo(type, g_browser_process->GetApplicationLocale());
185 } 187 }
186 188
187 gfx::Image WalletInstrumentWrapper::GetIcon() { 189 gfx::Image WalletInstrumentWrapper::GetIcon() {
188 return instrument_->CardIcon(); 190 return instrument_->CardIcon();
189 } 191 }
190 192
191 string16 WalletInstrumentWrapper::GetDisplayText() { 193 string16 WalletInstrumentWrapper::GetDisplayText() {
192 // TODO(dbeam): handle other instrument statuses? http://crbug.com/233048 194 // TODO(dbeam): handle other instrument statuses? http://crbug.com/233048
193 if (instrument_->status() == wallet::WalletItems::MaskedInstrument::EXPIRED || 195 if (instrument_->status() == wallet::WalletItems::MaskedInstrument::EXPIRED ||
194 !instrument_->address().is_complete_address()) { 196 !instrument_->address().is_complete_address() ||
197 GetInfo(PHONE_HOME_WHOLE_NUMBER).empty()) {
195 return string16(); 198 return string16();
196 } 199 }
197 200
198 // TODO(estade): descriptive_name() is user-provided. Should we use it or 201 // TODO(estade): descriptive_name() is user-provided. Should we use it or
199 // just type + last 4 digits? 202 // just type + last 4 digits?
200 string16 line1 = instrument_->descriptive_name(); 203 string16 line1 = instrument_->descriptive_name();
201 return line1 + ASCIIToUTF16("\n") + DataModelWrapper::GetDisplayText(); 204 return line1 + ASCIIToUTF16("\n") + DataModelWrapper::GetDisplayText();
202 } 205 }
203 206
204 // FullWalletBillingWrapper 207 // FullWalletBillingWrapper
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 239 }
237 240
238 FullWalletShippingWrapper::~FullWalletShippingWrapper() {} 241 FullWalletShippingWrapper::~FullWalletShippingWrapper() {}
239 242
240 string16 FullWalletShippingWrapper::GetInfo(AutofillFieldType type) { 243 string16 FullWalletShippingWrapper::GetInfo(AutofillFieldType type) {
241 return full_wallet_->shipping_address()->GetInfo( 244 return full_wallet_->shipping_address()->GetInfo(
242 type, g_browser_process->GetApplicationLocale()); 245 type, g_browser_process->GetApplicationLocale());
243 } 246 }
244 247
245 } // namespace autofill 248 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/data_model_wrapper.h ('k') | chrome/browser/ui/autofill/data_model_wrapper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698