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

Unified Diff: chrome/browser/autofill/autofill_popup_view.cc

Issue 9432029: GTK Keyboard Support for New Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing switch case Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
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..76625dcd7557a6b6d2d3be28e1e58a5e18dbf173 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,60 @@ 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 = 0;
+
+ 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() {
+ if (selected_line_ == kNoSelection)
+ return false;
+
+ 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() {
+ if (selected_line_ == kNoSelection)
+ return false;
+
+ // TODO(csharp) add removal code.
+ return false;
+}
+
void AutofillPopupView::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {

Powered by Google App Engine
This is Rietveld 408576698