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

Side by Side 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: Created 8 years, 8 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
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/autofill/autofill_popup_view.h" 5 #include "chrome/browser/autofill/autofill_popup_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/autofill/autofill_external_delegate.h" 8 #include "chrome/browser/autofill/autofill_external_delegate.h"
9 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "content/public/browser/navigation_controller.h" 10 #include "content/public/browser/navigation_controller.h"
11 #include "content/public/browser/notification_service.h" 11 #include "content/public/browser/notification_service.h"
12 #include "content/public/browser/notification_source.h" 12 #include "content/public/browser/notification_source.h"
13 #include "content/public/browser/notification_types.h" 13 #include "content/public/browser/notification_types.h"
14 14
15 AutofillPopupView::AutofillPopupView( 15 AutofillPopupView::AutofillPopupView(
16 content::WebContents* web_contents, 16 content::WebContents* web_contents,
17 AutofillExternalDelegate* external_delegate) 17 AutofillExternalDelegate* external_delegate)
18 : external_delegate_(external_delegate), 18 : kNoSelection(-1),
19 selected_line_(-1) { 19 external_delegate_(external_delegate),
20 selected_line_(kNoSelection) {
21 if (!web_contents)
22 return;
23
20 registrar_.Add(this, 24 registrar_.Add(this,
21 content::NOTIFICATION_WEB_CONTENTS_HIDDEN, 25 content::NOTIFICATION_WEB_CONTENTS_HIDDEN,
22 content::Source<content::WebContents>(web_contents)); 26 content::Source<content::WebContents>(web_contents));
23 registrar_.Add( 27 registrar_.Add(
24 this, 28 this,
25 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 29 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
26 content::Source<content::NavigationController>( 30 content::Source<content::NavigationController>(
27 &(web_contents->GetController()))); 31 &(web_contents->GetController())));
28 } 32 }
29 33
(...skipping 17 matching lines...) Expand all
47 51
48 separator_index_ = separator_index; 52 separator_index_ = separator_index;
49 53
50 ShowInternal(); 54 ShowInternal();
51 } 55 }
52 56
53 void AutofillPopupView::SetSelectedLine(int selected_line) { 57 void AutofillPopupView::SetSelectedLine(int selected_line) {
54 if (selected_line_ == selected_line) 58 if (selected_line_ == selected_line)
55 return; 59 return;
56 60
57 if (selected_line_ != -1) 61 if (selected_line_ != kNoSelection)
58 InvalidateRow(selected_line_); 62 InvalidateRow(selected_line_);
59 63
60 if (selected_line != -1) 64 if (selected_line != kNoSelection)
61 InvalidateRow(selected_line); 65 InvalidateRow(selected_line);
62 66
63 selected_line_ = selected_line; 67 selected_line_ = selected_line;
64 68
65 if (selected_line_ != -1) { 69 if (selected_line_ != kNoSelection) {
66 external_delegate_->SelectAutofillSuggestionAtIndex( 70 external_delegate_->SelectAutofillSuggestionAtIndex(
67 autofill_unique_ids_[selected_line_], 71 autofill_unique_ids_[selected_line_],
68 selected_line); 72 selected_line);
69 } 73 }
70 } 74 }
71 75
76 void AutofillPopupView::SelectNextLine() {
77 int new_selected_line = selected_line_ + 1;
78
79 if (new_selected_line == static_cast<int>(autofill_values_.size()))
80 new_selected_line = 0;
81
82 SetSelectedLine(new_selected_line);
83 }
84
85 void AutofillPopupView::SelectPreviousLine() {
86 int new_selected_line = selected_line_ - 1;
87
88 if (new_selected_line <= kNoSelection)
89 new_selected_line = autofill_values_.size() - 1;
90
91 SetSelectedLine(new_selected_line);
92 }
93
94 bool AutofillPopupView::AcceptSelectedLine() {
95 if (selected_line_ == kNoSelection)
96 return false;
97
98 DCHECK_GE(selected_line_, 0);
99 DCHECK_LT(selected_line_, static_cast<int>(autofill_values_.size()));
100
101 return external_delegate()->DidAcceptAutofillSuggestions(
102 autofill_values_[selected_line_],
103 autofill_unique_ids_[selected_line_],
104 selected_line_);
105 }
106
107 bool AutofillPopupView::RemoveSelectedLine() {
108 if (selected_line_ == kNoSelection)
109 return false;
110
111 // TODO(csharp) add removal code.
112 return false;
113 }
114
72 void AutofillPopupView::Observe(int type, 115 void AutofillPopupView::Observe(int type,
73 const content::NotificationSource& source, 116 const content::NotificationSource& source,
74 const content::NotificationDetails& details) { 117 const content::NotificationDetails& details) {
75 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN 118 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN
76 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) 119 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED)
77 Hide(); 120 Hide();
78 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698