Chromium Code Reviews| Index: chrome/browser/autofill/autofill_popup_view.cc |
| diff --git a/chrome/browser/autofill/autofill_popup_view.cc b/chrome/browser/autofill/autofill_popup_view.cc |
| index 7e3ba5a3be0d87fca605378dd1c5b1d6857fa3ad..940974e4e7753a04b31bfc3bfd9d889c9bd9185b 100644 |
| --- a/chrome/browser/autofill/autofill_popup_view.cc |
| +++ b/chrome/browser/autofill/autofill_popup_view.cc |
| @@ -17,6 +17,9 @@ AutofillPopupView::AutofillPopupView( |
| AutofillExternalDelegate* external_delegate) |
| : external_delegate_(external_delegate), |
| selected_line_(-1) { |
|
Ilya Sherman
2012/03/21 23:35:30
nit: Please use the named constant here.
csharp
2012/03/23 15:10:52
Done.
|
| + if (!web_contents) |
| + return; |
| + |
| registrar_.Add(this, |
| content::NOTIFICATION_WEB_CONTENTS_HIDDEN, |
| content::Source<content::WebContents>(web_contents)); |
| @@ -54,21 +57,53 @@ void AutofillPopupView::SetSelectedLine(int selected_line) { |
| if (selected_line_ == selected_line) |
| return; |
| - if (selected_line_ != -1) |
| + if (selected_line_ != kNoSelection) |
| InvalidateRow(selected_line_); |
| - if (selected_line != -1) |
| + if (selected_line != kNoSelection) |
| InvalidateRow(selected_line); |
| selected_line_ = selected_line; |
| - if (selected_line_ != -1) { |
| + if (selected_line_ != kNoSelection) { |
| external_delegate_->SelectAutofillSuggestionAtIndex( |
| autofill_unique_ids_[selected_line_], |
| selected_line); |
| } |
| } |
| +void AutofillPopupView::SelectNextLine() { |
| + int new_selected_line = selected_line_ + 1; |
| + |
| + if (new_selected_line == static_cast<int>(autofill_values_.size())) |
| + new_selected_line = kNoSelection; |
| + |
| + SetSelectedLine(new_selected_line); |
| +} |
| + |
| +void AutofillPopupView::SelectPreviousLine() { |
| + int new_selected_line = selected_line_ - 1; |
| + |
| + if (new_selected_line < kNoSelection) |
| + new_selected_line = autofill_values_.size() - 1; |
| + |
| + SetSelectedLine(new_selected_line); |
| +} |
| + |
| +void AutofillPopupView::AcceptSelectedLine() { |
| + DCHECK(selected_line_ >= 0 && |
| + selected_line_ < static_cast<int>(autofill_values_.size())); |
|
Ilya Sherman
2012/03/21 23:35:30
nit: Please write this as a DCHECK_GE and DCHECK_L
csharp
2012/03/23 15:10:52
Done.
|
| + |
| + external_delegate()->DidAcceptAutofillSuggestions( |
| + autofill_values_[selected_line_], |
| + autofill_unique_ids_[selected_line_], |
| + selected_line_); |
| +} |
| + |
| +void AutofillPopupView::RemoveLine(int line) { |
| + // TODO(csharp) add removal code. |
| +} |
| + |
| void AutofillPopupView::Observe(int type, |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) { |