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

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

Issue 23756007: [rac] Show amex specific cvc hint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move icon dependency logic into controller for testability Created 7 years, 3 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/autofill/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 1459
1460 UpdateSection(section); 1460 UpdateSection(section);
1461 1461
1462 GetMetricLogger().LogDialogUiEvent( 1462 GetMetricLogger().LogDialogUiEvent(
1463 common::DialogSectionToUiEditEvent(section)); 1463 common::DialogSectionToUiEditEvent(section));
1464 } 1464 }
1465 1465
1466 gfx::Image AutofillDialogControllerImpl::IconForField( 1466 gfx::Image AutofillDialogControllerImpl::IconForField(
1467 ServerFieldType type, const string16& user_input) const { 1467 ServerFieldType type, const string16& user_input) const {
1468 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1468 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
1469 if (type == CREDIT_CARD_VERIFICATION_CODE) 1469 const std::string credit_card_type =
1470 CreditCard::GetCreditCardType(user_input);
1471
1472 if (type == CREDIT_CARD_VERIFICATION_CODE) {
1473 if (credit_card_type == autofill::kAmericanExpressCard)
1474 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT_AMEX);
1470 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT); 1475 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT);
1476 }
1471 1477
1472 if (type == CREDIT_CARD_NUMBER) { 1478 if (type == CREDIT_CARD_NUMBER) {
1473 const int input_card_idr = CreditCard::IconResourceId( 1479 const int input_card_idr = CreditCard::IconResourceId(credit_card_type);
1474 CreditCard::GetCreditCardType(user_input));
1475 if (input_card_idr != IDR_AUTOFILL_CC_GENERIC) 1480 if (input_card_idr != IDR_AUTOFILL_CC_GENERIC)
1476 return rb.GetImageNamed(input_card_idr); 1481 return rb.GetImageNamed(input_card_idr);
1477 1482
1478 // When the credit card type is unknown, no image should be shown. However, 1483 // When the credit card type is unknown, no image should be shown. However,
1479 // to simplify the view code on Mac, save space for the credit card image by 1484 // to simplify the view code on Mac, save space for the credit card image by
1480 // returning a transparent image of the appropriate size. 1485 // returning a transparent image of the appropriate size.
1481 gfx::ImageSkia image = *rb.GetImageSkiaNamed(input_card_idr); 1486 gfx::ImageSkia image = *rb.GetImageSkiaNamed(input_card_idr);
1482 return 1487 return
1483 gfx::Image(gfx::ImageSkiaOperations::CreateTransparentImage(image, 0)); 1488 gfx::Image(gfx::ImageSkiaOperations::CreateTransparentImage(image, 0));
1484 } 1489 }
1485 1490
1486 return gfx::Image(); 1491 return gfx::Image();
1487 } 1492 }
1488 1493
1494 bool AutofillDialogControllerImpl::IsIconDependentField(
1495 ServerFieldType dependent_type) const {
1496 for (std::map<ServerFieldType, ServerFieldType>::const_iterator iter =
1497 icon_dependencies_.begin();
1498 iter != icon_dependencies_.end();
1499 ++iter) {
1500 if (iter->second == dependent_type)
1501 return true;
1502 }
1503 return false;
1504 }
1505
1506 bool AutofillDialogControllerImpl::IsIconDependencyField(
1507 ServerFieldType dependency_type,
1508 ServerFieldType* dependent_type) const {
1509 std::map<ServerFieldType, ServerFieldType>::const_iterator dependency_iter =
1510 icon_dependencies_.find(dependency_type);
1511 if (dependency_iter == icon_dependencies_.end())
1512 return false;
1513 if (dependent_type)
1514 *dependent_type = dependency_iter->second;
1515 return true;
1516 }
1517
1489 // TODO(estade): Replace all the error messages here with more helpful and 1518 // TODO(estade): Replace all the error messages here with more helpful and
1490 // translateable ones. TODO(groby): Also add tests. 1519 // translateable ones. TODO(groby): Also add tests.
1491 string16 AutofillDialogControllerImpl::InputValidityMessage( 1520 string16 AutofillDialogControllerImpl::InputValidityMessage(
1492 DialogSection section, 1521 DialogSection section,
1493 ServerFieldType type, 1522 ServerFieldType type,
1494 const string16& value) { 1523 const string16& value) {
1495 // If the field is edited, clear any Wallet errors. 1524 // If the field is edited, clear any Wallet errors.
1496 if (IsPayingWithWallet()) { 1525 if (IsPayingWithWallet()) {
1497 WalletValidationErrors::iterator it = wallet_errors_.find(section); 1526 WalletValidationErrors::iterator it = wallet_errors_.find(section);
1498 if (it != wallet_errors_.end()) { 1527 if (it != wallet_errors_.end()) {
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 ::prefs::kAutofillDialogHasPaidWithWallet)), 2320 ::prefs::kAutofillDialogHasPaidWithWallet)),
2292 has_shown_wallet_usage_confirmation_(false), 2321 has_shown_wallet_usage_confirmation_(false),
2293 has_accepted_legal_documents_(false), 2322 has_accepted_legal_documents_(false),
2294 is_submitting_(false), 2323 is_submitting_(false),
2295 choose_another_instrument_or_address_(false), 2324 choose_another_instrument_or_address_(false),
2296 wallet_server_validation_recoverable_(true), 2325 wallet_server_validation_recoverable_(true),
2297 data_was_passed_back_(false), 2326 data_was_passed_back_(false),
2298 was_ui_latency_logged_(false) { 2327 was_ui_latency_logged_(false) {
2299 // TODO(estade): remove duplicates from |form_structure|? 2328 // TODO(estade): remove duplicates from |form_structure|?
2300 DCHECK(!callback_.is_null()); 2329 DCHECK(!callback_.is_null());
2330 icon_dependencies_[CREDIT_CARD_NUMBER] = CREDIT_CARD_VERIFICATION_CODE;
2301 } 2331 }
2302 2332
2303 AutofillDialogView* AutofillDialogControllerImpl::CreateView() { 2333 AutofillDialogView* AutofillDialogControllerImpl::CreateView() {
2304 return AutofillDialogView::Create(this); 2334 return AutofillDialogView::Create(this);
2305 } 2335 }
2306 2336
2307 PersonalDataManager* AutofillDialogControllerImpl::GetManager() { 2337 PersonalDataManager* AutofillDialogControllerImpl::GetManager() {
2308 return PersonalDataManagerFactory::GetForProfile(profile_); 2338 return PersonalDataManagerFactory::GetForProfile(profile_);
2309 } 2339 }
2310 2340
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
3319 } 3349 }
3320 3350
3321 void AutofillDialogControllerImpl::OnSubmitButtonDelayEnd() { 3351 void AutofillDialogControllerImpl::OnSubmitButtonDelayEnd() {
3322 if (!view_) 3352 if (!view_)
3323 return; 3353 return;
3324 ScopedViewUpdates updates(view_.get()); 3354 ScopedViewUpdates updates(view_.get());
3325 view_->UpdateButtonStrip(); 3355 view_->UpdateButtonStrip();
3326 } 3356 }
3327 3357
3328 } // namespace autofill 3358 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698