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

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: Using keyboard listener to get keypresses 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 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 : external_delegate_(external_delegate),
19 selected_line_(-1) { 19 selected_line_(-1) {
20 registrar_.Add(this, 20 registrar_.Add(this,
21 content::NOTIFICATION_WEB_CONTENTS_HIDDEN, 21 content::NOTIFICATION_WEB_CONTENTS_HIDDEN,
22 content::Source<content::WebContents>(web_contents)); 22 content::Source<content::WebContents>(web_contents));
23 registrar_.Add( 23
24 this, 24 if (web_contents) {
Ilya Sherman 2012/03/15 20:10:56 nit: How about "if (!web_contents) return;" at the
csharp 2012/03/21 15:32:28 Done.
25 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 25 registrar_.Add(
26 content::Source<content::NavigationController>( 26 this,
27 &(web_contents->GetController()))); 27 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
28 content::Source<content::NavigationController>(
29 &(web_contents->GetController())));
30 }
28 } 31 }
29 32
30 AutofillPopupView::~AutofillPopupView() {} 33 AutofillPopupView::~AutofillPopupView() {}
31 34
32 void AutofillPopupView::Hide() { 35 void AutofillPopupView::Hide() {
33 HideInternal(); 36 HideInternal();
34 37
35 external_delegate_->ClearPreviewedForm(); 38 external_delegate_->ClearPreviewedForm();
36 } 39 }
37 40
(...skipping 24 matching lines...) Expand all
62 65
63 selected_line_ = selected_line; 66 selected_line_ = selected_line;
64 67
65 if (selected_line_ != -1) { 68 if (selected_line_ != -1) {
66 external_delegate_->SelectAutofillSuggestionAtIndex( 69 external_delegate_->SelectAutofillSuggestionAtIndex(
67 autofill_unique_ids_[selected_line_], 70 autofill_unique_ids_[selected_line_],
68 selected_line); 71 selected_line);
69 } 72 }
70 } 73 }
71 74
75 void AutofillPopupView::IncreaseSelectedLine() {
76 int new_selected_line = selected_line_ + 1;
77
78 if (new_selected_line == static_cast<int>(autofill_values_.size()))
79 new_selected_line = -1;
Ilya Sherman 2012/03/15 20:10:56 nit: Why -1 and not 0?
csharp 2012/03/21 15:32:28 Because when you go off either edge you have no se
Ilya Sherman 2012/03/21 23:35:30 Are you matching a system UI convention, or the ex
csharp 2012/03/23 15:15:19 This is the current WebKit Autofill method.
Ilya Sherman 2012/03/23 22:31:13 Ok. Unless this matches a system convention, or m
80
81 SetSelectedLine(new_selected_line);
82 }
83
84 void AutofillPopupView::DecreaseSelectedLine() {
85 int new_selected_line = selected_line_ - 1;
86
87 if (new_selected_line == -2)
88 new_selected_line = autofill_values_.size() - 1;
89
90 SetSelectedLine(new_selected_line);
91 }
92
93 void AutofillPopupView::ChooseLine(int line) {
94 if (line < 0 || line >= static_cast<int>(autofill_values_.size())) {
Ilya Sherman 2012/03/15 20:10:56 Hmm, why is this code reachable? (I.e., what is t
csharp 2012/03/21 15:32:28 Shouldn't be, but I've added a DCHECK to just make
95 // Ensure that the popup is no longer visible since the user has
96 // made a selection.
97 Hide();
98 return;
99 }
100
101 external_delegate()->DidAcceptAutofillSuggestions(
102 autofill_values_[line],
103 autofill_unique_ids_[line],
104 line);
105 }
106
107 void AutofillPopupView::RemoveLine(int line) {
108 // TODO(csharp) add removal code.
109 }
110
72 void AutofillPopupView::Observe(int type, 111 void AutofillPopupView::Observe(int type,
73 const content::NotificationSource& source, 112 const content::NotificationSource& source,
74 const content::NotificationDetails& details) { 113 const content::NotificationDetails& details) {
75 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN 114 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN
76 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) 115 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED)
77 Hide(); 116 Hide();
78 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698