| OLD | NEW |
| 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/views/autofill/autofill_dialog_views.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 void AutofillDialogViews::UpdateErrorBubble() { | 1308 void AutofillDialogViews::UpdateErrorBubble() { |
| 1309 if (!delegate_->ShouldShowErrorBubble()) | 1309 if (!delegate_->ShouldShowErrorBubble()) |
| 1310 HideErrorBubble(); | 1310 HideErrorBubble(); |
| 1311 } | 1311 } |
| 1312 | 1312 |
| 1313 void AutofillDialogViews::FillSection(DialogSection section, | 1313 void AutofillDialogViews::FillSection(DialogSection section, |
| 1314 const DetailInput& originating_input) { | 1314 const DetailInput& originating_input) { |
| 1315 DetailsGroup* group = GroupForSection(section); | 1315 DetailsGroup* group = GroupForSection(section); |
| 1316 // Make sure to overwrite the originating input. | 1316 // Make sure to overwrite the originating input. |
| 1317 TextfieldMap::iterator text_mapping = | 1317 TextfieldMap::iterator text_mapping = |
| 1318 group->textfields.find(&originating_input); | 1318 group->textfields.find(originating_input.type); |
| 1319 if (text_mapping != group->textfields.end()) | 1319 if (text_mapping != group->textfields.end()) |
| 1320 text_mapping->second->SetText(base::string16()); | 1320 text_mapping->second->SetText(base::string16()); |
| 1321 | 1321 |
| 1322 // If the Autofill data comes from a credit card, make sure to overwrite the | 1322 // If the Autofill data comes from a credit card, make sure to overwrite the |
| 1323 // CC comboboxes (even if they already have something in them). If the | 1323 // CC comboboxes (even if they already have something in them). If the |
| 1324 // Autofill data comes from an AutofillProfile, leave the comboboxes alone. | 1324 // Autofill data comes from an AutofillProfile, leave the comboboxes alone. |
| 1325 if (section == GetCreditCardSection() && | 1325 if (section == GetCreditCardSection() && |
| 1326 AutofillType(originating_input.type).group() == CREDIT_CARD) { | 1326 AutofillType(originating_input.type).group() == CREDIT_CARD) { |
| 1327 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); | 1327 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); |
| 1328 it != group->comboboxes.end(); ++it) { | 1328 it != group->comboboxes.end(); ++it) { |
| 1329 if (AutofillType(it->first->type).group() == CREDIT_CARD) | 1329 if (AutofillType(it->first).group() == CREDIT_CARD) |
| 1330 it->second->SetSelectedIndex(it->second->model()->GetDefaultIndex()); | 1330 it->second->SetSelectedIndex(it->second->model()->GetDefaultIndex()); |
| 1331 } | 1331 } |
| 1332 } | 1332 } |
| 1333 | 1333 |
| 1334 UpdateSectionImpl(section, false); | 1334 UpdateSectionImpl(section, false); |
| 1335 } | 1335 } |
| 1336 | 1336 |
| 1337 void AutofillDialogViews::GetUserInput(DialogSection section, | 1337 void AutofillDialogViews::GetUserInput(DialogSection section, |
| 1338 DetailOutputMap* output) { | 1338 FieldValueMap* output) { |
| 1339 DetailsGroup* group = GroupForSection(section); | 1339 DetailsGroup* group = GroupForSection(section); |
| 1340 for (TextfieldMap::const_iterator it = group->textfields.begin(); | 1340 for (TextfieldMap::const_iterator it = group->textfields.begin(); |
| 1341 it != group->textfields.end(); ++it) { | 1341 it != group->textfields.end(); ++it) { |
| 1342 output->insert(std::make_pair(it->first, it->second->text())); | 1342 output->insert(std::make_pair(it->first, it->second->text())); |
| 1343 } | 1343 } |
| 1344 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); | 1344 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); |
| 1345 it != group->comboboxes.end(); ++it) { | 1345 it != group->comboboxes.end(); ++it) { |
| 1346 output->insert(std::make_pair(it->first, | 1346 output->insert(std::make_pair(it->first, |
| 1347 it->second->model()->GetItemAt(it->second->selected_index()))); | 1347 it->second->model()->GetItemAt(it->second->selected_index()))); |
| 1348 } | 1348 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 | 1451 |
| 1452 NOTREACHED(); | 1452 NOTREACHED(); |
| 1453 return base::string16(); | 1453 return base::string16(); |
| 1454 } | 1454 } |
| 1455 | 1455 |
| 1456 void AutofillDialogViews::SetTextContentsOfInput( | 1456 void AutofillDialogViews::SetTextContentsOfInput( |
| 1457 const DetailInput& input, | 1457 const DetailInput& input, |
| 1458 const base::string16& contents) { | 1458 const base::string16& contents) { |
| 1459 views::Textfield* textfield = TextfieldForInput(input); | 1459 views::Textfield* textfield = TextfieldForInput(input); |
| 1460 if (textfield) { | 1460 if (textfield) { |
| 1461 TextfieldForInput(input)->SetText(contents); | 1461 textfield->SetText(contents); |
| 1462 return; | 1462 return; |
| 1463 } | 1463 } |
| 1464 | 1464 |
| 1465 views::Combobox* combobox = ComboboxForInput(input); | 1465 views::Combobox* combobox = ComboboxForInput(input); |
| 1466 if (combobox) { | 1466 if (combobox) { |
| 1467 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); | 1467 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); |
| 1468 return; | 1468 return; |
| 1469 } | 1469 } |
| 1470 | 1470 |
| 1471 NOTREACHED(); | 1471 NOTREACHED(); |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1961 | 1961 |
| 1962 for (DetailInputs::const_iterator it = inputs.begin(); | 1962 for (DetailInputs::const_iterator it = inputs.begin(); |
| 1963 it != inputs.end(); ++it) { | 1963 it != inputs.end(); ++it) { |
| 1964 const DetailInput& input = *it; | 1964 const DetailInput& input = *it; |
| 1965 ui::ComboboxModel* input_model = | 1965 ui::ComboboxModel* input_model = |
| 1966 delegate_->ComboboxModelForAutofillType(input.type); | 1966 delegate_->ComboboxModelForAutofillType(input.type); |
| 1967 scoped_ptr<views::View> view_to_add; | 1967 scoped_ptr<views::View> view_to_add; |
| 1968 if (input_model) { | 1968 if (input_model) { |
| 1969 views::Combobox* combobox = new views::Combobox(input_model); | 1969 views::Combobox* combobox = new views::Combobox(input_model); |
| 1970 combobox->set_listener(this); | 1970 combobox->set_listener(this); |
| 1971 comboboxes->insert(std::make_pair(&input, combobox)); | 1971 comboboxes->insert(std::make_pair(input.type, combobox)); |
| 1972 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); | 1972 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); |
| 1973 view_to_add.reset(combobox); | 1973 view_to_add.reset(combobox); |
| 1974 } else { | 1974 } else { |
| 1975 DecoratedTextfield* field = new DecoratedTextfield( | 1975 DecoratedTextfield* field = new DecoratedTextfield( |
| 1976 input.initial_value, | 1976 input.initial_value, |
| 1977 l10n_util::GetStringUTF16(input.placeholder_text_rid), | 1977 l10n_util::GetStringUTF16(input.placeholder_text_rid), |
| 1978 this); | 1978 this); |
| 1979 | 1979 |
| 1980 textfields->insert(std::make_pair(&input, field)); | 1980 textfields->insert(std::make_pair(input.type, field)); |
| 1981 view_to_add.reset(field); | 1981 view_to_add.reset(field); |
| 1982 } | 1982 } |
| 1983 | 1983 |
| 1984 int kColumnSetId = input.row_id; | 1984 int kColumnSetId = input.row_id; |
| 1985 if (kColumnSetId < 0) { | 1985 if (kColumnSetId < 0) { |
| 1986 other_owned_views_.push_back(view_to_add.release()); | 1986 other_owned_views_.push_back(view_to_add.release()); |
| 1987 continue; | 1987 continue; |
| 1988 } | 1988 } |
| 1989 | 1989 |
| 1990 views::ColumnSet* column_set = layout->GetColumnSet(kColumnSetId); | 1990 views::ColumnSet* column_set = layout->GetColumnSet(kColumnSetId); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 if (clobber_inputs) | 2038 if (clobber_inputs) |
| 2039 MarkInputsInvalid(section, ValidityMessages(), true); | 2039 MarkInputsInvalid(section, ValidityMessages(), true); |
| 2040 | 2040 |
| 2041 const DetailInputs& updated_inputs = | 2041 const DetailInputs& updated_inputs = |
| 2042 delegate_->RequestedFieldsForSection(section); | 2042 delegate_->RequestedFieldsForSection(section); |
| 2043 DetailsGroup* group = GroupForSection(section); | 2043 DetailsGroup* group = GroupForSection(section); |
| 2044 | 2044 |
| 2045 for (DetailInputs::const_iterator iter = updated_inputs.begin(); | 2045 for (DetailInputs::const_iterator iter = updated_inputs.begin(); |
| 2046 iter != updated_inputs.end(); ++iter) { | 2046 iter != updated_inputs.end(); ++iter) { |
| 2047 const DetailInput& input = *iter; | 2047 const DetailInput& input = *iter; |
| 2048 TextfieldMap::iterator text_mapping = group->textfields.find(&input); | 2048 TextfieldMap::iterator text_mapping = group->textfields.find(input.type); |
| 2049 | 2049 |
| 2050 if (text_mapping != group->textfields.end()) { | 2050 if (text_mapping != group->textfields.end()) { |
| 2051 DecoratedTextfield* decorated = text_mapping->second; | 2051 DecoratedTextfield* decorated = text_mapping->second; |
| 2052 if (decorated->text().empty() || clobber_inputs) | 2052 if (decorated->text().empty() || clobber_inputs) |
| 2053 decorated->SetText(iter->initial_value); | 2053 decorated->SetText(input.initial_value); |
| 2054 } | 2054 } |
| 2055 | 2055 |
| 2056 ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input); | 2056 ComboboxMap::iterator combo_mapping = group->comboboxes.find(input.type); |
| 2057 if (combo_mapping != group->comboboxes.end()) { | 2057 if (combo_mapping != group->comboboxes.end()) { |
| 2058 views::Combobox* combobox = combo_mapping->second; | 2058 views::Combobox* combobox = combo_mapping->second; |
| 2059 if (combobox->selected_index() == combobox->model()->GetDefaultIndex() || | 2059 if (combobox->selected_index() == combobox->model()->GetDefaultIndex() || |
| 2060 clobber_inputs) { | 2060 clobber_inputs) { |
| 2061 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); | 2061 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); |
| 2062 } | 2062 } |
| 2063 } | 2063 } |
| 2064 } | 2064 } |
| 2065 | 2065 |
| 2066 SetIconsForSection(section); | 2066 SetIconsForSection(section); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2159 DialogSection section, | 2159 DialogSection section, |
| 2160 const ValidityMessages& messages, | 2160 const ValidityMessages& messages, |
| 2161 bool overwrite_unsure) { | 2161 bool overwrite_unsure) { |
| 2162 DetailsGroup* group = GroupForSection(section); | 2162 DetailsGroup* group = GroupForSection(section); |
| 2163 DCHECK(group->container->visible()); | 2163 DCHECK(group->container->visible()); |
| 2164 | 2164 |
| 2165 if (group->manual_input->visible()) { | 2165 if (group->manual_input->visible()) { |
| 2166 for (TextfieldMap::const_iterator iter = group->textfields.begin(); | 2166 for (TextfieldMap::const_iterator iter = group->textfields.begin(); |
| 2167 iter != group->textfields.end(); ++iter) { | 2167 iter != group->textfields.end(); ++iter) { |
| 2168 const ValidityMessage& message = | 2168 const ValidityMessage& message = |
| 2169 messages.GetMessageOrDefault(iter->first->type); | 2169 messages.GetMessageOrDefault(iter->first); |
| 2170 if (overwrite_unsure || message.sure) | 2170 if (overwrite_unsure || message.sure) |
| 2171 SetValidityForInput(iter->second, message.text); | 2171 SetValidityForInput(iter->second, message.text); |
| 2172 } | 2172 } |
| 2173 for (ComboboxMap::const_iterator iter = group->comboboxes.begin(); | 2173 for (ComboboxMap::const_iterator iter = group->comboboxes.begin(); |
| 2174 iter != group->comboboxes.end(); ++iter) { | 2174 iter != group->comboboxes.end(); ++iter) { |
| 2175 const ValidityMessage& message = | 2175 const ValidityMessage& message = |
| 2176 messages.GetMessageOrDefault(iter->first->type); | 2176 messages.GetMessageOrDefault(iter->first); |
| 2177 if (overwrite_unsure || message.sure) | 2177 if (overwrite_unsure || message.sure) |
| 2178 SetValidityForInput(iter->second, message.text); | 2178 SetValidityForInput(iter->second, message.text); |
| 2179 } | 2179 } |
| 2180 } else { | 2180 } else { |
| 2181 // Purge invisible views from |validity_map_|. | 2181 // Purge invisible views from |validity_map_|. |
| 2182 std::map<views::View*, base::string16>::iterator it; | 2182 std::map<views::View*, base::string16>::iterator it; |
| 2183 for (it = validity_map_.begin(); it != validity_map_.end();) { | 2183 for (it = validity_map_.begin(); it != validity_map_.end();) { |
| 2184 DCHECK(GroupForView(it->first)); | 2184 DCHECK(GroupForView(it->first)); |
| 2185 if (GroupForView(it->first) == group) | 2185 if (GroupForView(it->first) == group) |
| 2186 validity_map_.erase(it++); | 2186 validity_map_.erase(it++); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2197 message.text); | 2197 message.text); |
| 2198 } | 2198 } |
| 2199 } | 2199 } |
| 2200 } | 2200 } |
| 2201 } | 2201 } |
| 2202 | 2202 |
| 2203 bool AutofillDialogViews::ValidateGroup(const DetailsGroup& group, | 2203 bool AutofillDialogViews::ValidateGroup(const DetailsGroup& group, |
| 2204 ValidationType validation_type) { | 2204 ValidationType validation_type) { |
| 2205 DCHECK(group.container->visible()); | 2205 DCHECK(group.container->visible()); |
| 2206 | 2206 |
| 2207 scoped_ptr<DetailInput> cvc_input; | 2207 FieldValueMap detail_outputs; |
| 2208 DetailOutputMap detail_outputs; | |
| 2209 | 2208 |
| 2210 if (group.manual_input->visible()) { | 2209 if (group.manual_input->visible()) { |
| 2211 for (TextfieldMap::const_iterator iter = group.textfields.begin(); | 2210 for (TextfieldMap::const_iterator iter = group.textfields.begin(); |
| 2212 iter != group.textfields.end(); ++iter) { | 2211 iter != group.textfields.end(); ++iter) { |
| 2213 if (!iter->second->editable()) | 2212 if (!iter->second->editable()) |
| 2214 continue; | 2213 continue; |
| 2215 | 2214 |
| 2216 detail_outputs[iter->first] = iter->second->text(); | 2215 detail_outputs[iter->first] = iter->second->text(); |
| 2217 } | 2216 } |
| 2218 for (ComboboxMap::const_iterator iter = group.comboboxes.begin(); | 2217 for (ComboboxMap::const_iterator iter = group.comboboxes.begin(); |
| 2219 iter != group.comboboxes.end(); ++iter) { | 2218 iter != group.comboboxes.end(); ++iter) { |
| 2220 if (!iter->second->enabled()) | 2219 if (!iter->second->enabled()) |
| 2221 continue; | 2220 continue; |
| 2222 | 2221 |
| 2223 views::Combobox* combobox = iter->second; | 2222 views::Combobox* combobox = iter->second; |
| 2224 base::string16 item = | 2223 base::string16 item = |
| 2225 combobox->model()->GetItemAt(combobox->selected_index()); | 2224 combobox->model()->GetItemAt(combobox->selected_index()); |
| 2226 detail_outputs[iter->first] = item; | 2225 detail_outputs[iter->first] = item; |
| 2227 } | 2226 } |
| 2228 } else if (group.section == GetCreditCardSection()) { | 2227 } else if (group.section == GetCreditCardSection()) { |
| 2229 DecoratedTextfield* decorated_cvc = | 2228 DecoratedTextfield* decorated_cvc = |
| 2230 group.suggested_info->decorated_textfield(); | 2229 group.suggested_info->decorated_textfield(); |
| 2231 if (decorated_cvc->visible()) { | 2230 if (decorated_cvc->visible()) |
| 2232 cvc_input.reset(new DetailInput); | 2231 detail_outputs[CREDIT_CARD_VERIFICATION_CODE] = decorated_cvc->text(); |
| 2233 cvc_input->type = CREDIT_CARD_VERIFICATION_CODE; | |
| 2234 detail_outputs[cvc_input.get()] = decorated_cvc->text(); | |
| 2235 } | |
| 2236 } | 2232 } |
| 2237 | 2233 |
| 2238 ValidityMessages validity = delegate_->InputsAreValid(group.section, | 2234 ValidityMessages validity = delegate_->InputsAreValid(group.section, |
| 2239 detail_outputs); | 2235 detail_outputs); |
| 2240 MarkInputsInvalid(group.section, validity, validation_type == VALIDATE_FINAL); | 2236 MarkInputsInvalid(group.section, validity, validation_type == VALIDATE_FINAL); |
| 2241 | 2237 |
| 2242 // If there are any validation errors, sure or unsure, the group is invalid. | 2238 // If there are any validation errors, sure or unsure, the group is invalid. |
| 2243 return !validity.HasErrors(); | 2239 return !validity.HasErrors(); |
| 2244 } | 2240 } |
| 2245 | 2241 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2275 iter != group->textfields.end(); | 2271 iter != group->textfields.end(); |
| 2276 ++iter) { | 2272 ++iter) { |
| 2277 decorated = iter->second; | 2273 decorated = iter->second; |
| 2278 if (decorated == textfield) { | 2274 if (decorated == textfield) { |
| 2279 delegate_->UserEditedOrActivatedInput(group->section, | 2275 delegate_->UserEditedOrActivatedInput(group->section, |
| 2280 iter->first, | 2276 iter->first, |
| 2281 GetWidget()->GetNativeView(), | 2277 GetWidget()->GetNativeView(), |
| 2282 textfield->GetBoundsInScreen(), | 2278 textfield->GetBoundsInScreen(), |
| 2283 textfield->text(), | 2279 textfield->text(), |
| 2284 was_edit); | 2280 was_edit); |
| 2285 type = iter->first->type; | 2281 type = iter->first; |
| 2286 break; | 2282 break; |
| 2287 } | 2283 } |
| 2288 } | 2284 } |
| 2289 | 2285 |
| 2290 if (textfield == group->suggested_info->decorated_textfield()) { | 2286 if (textfield == group->suggested_info->decorated_textfield()) { |
| 2291 decorated = group->suggested_info->decorated_textfield(); | 2287 decorated = group->suggested_info->decorated_textfield(); |
| 2292 type = CREDIT_CARD_VERIFICATION_CODE; | 2288 type = CREDIT_CARD_VERIFICATION_CODE; |
| 2293 } | 2289 } |
| 2294 DCHECK_NE(UNKNOWN_TYPE, type); | 2290 DCHECK_NE(UNKNOWN_TYPE, type); |
| 2295 | 2291 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2370 } | 2366 } |
| 2371 } | 2367 } |
| 2372 return NULL; | 2368 return NULL; |
| 2373 } | 2369 } |
| 2374 | 2370 |
| 2375 views::Textfield* AutofillDialogViews::TextfieldForInput( | 2371 views::Textfield* AutofillDialogViews::TextfieldForInput( |
| 2376 const DetailInput& input) { | 2372 const DetailInput& input) { |
| 2377 for (DetailGroupMap::iterator iter = detail_groups_.begin(); | 2373 for (DetailGroupMap::iterator iter = detail_groups_.begin(); |
| 2378 iter != detail_groups_.end(); ++iter) { | 2374 iter != detail_groups_.end(); ++iter) { |
| 2379 const DetailsGroup& group = iter->second; | 2375 const DetailsGroup& group = iter->second; |
| 2380 TextfieldMap::const_iterator text_mapping = group.textfields.find(&input); | 2376 TextfieldMap::const_iterator text_mapping = |
| 2377 group.textfields.find(input.type); |
| 2381 if (text_mapping != group.textfields.end()) | 2378 if (text_mapping != group.textfields.end()) |
| 2382 return text_mapping->second; | 2379 return text_mapping->second; |
| 2383 } | 2380 } |
| 2384 | 2381 |
| 2385 return NULL; | 2382 return NULL; |
| 2386 } | 2383 } |
| 2387 | 2384 |
| 2388 views::Combobox* AutofillDialogViews::ComboboxForInput( | 2385 views::Combobox* AutofillDialogViews::ComboboxForInput( |
| 2389 const DetailInput& input) { | 2386 const DetailInput& input) { |
| 2390 for (DetailGroupMap::iterator iter = detail_groups_.begin(); | 2387 for (DetailGroupMap::iterator iter = detail_groups_.begin(); |
| 2391 iter != detail_groups_.end(); ++iter) { | 2388 iter != detail_groups_.end(); ++iter) { |
| 2392 const DetailsGroup& group = iter->second; | 2389 const DetailsGroup& group = iter->second; |
| 2393 ComboboxMap::const_iterator combo_mapping = group.comboboxes.find(&input); | 2390 ComboboxMap::const_iterator combo_mapping = |
| 2391 group.comboboxes.find(input.type); |
| 2394 if (combo_mapping != group.comboboxes.end()) | 2392 if (combo_mapping != group.comboboxes.end()) |
| 2395 return combo_mapping->second; | 2393 return combo_mapping->second; |
| 2396 } | 2394 } |
| 2397 | 2395 |
| 2398 return NULL; | 2396 return NULL; |
| 2399 } | 2397 } |
| 2400 | 2398 |
| 2401 void AutofillDialogViews::DetailsContainerBoundsChanged() { | 2399 void AutofillDialogViews::DetailsContainerBoundsChanged() { |
| 2402 if (error_bubble_) | 2400 if (error_bubble_) |
| 2403 error_bubble_->UpdatePosition(); | 2401 error_bubble_->UpdatePosition(); |
| 2404 } | 2402 } |
| 2405 | 2403 |
| 2406 void AutofillDialogViews::SetIconsForSection(DialogSection section) { | 2404 void AutofillDialogViews::SetIconsForSection(DialogSection section) { |
| 2407 DetailOutputMap user_input; | 2405 FieldValueMap user_input; |
| 2408 GetUserInput(section, &user_input); | 2406 GetUserInput(section, &user_input); |
| 2409 FieldValueMap field_values; | 2407 FieldIconMap field_icons = delegate_->IconsForFields(user_input); |
| 2410 for (DetailOutputMap::const_iterator user_input_it = user_input.begin(); | |
| 2411 user_input_it != user_input.end(); | |
| 2412 ++user_input_it) { | |
| 2413 const DetailInput* field_detail = user_input_it->first; | |
| 2414 const string16& field_value = user_input_it->second; | |
| 2415 field_values[field_detail->type] = field_value; | |
| 2416 } | |
| 2417 FieldIconMap field_icons = delegate_->IconsForFields(field_values); | |
| 2418 TextfieldMap* textfields = &GroupForSection(section)->textfields; | 2408 TextfieldMap* textfields = &GroupForSection(section)->textfields; |
| 2419 for (TextfieldMap::const_iterator textfield_it = textfields->begin(); | 2409 for (TextfieldMap::const_iterator textfield_it = textfields->begin(); |
| 2420 textfield_it != textfields->end(); | 2410 textfield_it != textfields->end(); |
| 2421 ++textfield_it) { | 2411 ++textfield_it) { |
| 2422 ServerFieldType field_type = textfield_it->first->type; | 2412 ServerFieldType field_type = textfield_it->first; |
| 2423 FieldIconMap::const_iterator field_icon_it = field_icons.find(field_type); | 2413 FieldIconMap::const_iterator field_icon_it = field_icons.find(field_type); |
| 2424 DecoratedTextfield* textfield = textfield_it->second; | 2414 DecoratedTextfield* textfield = textfield_it->second; |
| 2425 if (field_icon_it != field_icons.end()) | 2415 if (field_icon_it != field_icons.end()) |
| 2426 textfield->SetIcon(field_icon_it->second); | 2416 textfield->SetIcon(field_icon_it->second); |
| 2427 else | 2417 else |
| 2428 textfield->SetTooltipIcon(delegate_->TooltipForField(field_type)); | 2418 textfield->SetTooltipIcon(delegate_->TooltipForField(field_type)); |
| 2429 } | 2419 } |
| 2430 } | 2420 } |
| 2431 | 2421 |
| 2432 void AutofillDialogViews::SetEditabilityForSection(DialogSection section) { | 2422 void AutofillDialogViews::SetEditabilityForSection(DialogSection section) { |
| 2433 const DetailInputs& inputs = | 2423 const DetailInputs& inputs = |
| 2434 delegate_->RequestedFieldsForSection(section); | 2424 delegate_->RequestedFieldsForSection(section); |
| 2435 DetailsGroup* group = GroupForSection(section); | 2425 DetailsGroup* group = GroupForSection(section); |
| 2436 | 2426 |
| 2437 for (DetailInputs::const_iterator iter = inputs.begin(); | 2427 for (DetailInputs::const_iterator iter = inputs.begin(); |
| 2438 iter != inputs.end(); ++iter) { | 2428 iter != inputs.end(); ++iter) { |
| 2439 const DetailInput& input = *iter; | 2429 const DetailInput& input = *iter; |
| 2440 bool editable = delegate_->InputIsEditable(input, section); | 2430 bool editable = delegate_->InputIsEditable(input, section); |
| 2441 | 2431 |
| 2442 TextfieldMap::iterator text_mapping = group->textfields.find(&input); | 2432 TextfieldMap::iterator text_mapping = group->textfields.find(input.type); |
| 2443 if (text_mapping != group->textfields.end()) { | 2433 if (text_mapping != group->textfields.end()) { |
| 2444 DecoratedTextfield* decorated = text_mapping->second; | 2434 DecoratedTextfield* decorated = text_mapping->second; |
| 2445 decorated->SetEditable(editable); | 2435 decorated->SetEditable(editable); |
| 2446 continue; | 2436 continue; |
| 2447 } | 2437 } |
| 2448 | 2438 |
| 2449 ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input); | 2439 ComboboxMap::iterator combo_mapping = group->comboboxes.find(input.type); |
| 2450 if (combo_mapping != group->comboboxes.end()) { | 2440 if (combo_mapping != group->comboboxes.end()) { |
| 2451 views::Combobox* combobox = combo_mapping->second; | 2441 views::Combobox* combobox = combo_mapping->second; |
| 2452 combobox->SetEnabled(editable); | 2442 combobox->SetEnabled(editable); |
| 2453 } | 2443 } |
| 2454 } | 2444 } |
| 2455 } | 2445 } |
| 2456 | 2446 |
| 2457 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2447 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
| 2458 : section(section), | 2448 : section(section), |
| 2459 container(NULL), | 2449 container(NULL), |
| 2460 manual_input(NULL), | 2450 manual_input(NULL), |
| 2461 suggested_info(NULL), | 2451 suggested_info(NULL), |
| 2462 suggested_button(NULL) {} | 2452 suggested_button(NULL) {} |
| 2463 | 2453 |
| 2464 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2454 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
| 2465 | 2455 |
| 2466 } // namespace autofill | 2456 } // namespace autofill |
| OLD | NEW |