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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_dialog_views.cc

Issue 23756007: [rac] Show amex specific cvc hint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Enable going from icon to no icon 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 (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 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 } 1926 }
1927 } 1927 }
1928 1928
1929 view_to_add.reset(combobox); 1929 view_to_add.reset(combobox);
1930 } else { 1930 } else {
1931 DecoratedTextfield* field = new DecoratedTextfield( 1931 DecoratedTextfield* field = new DecoratedTextfield(
1932 input.initial_value, 1932 input.initial_value,
1933 l10n_util::GetStringUTF16(input.placeholder_text_rid), 1933 l10n_util::GetStringUTF16(input.placeholder_text_rid),
1934 this); 1934 this);
1935 1935
1936 gfx::Image icon =
1937 delegate_->IconForField(input.type, input.initial_value);
1938 field->SetIcon(icon);
1939
1940 textfields->insert(std::make_pair(&input, field)); 1936 textfields->insert(std::make_pair(&input, field));
1941 view_to_add.reset(field); 1937 view_to_add.reset(field);
1942 } 1938 }
1943 1939
1944 int kColumnSetId = input.row_id; 1940 int kColumnSetId = input.row_id;
1945 if (kColumnSetId < 0) { 1941 if (kColumnSetId < 0) {
1946 other_owned_views_.push_back(view_to_add.release()); 1942 other_owned_views_.push_back(view_to_add.release());
1947 continue; 1943 continue;
1948 } 1944 }
1949 1945
(...skipping 21 matching lines...) Expand all
1971 0); 1967 0);
1972 1968
1973 // This is the same as AddView(view_to_add), except that 1 is used for the 1969 // This is the same as AddView(view_to_add), except that 1 is used for the
1974 // view's preferred width. Thus the width of the column completely depends 1970 // view's preferred width. Thus the width of the column completely depends
1975 // on |expand|. 1971 // on |expand|.
1976 layout->AddView(view_to_add.release(), 1, 1, 1972 layout->AddView(view_to_add.release(), 1, 1,
1977 views::GridLayout::FILL, views::GridLayout::FILL, 1973 views::GridLayout::FILL, views::GridLayout::FILL,
1978 1, 0); 1974 1, 0);
1979 } 1975 }
1980 1976
1977 SetIconsForSection(section);
1978
1981 return view; 1979 return view;
1982 } 1980 }
1983 1981
1984 void AutofillDialogViews::UpdateSectionImpl( 1982 void AutofillDialogViews::UpdateSectionImpl(
1985 DialogSection section, 1983 DialogSection section,
1986 bool clobber_inputs) { 1984 bool clobber_inputs) {
1987 const DetailInputs& updated_inputs = 1985 const DetailInputs& updated_inputs =
1988 delegate_->RequestedFieldsForSection(section); 1986 delegate_->RequestedFieldsForSection(section);
1989 DetailsGroup* group = GroupForSection(section); 1987 DetailsGroup* group = GroupForSection(section);
1990 1988
1991 for (DetailInputs::const_iterator iter = updated_inputs.begin(); 1989 for (DetailInputs::const_iterator iter = updated_inputs.begin();
1992 iter != updated_inputs.end(); ++iter) { 1990 iter != updated_inputs.end(); ++iter) {
1993 const DetailInput& input = *iter; 1991 const DetailInput& input = *iter;
1994 TextfieldMap::iterator text_mapping = group->textfields.find(&input); 1992 TextfieldMap::iterator text_mapping = group->textfields.find(&input);
1995 1993
1996 if (text_mapping != group->textfields.end()) { 1994 if (text_mapping != group->textfields.end()) {
1997 DecoratedTextfield* decorated = text_mapping->second; 1995 DecoratedTextfield* decorated = text_mapping->second;
1998 decorated->SetEnabled(input.editable); 1996 decorated->SetEnabled(input.editable);
1999 if (decorated->text().empty() || clobber_inputs) { 1997 if (decorated->text().empty() || clobber_inputs)
2000 decorated->SetText(iter->initial_value); 1998 decorated->SetText(iter->initial_value);
2001 decorated->SetIcon(
2002 delegate_->IconForField(input.type, decorated->text()));
2003 }
2004 } 1999 }
2005 2000
2006 ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input); 2001 ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input);
2007 if (combo_mapping != group->comboboxes.end()) { 2002 if (combo_mapping != group->comboboxes.end()) {
2008 views::Combobox* combobox = combo_mapping->second; 2003 views::Combobox* combobox = combo_mapping->second;
2009 combobox->SetEnabled(input.editable); 2004 combobox->SetEnabled(input.editable);
2010 if (combobox->selected_index() == combobox->model()->GetDefaultIndex() || 2005 if (combobox->selected_index() == combobox->model()->GetDefaultIndex() ||
2011 clobber_inputs) { 2006 clobber_inputs) {
2012 for (int i = 0; i < combobox->model()->GetItemCount(); ++i) { 2007 for (int i = 0; i < combobox->model()->GetItemCount(); ++i) {
2013 if (input.initial_value == combobox->model()->GetItemAt(i)) { 2008 if (input.initial_value == combobox->model()->GetItemAt(i)) {
2014 combobox->SetSelectedIndex(i); 2009 combobox->SetSelectedIndex(i);
2015 break; 2010 break;
2016 } 2011 }
2017 } 2012 }
2018 } 2013 }
2019 } 2014 }
2020 } 2015 }
2021 2016
2017 SetIconsForSection(section);
2022 UpdateDetailsGroupState(*group); 2018 UpdateDetailsGroupState(*group);
2023 } 2019 }
2024 2020
2025 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { 2021 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) {
2026 const SuggestionState& suggestion_state = 2022 const SuggestionState& suggestion_state =
2027 delegate_->SuggestionStateForSection(group.section); 2023 delegate_->SuggestionStateForSection(group.section);
2028 group.suggested_info->SetState(suggestion_state); 2024 group.suggested_info->SetState(suggestion_state);
2029 group.manual_input->SetVisible(!suggestion_state.visible); 2025 group.manual_input->SetVisible(!suggestion_state.visible);
2030 2026
2031 UpdateButtonStripExtraView(); 2027 UpdateButtonStripExtraView();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 2226
2231 // If the field is marked as invalid, check if the text is now valid. 2227 // If the field is marked as invalid, check if the text is now valid.
2232 // Many fields (i.e. CC#) are invalid for most of the duration of editing, 2228 // Many fields (i.e. CC#) are invalid for most of the duration of editing,
2233 // so flagging them as invalid prematurely is not helpful. However, 2229 // so flagging them as invalid prematurely is not helpful. However,
2234 // correcting a minor mistake (i.e. a wrong CC digit) should immediately 2230 // correcting a minor mistake (i.e. a wrong CC digit) should immediately
2235 // result in validation - positive user feedback. 2231 // result in validation - positive user feedback.
2236 if (decorated->invalid() && was_edit) { 2232 if (decorated->invalid() && was_edit) {
2237 SetValidityForInput<DecoratedTextfield>( 2233 SetValidityForInput<DecoratedTextfield>(
2238 decorated, 2234 decorated,
2239 delegate_->InputValidityMessage(group->section, type, 2235 delegate_->InputValidityMessage(group->section, type,
2240 textfield->text())); 2236 textfield->text()));
2241 2237
2242 // If the field transitioned from invalid to valid, re-validate the group, 2238 // If the field transitioned from invalid to valid, re-validate the group,
2243 // since inter-field checks become meaningful with valid fields. 2239 // since inter-field checks become meaningful with valid fields.
2244 if (!decorated->invalid()) 2240 if (!decorated->invalid())
2245 ValidateGroup(*group, VALIDATE_EDIT); 2241 ValidateGroup(*group, VALIDATE_EDIT);
2246 } 2242 }
2247 2243
2248 gfx::Image icon = delegate_->IconForField(type, textfield->text()); 2244 if (delegate_->FieldControlsIcons(type))
2249 decorated->SetIcon(icon); 2245 SetIconsForSection(group->section);
2250 } 2246 }
2251 2247
2252 void AutofillDialogViews::UpdateButtonStripExtraView() { 2248 void AutofillDialogViews::UpdateButtonStripExtraView() {
2253 save_in_chrome_checkbox_container_->SetVisible( 2249 save_in_chrome_checkbox_container_->SetVisible(
2254 delegate_->ShouldOfferToSaveInChrome()); 2250 delegate_->ShouldOfferToSaveInChrome());
2255 2251
2256 gfx::Image image = delegate_->ButtonStripImage(); 2252 gfx::Image image = delegate_->ButtonStripImage();
2257 button_strip_image_->SetVisible(!image.IsEmpty()); 2253 button_strip_image_->SetVisible(!image.IsEmpty());
2258 button_strip_image_->SetImage(image.AsImageSkia()); 2254 button_strip_image_->SetImage(image.AsImageSkia());
2259 } 2255 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 void AutofillDialogViews::DetailsContainerBoundsChanged() { 2328 void AutofillDialogViews::DetailsContainerBoundsChanged() {
2333 if (error_bubble_) 2329 if (error_bubble_)
2334 error_bubble_->UpdatePosition(); 2330 error_bubble_->UpdatePosition();
2335 } 2331 }
2336 2332
2337 bool AutofillDialogViews::SignInWebviewDictatesHeight() const { 2333 bool AutofillDialogViews::SignInWebviewDictatesHeight() const {
2338 return sign_in_webview_->visible() || 2334 return sign_in_webview_->visible() ||
2339 (sign_in_webview_->web_contents() && delegate_->ShouldShowSpinner()); 2335 (sign_in_webview_->web_contents() && delegate_->ShouldShowSpinner());
2340 } 2336 }
2341 2337
2338 void AutofillDialogViews::SetIconsForSection(DialogSection section) {
2339 DetailOutputMap user_input;
2340 GetUserInput(section, &user_input);
2341 FieldValueMap field_values;
2342 for (DetailOutputMap::const_iterator user_input_it = user_input.begin();
2343 user_input_it != user_input.end();
2344 ++user_input_it) {
2345 const DetailInput* field_detail = user_input_it->first;
2346 const string16& field_value = user_input_it->second;
2347 field_values[field_detail->type] = field_value;
2348 }
2349 FieldIconMap field_icons = delegate_->IconsForFields(field_values);
2350 TextfieldMap* textfields = &GroupForSection(section)->textfields;
2351 for (TextfieldMap::const_iterator textfield_it = textfields->begin();
2352 textfield_it != textfields->end();
2353 ++textfield_it) {
2354 ServerFieldType field_type = textfield_it->first->type;
2355 FieldIconMap::const_iterator field_icon_it = field_icons.find(field_type);
2356 DecoratedTextfield* textfield = textfield_it->second;
2357 if (field_icon_it == field_icons.end()) {
Evan Stade 2013/09/17 19:59:06 nit: textfield->SetIcon(field_icon_it == field_ic
please use gerrit instead 2013/09/17 20:32:24 Done.
2358 textfield->SetIcon(gfx::Image());
2359 continue;
2360 }
2361 const gfx::Image& field_icon = field_icon_it->second;
2362 textfield->SetIcon(field_icon);
2363 }
2364 }
2365
2342 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 2366 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
2343 : section(section), 2367 : section(section),
2344 container(NULL), 2368 container(NULL),
2345 manual_input(NULL), 2369 manual_input(NULL),
2346 suggested_info(NULL), 2370 suggested_info(NULL),
2347 suggested_button(NULL) {} 2371 suggested_button(NULL) {}
2348 2372
2349 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 2373 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
2350 2374
2351 } // namespace autofill 2375 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698