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

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: Modifying wraparound 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_(kNoSelection) {
20 if (!web_contents)
21 return;
22
20 registrar_.Add(this, 23 registrar_.Add(this,
21 content::NOTIFICATION_WEB_CONTENTS_HIDDEN, 24 content::NOTIFICATION_WEB_CONTENTS_HIDDEN,
22 content::Source<content::WebContents>(web_contents)); 25 content::Source<content::WebContents>(web_contents));
23 registrar_.Add( 26 registrar_.Add(
24 this, 27 this,
25 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 28 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
26 content::Source<content::NavigationController>( 29 content::Source<content::NavigationController>(
27 &(web_contents->GetController()))); 30 &(web_contents->GetController())));
28 } 31 }
29 32
(...skipping 17 matching lines...) Expand all
47 50
48 separator_index_ = separator_index; 51 separator_index_ = separator_index;
49 52
50 ShowInternal(); 53 ShowInternal();
51 } 54 }
52 55
53 void AutofillPopupView::SetSelectedLine(int selected_line) { 56 void AutofillPopupView::SetSelectedLine(int selected_line) {
54 if (selected_line_ == selected_line) 57 if (selected_line_ == selected_line)
55 return; 58 return;
56 59
57 if (selected_line_ != -1) 60 if (selected_line_ != kNoSelection)
58 InvalidateRow(selected_line_); 61 InvalidateRow(selected_line_);
59 62
60 if (selected_line != -1) 63 if (selected_line != kNoSelection)
61 InvalidateRow(selected_line); 64 InvalidateRow(selected_line);
62 65
63 selected_line_ = selected_line; 66 selected_line_ = selected_line;
64 67
65 if (selected_line_ != -1) { 68 if (selected_line_ != kNoSelection) {
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::SelectNextLine() {
76 int new_selected_line = selected_line_ + 1;
77
78 if (new_selected_line == static_cast<int>(autofill_values_.size()))
79 new_selected_line = 0;
80
81 SetSelectedLine(new_selected_line);
82 }
83
84 void AutofillPopupView::SelectPreviousLine() {
85 int new_selected_line = selected_line_ - 1;
86
87 if (new_selected_line <= kNoSelection)
88 new_selected_line = autofill_values_.size() - 1;
89
90 SetSelectedLine(new_selected_line);
91 }
92
93 bool AutofillPopupView::AcceptSelectedLine() {
94 if (selected_line_ == kNoSelection)
95 return false;
96
97 DCHECK_GE(selected_line_, 0);
98 DCHECK_LT(selected_line_, static_cast<int>(autofill_values_.size()));
99
100 return external_delegate()->DidAcceptAutofillSuggestions(
101 autofill_values_[selected_line_],
102 autofill_unique_ids_[selected_line_],
103 selected_line_);
104 }
105
106 bool AutofillPopupView::RemoveSelectedLine() {
107 if (selected_line_ == kNoSelection)
108 return false;
109
110 // TODO(csharp) add removal code.
111 return false;
112 }
113
72 void AutofillPopupView::Observe(int type, 114 void AutofillPopupView::Observe(int type,
73 const content::NotificationSource& source, 115 const content::NotificationSource& source,
74 const content::NotificationDetails& details) { 116 const content::NotificationDetails& details) {
75 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN 117 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN
76 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) 118 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED)
77 Hide(); 119 Hide();
78 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698