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 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 void AutofillDialogViews::UpdateSection(DialogSection section) { | 1309 void AutofillDialogViews::UpdateSection(DialogSection section) { |
1310 UpdateSectionImpl(section, true); | 1310 UpdateSectionImpl(section, true); |
1311 } | 1311 } |
1312 | 1312 |
1313 void AutofillDialogViews::UpdateErrorBubble() { | 1313 void AutofillDialogViews::UpdateErrorBubble() { |
1314 if (!delegate_->ShouldShowErrorBubble()) | 1314 if (!delegate_->ShouldShowErrorBubble()) |
1315 HideErrorBubble(); | 1315 HideErrorBubble(); |
1316 } | 1316 } |
1317 | 1317 |
1318 void AutofillDialogViews::FillSection(DialogSection section, | 1318 void AutofillDialogViews::FillSection(DialogSection section, |
1319 const DetailInput& originating_input) { | 1319 ServerFieldType originating_type) { |
1320 DetailsGroup* group = GroupForSection(section); | 1320 DetailsGroup* group = GroupForSection(section); |
1321 // Make sure to overwrite the originating input. | 1321 // Make sure to overwrite the originating input. |
1322 TextfieldMap::iterator text_mapping = | 1322 TextfieldMap::iterator text_mapping = |
1323 group->textfields.find(originating_input.type); | 1323 group->textfields.find(originating_type); |
1324 if (text_mapping != group->textfields.end()) | 1324 if (text_mapping != group->textfields.end()) |
1325 text_mapping->second->SetText(base::string16()); | 1325 text_mapping->second->SetText(base::string16()); |
1326 | 1326 |
1327 // If the Autofill data comes from a credit card, make sure to overwrite the | 1327 // If the Autofill data comes from a credit card, make sure to overwrite the |
1328 // CC comboboxes (even if they already have something in them). If the | 1328 // CC comboboxes (even if they already have something in them). If the |
1329 // Autofill data comes from an AutofillProfile, leave the comboboxes alone. | 1329 // Autofill data comes from an AutofillProfile, leave the comboboxes alone. |
1330 if (section == GetCreditCardSection() && | 1330 if (section == GetCreditCardSection() && |
1331 AutofillType(originating_input.type).group() == CREDIT_CARD) { | 1331 AutofillType(originating_type).group() == CREDIT_CARD) { |
1332 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); | 1332 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); |
1333 it != group->comboboxes.end(); ++it) { | 1333 it != group->comboboxes.end(); ++it) { |
1334 if (AutofillType(it->first).group() == CREDIT_CARD) | 1334 if (AutofillType(it->first).group() == CREDIT_CARD) |
1335 it->second->SetSelectedIndex(it->second->model()->GetDefaultIndex()); | 1335 it->second->SetSelectedIndex(it->second->model()->GetDefaultIndex()); |
1336 } | 1336 } |
1337 } | 1337 } |
1338 | 1338 |
1339 UpdateSectionImpl(section, false); | 1339 UpdateSectionImpl(section, false); |
1340 } | 1340 } |
1341 | 1341 |
1342 void AutofillDialogViews::GetUserInput(DialogSection section, | 1342 void AutofillDialogViews::GetUserInput(DialogSection section, |
1343 FieldValueMap* output) { | 1343 FieldValueMap* output) { |
1344 DetailsGroup* group = GroupForSection(section); | 1344 DetailsGroup* group = GroupForSection(section); |
1345 for (TextfieldMap::const_iterator it = group->textfields.begin(); | 1345 for (TextfieldMap::const_iterator it = group->textfields.begin(); |
1346 it != group->textfields.end(); ++it) { | 1346 it != group->textfields.end(); ++it) { |
1347 output->insert(std::make_pair(it->first, it->second->text())); | 1347 output->insert(std::make_pair(it->first, it->second->text())); |
1348 } | 1348 } |
1349 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); | 1349 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); |
1350 it != group->comboboxes.end(); ++it) { | 1350 it != group->comboboxes.end(); ++it) { |
1351 output->insert(std::make_pair(it->first, | 1351 output->insert(std::make_pair(it->first, |
1352 it->second->model()->GetItemAt(it->second->selected_index()))); | 1352 it->second->model()->GetItemAt(it->second->selected_index()))); |
1353 } | 1353 } |
1354 } | 1354 } |
1355 | 1355 |
1356 base::string16 AutofillDialogViews::GetCvc() { | 1356 base::string16 AutofillDialogViews::GetCvc() { |
1357 return GroupForSection(GetCreditCardSection())->suggested_info-> | 1357 return GroupForSection(GetCreditCardSection())->suggested_info-> |
1358 decorated_textfield()->text(); | 1358 decorated_textfield()->text(); |
1359 } | 1359 } |
1360 | 1360 |
1361 bool AutofillDialogViews::HitTestInput(const DetailInput& input, | 1361 bool AutofillDialogViews::HitTestInput(ServerFieldType type, |
1362 const gfx::Point& screen_point) { | 1362 const gfx::Point& screen_point) { |
1363 views::View* view = TextfieldForType(input.type); | 1363 views::View* view = TextfieldForType(type); |
1364 if (!view) | 1364 if (!view) |
1365 view = ComboboxForType(input.type); | 1365 view = ComboboxForType(type); |
1366 | 1366 |
1367 if (view) { | 1367 if (view) { |
1368 gfx::Point target_point(screen_point); | 1368 gfx::Point target_point(screen_point); |
1369 views::View::ConvertPointFromScreen(view, &target_point); | 1369 views::View::ConvertPointFromScreen(view, &target_point); |
1370 return view->HitTestPoint(target_point); | 1370 return view->HitTestPoint(target_point); |
1371 } | 1371 } |
1372 | 1372 |
1373 NOTREACHED(); | 1373 NOTREACHED(); |
1374 return false; | 1374 return false; |
1375 } | 1375 } |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2451 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2451 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
2452 : section(section), | 2452 : section(section), |
2453 container(NULL), | 2453 container(NULL), |
2454 manual_input(NULL), | 2454 manual_input(NULL), |
2455 suggested_info(NULL), | 2455 suggested_info(NULL), |
2456 suggested_button(NULL) {} | 2456 suggested_button(NULL) {} |
2457 | 2457 |
2458 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2458 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
2459 | 2459 |
2460 } // namespace autofill | 2460 } // namespace autofill |
OLD | NEW |