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

Side by Side Diff: components/autofill/browser/wallet/wallet_items.cc

Issue 13973004: Convert string16 -> base::string16 in components/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 "components/autofill/browser/wallet/wallet_items.h" 5 #include "components/autofill/browser/wallet/wallet_items.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "components/autofill/browser/autofill_type.h" 11 #include "components/autofill/browser/autofill_type.h"
12 #include "components/autofill/browser/credit_card.h" 12 #include "components/autofill/browser/credit_card.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "grit/webkit_resources.h" 15 #include "grit/webkit_resources.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 if (status_string == "EXPIRED") 76 if (status_string == "EXPIRED")
77 return WalletItems::MaskedInstrument::EXPIRED; 77 return WalletItems::MaskedInstrument::EXPIRED;
78 if (status_string == "BILLING_INCOMPLETE") 78 if (status_string == "BILLING_INCOMPLETE")
79 return WalletItems::MaskedInstrument::BILLING_INCOMPLETE; 79 return WalletItems::MaskedInstrument::BILLING_INCOMPLETE;
80 return WalletItems::MaskedInstrument::INAPPLICABLE; 80 return WalletItems::MaskedInstrument::INAPPLICABLE;
81 } 81 }
82 82
83 } // anonymous namespace 83 } // anonymous namespace
84 84
85 WalletItems::MaskedInstrument::MaskedInstrument( 85 WalletItems::MaskedInstrument::MaskedInstrument(
86 const string16& descriptive_name, 86 const base::string16& descriptive_name,
87 const WalletItems::MaskedInstrument::Type& type, 87 const WalletItems::MaskedInstrument::Type& type,
88 const std::vector<string16>& supported_currencies, 88 const std::vector<base::string16>& supported_currencies,
89 const string16& last_four_digits, 89 const base::string16& last_four_digits,
90 int expiration_month, 90 int expiration_month,
91 int expiration_year, 91 int expiration_year,
92 scoped_ptr<Address> address, 92 scoped_ptr<Address> address,
93 const WalletItems::MaskedInstrument::Status& status, 93 const WalletItems::MaskedInstrument::Status& status,
94 const std::string& object_id) 94 const std::string& object_id)
95 : descriptive_name_(descriptive_name), 95 : descriptive_name_(descriptive_name),
96 type_(type), 96 type_(type),
97 supported_currencies_(supported_currencies), 97 supported_currencies_(supported_currencies),
98 last_four_digits_(last_four_digits), 98 last_four_digits_(last_four_digits),
99 expiration_month_(expiration_month), 99 expiration_month_(expiration_month),
(...skipping 11 matching lines...) Expand all
111 const base::DictionaryValue& dictionary) { 111 const base::DictionaryValue& dictionary) {
112 std::string type_string; 112 std::string type_string;
113 Type type; 113 Type type;
114 if (dictionary.GetString("type", &type_string)) { 114 if (dictionary.GetString("type", &type_string)) {
115 type = TypeFromString(type_string); 115 type = TypeFromString(type_string);
116 } else { 116 } else {
117 DLOG(ERROR) << "Response from Google Wallet missing card type"; 117 DLOG(ERROR) << "Response from Google Wallet missing card type";
118 return scoped_ptr<MaskedInstrument>(); 118 return scoped_ptr<MaskedInstrument>();
119 } 119 }
120 120
121 string16 last_four_digits; 121 base::string16 last_four_digits;
122 if (!dictionary.GetString("last_four_digits", &last_four_digits)) { 122 if (!dictionary.GetString("last_four_digits", &last_four_digits)) {
123 DLOG(ERROR) << "Response from Google Wallet missing last four digits"; 123 DLOG(ERROR) << "Response from Google Wallet missing last four digits";
124 return scoped_ptr<MaskedInstrument>(); 124 return scoped_ptr<MaskedInstrument>();
125 } 125 }
126 126
127 std::string status_string; 127 std::string status_string;
128 Status status; 128 Status status;
129 if (dictionary.GetString("status", &status_string)) { 129 if (dictionary.GetString("status", &status_string)) {
130 status = StatusFromString(status_string); 130 status = StatusFromString(status_string);
131 } else { 131 } else {
(...skipping 12 matching lines...) Expand all
144 DLOG(ERROR) << "Response from Google wallet missing address"; 144 DLOG(ERROR) << "Response from Google wallet missing address";
145 return scoped_ptr<MaskedInstrument>(); 145 return scoped_ptr<MaskedInstrument>();
146 } 146 }
147 scoped_ptr<Address> address = Address::CreateDisplayAddress(*address_dict); 147 scoped_ptr<Address> address = Address::CreateDisplayAddress(*address_dict);
148 148
149 if (!address.get()) { 149 if (!address.get()) {
150 DLOG(ERROR) << "Response from Google wallet contained malformed address"; 150 DLOG(ERROR) << "Response from Google wallet contained malformed address";
151 return scoped_ptr<MaskedInstrument>(); 151 return scoped_ptr<MaskedInstrument>();
152 } 152 }
153 153
154 std::vector<string16> supported_currencies; 154 std::vector<base::string16> supported_currencies;
155 const ListValue* supported_currency_list; 155 const ListValue* supported_currency_list;
156 if (dictionary.GetList("supported_currency", &supported_currency_list)) { 156 if (dictionary.GetList("supported_currency", &supported_currency_list)) {
157 for (size_t i = 0; i < supported_currency_list->GetSize(); ++i) { 157 for (size_t i = 0; i < supported_currency_list->GetSize(); ++i) {
158 string16 currency; 158 base::string16 currency;
159 if (supported_currency_list->GetString(i, &currency)) 159 if (supported_currency_list->GetString(i, &currency))
160 supported_currencies.push_back(currency); 160 supported_currencies.push_back(currency);
161 } 161 }
162 } else { 162 } else {
163 DVLOG(1) << "Response from Google Wallet missing supported currency"; 163 DVLOG(1) << "Response from Google Wallet missing supported currency";
164 } 164 }
165 165
166 int expiration_month; 166 int expiration_month;
167 if (!dictionary.GetInteger("expiration_month", &expiration_month)) 167 if (!dictionary.GetInteger("expiration_month", &expiration_month))
168 DVLOG(1) << "Response from Google Wallet missing expiration month"; 168 DVLOG(1) << "Response from Google Wallet missing expiration month";
169 169
170 int expiration_year; 170 int expiration_year;
171 if (!dictionary.GetInteger("expiration_year", &expiration_year)) 171 if (!dictionary.GetInteger("expiration_year", &expiration_year))
172 DVLOG(1) << "Response from Google Wallet missing expiration year"; 172 DVLOG(1) << "Response from Google Wallet missing expiration year";
173 173
174 string16 descriptive_name; 174 base::string16 descriptive_name;
175 if (!dictionary.GetString("descriptive_name", &descriptive_name)) 175 if (!dictionary.GetString("descriptive_name", &descriptive_name))
176 DVLOG(1) << "Response from Google Wallet missing descriptive name"; 176 DVLOG(1) << "Response from Google Wallet missing descriptive name";
177 177
178 return scoped_ptr<MaskedInstrument>(new MaskedInstrument(descriptive_name, 178 return scoped_ptr<MaskedInstrument>(new MaskedInstrument(descriptive_name,
179 type, 179 type,
180 supported_currencies, 180 supported_currencies,
181 last_four_digits, 181 last_four_digits,
182 expiration_month, 182 expiration_month,
183 expiration_year, 183 expiration_year,
184 address.Pass(), 184 address.Pass(),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 return NULL; 235 return NULL;
236 236
237 for (size_t i = 0; i < instruments_.size(); ++i) { 237 for (size_t i = 0; i < instruments_.size(); ++i) {
238 if (instruments_[i]->object_id() == object_id) 238 if (instruments_[i]->object_id() == object_id)
239 return instruments_[i]; 239 return instruments_[i];
240 } 240 }
241 241
242 return NULL; 242 return NULL;
243 } 243 }
244 244
245 string16 WalletItems::MaskedInstrument::DisplayName() const { 245 base::string16 WalletItems::MaskedInstrument::DisplayName() const {
246 #if defined(OS_ANDROID) 246 #if defined(OS_ANDROID)
247 // TODO(aruslan): improve this stub implementation. 247 // TODO(aruslan): improve this stub implementation.
248 return descriptive_name(); 248 return descriptive_name();
249 #else 249 #else
250 return descriptive_name(); 250 return descriptive_name();
251 #endif 251 #endif
252 } 252 }
253 253
254 string16 WalletItems::MaskedInstrument::DisplayNameDetail() const { 254 base::string16 WalletItems::MaskedInstrument::DisplayNameDetail() const {
255 #if defined(OS_ANDROID) 255 #if defined(OS_ANDROID)
256 // TODO(aruslan): improve this stub implementation. 256 // TODO(aruslan): improve this stub implementation.
257 return address().DisplayName(); 257 return address().DisplayName();
258 #else 258 #else
259 return string16(); 259 return base::string16();
260 #endif 260 #endif
261 } 261 }
262 262
263 string16 WalletItems::MaskedInstrument::TypeAndLastFourDigits() const { 263 base::string16 WalletItems::MaskedInstrument::TypeAndLastFourDigits() const {
264 string16 display_type; 264 base::string16 display_type;
265 265
266 if (type_ == AMEX) 266 if (type_ == AMEX)
267 display_type = CreditCard::TypeForDisplay(kAmericanExpressCard); 267 display_type = CreditCard::TypeForDisplay(kAmericanExpressCard);
268 else if (type_ == DISCOVER) 268 else if (type_ == DISCOVER)
269 display_type = CreditCard::TypeForDisplay(kDiscoverCard); 269 display_type = CreditCard::TypeForDisplay(kDiscoverCard);
270 else if (type_ == MASTER_CARD) 270 else if (type_ == MASTER_CARD)
271 display_type = CreditCard::TypeForDisplay(kMasterCard); 271 display_type = CreditCard::TypeForDisplay(kMasterCard);
272 else if (type_ == SOLO) 272 else if (type_ == SOLO)
273 display_type = CreditCard::TypeForDisplay(kSoloCard); 273 display_type = CreditCard::TypeForDisplay(kSoloCard);
274 else if (type_ == VISA) 274 else if (type_ == VISA)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 case MAESTRO: 306 case MAESTRO:
307 case SWITCH: 307 case SWITCH:
308 case UNKNOWN: 308 case UNKNOWN:
309 idr = IDR_AUTOFILL_CC_GENERIC; 309 idr = IDR_AUTOFILL_CC_GENERIC;
310 break; 310 break;
311 } 311 }
312 312
313 return ResourceBundle::GetSharedInstance().GetImageNamed(idr); 313 return ResourceBundle::GetSharedInstance().GetImageNamed(idr);
314 } 314 }
315 315
316 string16 WalletItems::MaskedInstrument::GetInfo( 316 base::string16 WalletItems::MaskedInstrument::GetInfo(
317 AutofillFieldType type, 317 AutofillFieldType type,
318 const std::string& app_locale) const { 318 const std::string& app_locale) const {
319 if (AutofillType(type).group() != AutofillType::CREDIT_CARD) 319 if (AutofillType(type).group() != AutofillType::CREDIT_CARD)
320 return address().GetInfo(type, app_locale); 320 return address().GetInfo(type, app_locale);
321 321
322 switch (type) { 322 switch (type) {
323 case CREDIT_CARD_NAME: 323 case CREDIT_CARD_NAME:
324 return address().recipient_name(); 324 return address().recipient_name();
325 325
326 case CREDIT_CARD_NUMBER: 326 case CREDIT_CARD_NUMBER:
327 // TODO(dbeam): show these as XXXX-#### and non-editable in the UI. 327 // TODO(dbeam): show these as XXXX-#### and non-editable in the UI.
328 return last_four_digits(); 328 return last_four_digits();
329 329
330 case CREDIT_CARD_EXP_4_DIGIT_YEAR: 330 case CREDIT_CARD_EXP_4_DIGIT_YEAR:
331 return base::IntToString16(expiration_year()); 331 return base::IntToString16(expiration_year());
332 332
333 case CREDIT_CARD_VERIFICATION_CODE: 333 case CREDIT_CARD_VERIFICATION_CODE:
334 break; 334 break;
335 335
336 default: 336 default:
337 NOTREACHED(); 337 NOTREACHED();
338 } 338 }
339 339
340 return string16(); 340 return base::string16();
341 } 341 }
342 342
343 WalletItems::LegalDocument::~LegalDocument() {} 343 WalletItems::LegalDocument::~LegalDocument() {}
344 344
345 scoped_ptr<WalletItems::LegalDocument> 345 scoped_ptr<WalletItems::LegalDocument>
346 WalletItems::LegalDocument::CreateLegalDocument( 346 WalletItems::LegalDocument::CreateLegalDocument(
347 const base::DictionaryValue& dictionary) { 347 const base::DictionaryValue& dictionary) {
348 std::string id; 348 std::string id;
349 if (!dictionary.GetString("legal_document_id", &id)) { 349 if (!dictionary.GetString("legal_document_id", &id)) {
350 DLOG(ERROR) << "Response from Google Wallet missing legal document id"; 350 DLOG(ERROR) << "Response from Google Wallet missing legal document id";
351 return scoped_ptr<LegalDocument>(); 351 return scoped_ptr<LegalDocument>();
352 } 352 }
353 353
354 string16 display_name; 354 base::string16 display_name;
355 if (!dictionary.GetString("display_name", &display_name)) { 355 if (!dictionary.GetString("display_name", &display_name)) {
356 DLOG(ERROR) << "Response from Google Wallet missing display name"; 356 DLOG(ERROR) << "Response from Google Wallet missing display name";
357 return scoped_ptr<LegalDocument>(); 357 return scoped_ptr<LegalDocument>();
358 } 358 }
359 359
360 return scoped_ptr<LegalDocument>(new LegalDocument(id, display_name)); 360 return scoped_ptr<LegalDocument>(new LegalDocument(id, display_name));
361 } 361 }
362 362
363 scoped_ptr<WalletItems::LegalDocument> 363 scoped_ptr<WalletItems::LegalDocument>
364 WalletItems::LegalDocument::CreatePrivacyPolicyDocument() { 364 WalletItems::LegalDocument::CreatePrivacyPolicyDocument() {
365 return scoped_ptr<LegalDocument>(new LegalDocument( 365 return scoped_ptr<LegalDocument>(new LegalDocument(
366 GURL(kPrivacyNoticeUrl), 366 GURL(kPrivacyNoticeUrl),
367 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PRIVACY_POLICY_LINK))); 367 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PRIVACY_POLICY_LINK)));
368 } 368 }
369 369
370 bool WalletItems::LegalDocument::operator==(const LegalDocument& other) const { 370 bool WalletItems::LegalDocument::operator==(const LegalDocument& other) const {
371 return id_ == other.id_ && 371 return id_ == other.id_ &&
372 url_ == other.url_ && 372 url_ == other.url_ &&
373 display_name_ == other.display_name_; 373 display_name_ == other.display_name_;
374 } 374 }
375 375
376 bool WalletItems::LegalDocument::operator!=(const LegalDocument& other) const { 376 bool WalletItems::LegalDocument::operator!=(const LegalDocument& other) const {
377 return !(*this == other); 377 return !(*this == other);
378 } 378 }
379 379
380 WalletItems::LegalDocument::LegalDocument(const std::string& id, 380 WalletItems::LegalDocument::LegalDocument(const std::string& id,
381 const string16& display_name) 381 const base::string16& display_name)
382 : id_(id), 382 : id_(id),
383 url_(kLegalDocumentUrl + id), 383 url_(kLegalDocumentUrl + id),
384 display_name_(display_name) {} 384 display_name_(display_name) {}
385 385
386 WalletItems::LegalDocument::LegalDocument(const GURL& url, 386 WalletItems::LegalDocument::LegalDocument(const GURL& url,
387 const string16& display_name) 387 const base::string16& display_name)
388 : url_(url), 388 : url_(url),
389 display_name_(display_name) {} 389 display_name_(display_name) {}
390 390
391 WalletItems::WalletItems(const std::vector<RequiredAction>& required_actions, 391 WalletItems::WalletItems(const std::vector<RequiredAction>& required_actions,
392 const std::string& google_transaction_id, 392 const std::string& google_transaction_id,
393 const std::string& default_instrument_id, 393 const std::string& default_instrument_id,
394 const std::string& default_address_id, 394 const std::string& default_address_id,
395 const std::string& obfuscated_gaia_id) 395 const std::string& obfuscated_gaia_id)
396 : required_actions_(required_actions), 396 : required_actions_(required_actions),
397 google_transaction_id_(google_transaction_id), 397 google_transaction_id_(google_transaction_id),
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 VectorsAreEqual<LegalDocument>(legal_documents(), 522 VectorsAreEqual<LegalDocument>(legal_documents(),
523 other.legal_documents()); 523 other.legal_documents());
524 } 524 }
525 525
526 bool WalletItems::operator!=(const WalletItems& other) const { 526 bool WalletItems::operator!=(const WalletItems& other) const {
527 return !(*this == other); 527 return !(*this == other);
528 } 528 }
529 529
530 } // namespace wallet 530 } // namespace wallet
531 } // namespace autofill 531 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698