| 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..6c25109c151ea34e012cfccd208d24ef8bf80384 100644
|
| --- a/chrome/browser/autofill/autofill_popup_view.cc
|
| +++ b/chrome/browser/autofill/autofill_popup_view.cc
|
| @@ -16,7 +16,10 @@ AutofillPopupView::AutofillPopupView(
|
| content::WebContents* web_contents,
|
| AutofillExternalDelegate* external_delegate)
|
| : external_delegate_(external_delegate),
|
| - selected_line_(-1) {
|
| + selected_line_(kNoSelection) {
|
| + if (!web_contents)
|
| + return;
|
| +
|
| registrar_.Add(this,
|
| content::NOTIFICATION_WEB_CONTENTS_HIDDEN,
|
| content::Source<content::WebContents>(web_contents));
|
| @@ -54,21 +57,54 @@ 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);
|
| +}
|
| +
|
| +bool AutofillPopupView::AcceptSelectedLine() {
|
| + DCHECK_GE(selected_line_, 0);
|
| + DCHECK_LT(selected_line_, static_cast<int>(autofill_values_.size()));
|
| +
|
| + return external_delegate()->DidAcceptAutofillSuggestions(
|
| + autofill_values_[selected_line_],
|
| + autofill_unique_ids_[selected_line_],
|
| + selected_line_);
|
| +}
|
| +
|
| +bool AutofillPopupView::RemoveSelectedLine() {
|
| + // TODO(csharp) add removal code.
|
| + return false;
|
| +}
|
| +
|
| void AutofillPopupView::Observe(int type,
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) {
|
|
|