| 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/singleton.h" | 9 #include "base/singleton.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 26 #include "grit/app_resources.h" | 26 #include "grit/app_resources.h" |
| 27 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // Type for singleton object that contains the instance of the visible | 31 // Type for singleton object that contains the instance of the visible |
| 32 // dialog. | 32 // dialog. |
| 33 typedef std::map<Profile*, AutoFillDialogController*> ProfileControllerMap; | 33 typedef std::map<Profile*, AutoFillDialogController*> ProfileControllerMap; |
| 34 | 34 |
| 35 // Update profile labels passed as |input|. When profile data changes as a | |
| 36 // result of adding new profiles, edititing existing profiles, or deleting a | |
| 37 // profile, then the list of profiles need to have their derived labels | |
| 38 // recomputed. | |
| 39 void UpdateProfileLabels(std::vector<AutoFillProfile>* input) { | |
| 40 DCHECK(input); | |
| 41 std::vector<AutoFillProfile*> profiles; | |
| 42 profiles.resize(input->size()); | |
| 43 for (size_t i = 0; i < input->size(); ++i) { | |
| 44 profiles[i] = &(*input)[i]; | |
| 45 } | |
| 46 AutoFillProfile::AdjustInferredLabels(&profiles); | |
| 47 } | |
| 48 | |
| 49 } // namespace | 35 } // namespace |
| 50 | 36 |
| 51 // Delegate protocol that needs to be in place for the AutoFillTableView's | 37 // Delegate protocol that needs to be in place for the AutoFillTableView's |
| 52 // handling of delete and backspace keys. | 38 // handling of delete and backspace keys. |
| 53 @protocol DeleteKeyDelegate | 39 @protocol DeleteKeyDelegate |
| 54 - (IBAction)deleteSelection:(id)sender; | 40 - (IBAction)deleteSelection:(id)sender; |
| 55 @end | 41 @end |
| 56 | 42 |
| 57 // A subclass of NSTableView that allows for deleting selected elements using | 43 // A subclass of NSTableView that allows for deleting selected elements using |
| 58 // the delete or backspace keys. | 44 // the delete or backspace keys. |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 for (std::vector<AutoFillProfile*>::const_iterator iter = profiles.begin(); | 818 for (std::vector<AutoFillProfile*>::const_iterator iter = profiles.begin(); |
| 833 iter != profiles.end(); ++iter) | 819 iter != profiles.end(); ++iter) |
| 834 profiles_.push_back(**iter); | 820 profiles_.push_back(**iter); |
| 835 | 821 |
| 836 // Make local copy of |creditCards|. | 822 // Make local copy of |creditCards|. |
| 837 creditCards_.clear(); | 823 creditCards_.clear(); |
| 838 for (std::vector<CreditCard*>::const_iterator iter = creditCards.begin(); | 824 for (std::vector<CreditCard*>::const_iterator iter = creditCards.begin(); |
| 839 iter != creditCards.end(); ++iter) | 825 iter != creditCards.end(); ++iter) |
| 840 creditCards_.push_back(**iter); | 826 creditCards_.push_back(**iter); |
| 841 | 827 |
| 842 UpdateProfileLabels(&profiles_); | |
| 843 [tableView_ reloadData]; | 828 [tableView_ reloadData]; |
| 844 } | 829 } |
| 845 | 830 |
| 846 - (void)preferenceDidChange:(const std::string&)preferenceName { | 831 - (void)preferenceDidChange:(const std::string&)preferenceName { |
| 847 if (preferenceName == prefs::kAutoFillEnabled) { | 832 if (preferenceName == prefs::kAutoFillEnabled) { |
| 848 [self setAutoFillEnabled:autoFillEnabled_.GetValue()]; | 833 [self setAutoFillEnabled:autoFillEnabled_.GetValue()]; |
| 849 [self setAutoFillManaged:autoFillEnabled_.IsManaged()]; | 834 [self setAutoFillManaged:autoFillEnabled_.IsManaged()]; |
| 850 [self setAutoFillManagedAndDisabled: | 835 [self setAutoFillManagedAndDisabled: |
| 851 autoFillEnabled_.IsManaged() && !autoFillEnabled_.GetValue()]; | 836 autoFillEnabled_.IsManaged() && !autoFillEnabled_.GetValue()]; |
| 852 } else if (preferenceName == prefs::kAutoFillAuxiliaryProfilesEnabled) { | 837 } else if (preferenceName == prefs::kAutoFillAuxiliaryProfilesEnabled) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 if (!image) { | 931 if (!image) { |
| 947 image = rb.GetNativeImageNamed(IDR_INPUT_GOOD); | 932 image = rb.GetNativeImageNamed(IDR_INPUT_GOOD); |
| 948 DCHECK(image); | 933 DCHECK(image); |
| 949 return image; | 934 return image; |
| 950 } | 935 } |
| 951 | 936 |
| 952 return nil; | 937 return nil; |
| 953 } | 938 } |
| 954 | 939 |
| 955 @end | 940 @end |
| OLD | NEW |