OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import "chrome/browser/autofill/autofill_dialog_controller_mac.h" | 5 #import "chrome/browser/autofill/autofill_dialog_controller_mac.h" |
6 #include "app/l10n_util.h" | 6 #include "app/l10n_util.h" |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #import "chrome/browser/autofill/autofill_address_model_mac.h" | 10 #import "chrome/browser/autofill/autofill_address_model_mac.h" |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 return [NSImage class]; | 757 return [NSImage class]; |
758 } | 758 } |
759 | 759 |
760 + (BOOL)allowsReverseTransformation { | 760 + (BOOL)allowsReverseTransformation { |
761 return NO; | 761 return NO; |
762 } | 762 } |
763 | 763 |
764 - (id)transformedValue:(id)string { | 764 - (id)transformedValue:(id)string { |
765 NSImage* image = nil; | 765 NSImage* image = nil; |
766 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 766 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 767 |
| 768 // We display no validation icon when input has not yet been entered. |
| 769 if (string == nil || [string length] == 0) |
| 770 return nil; |
| 771 |
| 772 // If we have input then display alert icon if we have an invalid number. |
767 if (string != nil && [string length] != 0) { | 773 if (string != nil && [string length] != 0) { |
768 // TODO(dhollowa): Using SetInfo() call to validate phone number. Should | 774 // TODO(dhollowa): Using SetInfo() call to validate phone number. Should |
769 // have explicit validation method. More robust validation is needed as | 775 // have explicit validation method. More robust validation is needed as |
770 // well eventually. | 776 // well eventually. |
771 AutoFillProfile profile(string16(), 0); | 777 AutoFillProfile profile(string16(), 0); |
772 profile.SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), | 778 profile.SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), |
773 base::SysNSStringToUTF16(string)); | 779 base::SysNSStringToUTF16(string)); |
774 if (profile.GetFieldText(AutoFillType(PHONE_HOME_WHOLE_NUMBER)).empty()) { | 780 if (profile.GetFieldText(AutoFillType(PHONE_HOME_WHOLE_NUMBER)).empty()) { |
775 image = rb.GetNSImageNamed(IDR_INPUT_ALERT); | 781 image = rb.GetNSImageNamed(IDR_INPUT_ALERT); |
776 DCHECK(image); | 782 DCHECK(image); |
777 return image; | 783 return image; |
778 } | 784 } |
779 } | 785 } |
780 | 786 |
| 787 // No alert icon, so must be valid input. |
781 if (!image) { | 788 if (!image) { |
782 image = rb.GetNSImageNamed(IDR_INPUT_GOOD); | 789 image = rb.GetNSImageNamed(IDR_INPUT_GOOD); |
783 DCHECK(image); | 790 DCHECK(image); |
784 return image; | 791 return image; |
785 } | 792 } |
786 | 793 |
787 return nil; | 794 return nil; |
788 } | 795 } |
789 | 796 |
790 @end | 797 @end |
OLD | NEW |