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

Side by Side Diff: chrome/browser/ui/autofill/autofill_popup_controller_impl.cc

Issue 492043003: Fill on account select in the password manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-added check that form contains a username field. Created 6 years, 1 month 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 | Annotate | Revision Log
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/ui/autofill/autofill_popup_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 base::Bind(&AutofillPopupControllerImpl::HandleKeyPressEvent, 111 base::Bind(&AutofillPopupControllerImpl::HandleKeyPressEvent,
112 base::Unretained(this))); 112 base::Unretained(this)));
113 #if !defined(OS_ANDROID) 113 #if !defined(OS_ANDROID)
114 subtext_font_list_ = name_font_list_.DeriveWithSizeDelta(kLabelFontSizeDelta); 114 subtext_font_list_ = name_font_list_.DeriveWithSizeDelta(kLabelFontSizeDelta);
115 #if defined(OS_MACOSX) 115 #if defined(OS_MACOSX)
116 // There is no italic version of the system font. 116 // There is no italic version of the system font.
117 warning_font_list_ = name_font_list_; 117 warning_font_list_ = name_font_list_;
118 #else 118 #else
119 warning_font_list_ = name_font_list_.DeriveWithStyle(gfx::Font::ITALIC); 119 warning_font_list_ = name_font_list_.DeriveWithStyle(gfx::Font::ITALIC);
120 #endif 120 #endif
121 title_font_list_ = name_font_list_.DeriveWithStyle(gfx::Font::BOLD);
121 #endif 122 #endif
122 } 123 }
123 124
124 AutofillPopupControllerImpl::~AutofillPopupControllerImpl() {} 125 AutofillPopupControllerImpl::~AutofillPopupControllerImpl() {}
125 126
126 void AutofillPopupControllerImpl::Show( 127 void AutofillPopupControllerImpl::Show(
127 const std::vector<base::string16>& names, 128 const std::vector<base::string16>& names,
128 const std::vector<base::string16>& subtexts, 129 const std::vector<base::string16>& subtexts,
129 const std::vector<base::string16>& icons, 130 const std::vector<base::string16>& icons,
130 const std::vector<int>& identifiers) { 131 const std::vector<int>& identifiers) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 bool AutofillPopupControllerImpl::HandleKeyPressEvent( 254 bool AutofillPopupControllerImpl::HandleKeyPressEvent(
254 const content::NativeWebKeyboardEvent& event) { 255 const content::NativeWebKeyboardEvent& event) {
255 switch (event.windowsKeyCode) { 256 switch (event.windowsKeyCode) {
256 case ui::VKEY_UP: 257 case ui::VKEY_UP:
257 SelectPreviousLine(); 258 SelectPreviousLine();
258 return true; 259 return true;
259 case ui::VKEY_DOWN: 260 case ui::VKEY_DOWN:
260 SelectNextLine(); 261 SelectNextLine();
261 return true; 262 return true;
262 case ui::VKEY_PRIOR: // Page up. 263 case ui::VKEY_PRIOR: // Page up.
263 SetSelectedLine(0); 264 SetSelectedLine(GetFirstSelectableLine());
Garrett Casto 2014/11/23 07:49:48 It might not be possible now, but I would think th
jww 2014/11/25 02:46:26 Done.
264 return true; 265 return true;
265 case ui::VKEY_NEXT: // Page down. 266 case ui::VKEY_NEXT: // Page down.
266 SetSelectedLine(names().size() - 1); 267 SetSelectedLine(names().size() - 1);
267 return true; 268 return true;
268 case ui::VKEY_ESCAPE: 269 case ui::VKEY_ESCAPE:
269 Hide(); 270 Hide();
270 return true; 271 return true;
271 case ui::VKEY_DELETE: 272 case ui::VKEY_DELETE:
272 return (event.modifiers & content::NativeWebKeyboardEvent::ShiftKey) && 273 return (event.modifiers & content::NativeWebKeyboardEvent::ShiftKey) &&
273 RemoveSelectedLine(); 274 RemoveSelectedLine();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 const std::vector<int>& AutofillPopupControllerImpl::identifiers() const { 399 const std::vector<int>& AutofillPopupControllerImpl::identifiers() const {
399 return identifiers_; 400 return identifiers_;
400 } 401 }
401 402
402 #if !defined(OS_ANDROID) 403 #if !defined(OS_ANDROID)
403 const gfx::FontList& AutofillPopupControllerImpl::GetNameFontListForRow( 404 const gfx::FontList& AutofillPopupControllerImpl::GetNameFontListForRow(
404 size_t index) const { 405 size_t index) const {
405 if (identifiers_[index] == POPUP_ITEM_ID_WARNING_MESSAGE) 406 if (identifiers_[index] == POPUP_ITEM_ID_WARNING_MESSAGE)
406 return warning_font_list_; 407 return warning_font_list_;
407 408
409 if (identifiers_[index] == POPUP_ITEM_ID_TITLE)
410 return title_font_list_;
411
408 return name_font_list_; 412 return name_font_list_;
409 } 413 }
410 414
411 const gfx::FontList& AutofillPopupControllerImpl::subtext_font_list() const { 415 const gfx::FontList& AutofillPopupControllerImpl::subtext_font_list() const {
412 return subtext_font_list_; 416 return subtext_font_list_;
413 } 417 }
414 #endif 418 #endif
415 419
416 int AutofillPopupControllerImpl::selected_line() const { 420 int AutofillPopupControllerImpl::selected_line() const {
417 return selected_line_; 421 return selected_line_;
418 } 422 }
419 423
420 void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) { 424 void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) {
421 if (selected_line_ == selected_line) 425 if (selected_line_ == selected_line)
422 return; 426 return;
423 427
428 if (selected_line != kNoSelection && identifiers_.size() > 0 &&
429 identifiers_[selected_line] == POPUP_ITEM_ID_TITLE)
430 return;
431
424 if (selected_line_ != kNoSelection && 432 if (selected_line_ != kNoSelection &&
425 static_cast<size_t>(selected_line_) < identifiers_.size()) 433 static_cast<size_t>(selected_line_) < identifiers_.size())
426 InvalidateRow(selected_line_); 434 InvalidateRow(selected_line_);
427 435
428 if (selected_line != kNoSelection) 436 if (selected_line != kNoSelection)
429 InvalidateRow(selected_line); 437 InvalidateRow(selected_line);
430 438
431 selected_line_ = selected_line; 439 selected_line_ = selected_line;
432 440
433 if (selected_line_ != kNoSelection) { 441 if (selected_line_ != kNoSelection) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } 523 }
516 524
517 int AutofillPopupControllerImpl::GetRowHeightFromId(int identifier) const { 525 int AutofillPopupControllerImpl::GetRowHeightFromId(int identifier) const {
518 if (identifier == POPUP_ITEM_ID_SEPARATOR) 526 if (identifier == POPUP_ITEM_ID_SEPARATOR)
519 return kSeparatorHeight; 527 return kSeparatorHeight;
520 528
521 return kRowHeight; 529 return kRowHeight;
522 } 530 }
523 531
524 bool AutofillPopupControllerImpl::CanAccept(int id) { 532 bool AutofillPopupControllerImpl::CanAccept(int id) {
525 return id != POPUP_ITEM_ID_SEPARATOR && id != POPUP_ITEM_ID_WARNING_MESSAGE; 533 return id != POPUP_ITEM_ID_SEPARATOR && id != POPUP_ITEM_ID_WARNING_MESSAGE &&
534 id != POPUP_ITEM_ID_TITLE;
526 } 535 }
527 536
528 bool AutofillPopupControllerImpl::HasSuggestions() { 537 bool AutofillPopupControllerImpl::HasSuggestions() {
529 return identifiers_.size() != 0 && 538 return identifiers_.size() != 0 &&
530 (identifiers_[0] > 0 || 539 (identifiers_[0] > 0 ||
531 identifiers_[0] == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY || 540 identifiers_[0] == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY ||
532 identifiers_[0] == POPUP_ITEM_ID_PASSWORD_ENTRY || 541 identifiers_[0] == POPUP_ITEM_ID_PASSWORD_ENTRY ||
533 identifiers_[0] == POPUP_ITEM_ID_DATALIST_ENTRY || 542 identifiers_[0] == POPUP_ITEM_ID_DATALIST_ENTRY ||
534 identifiers_[0] == POPUP_ITEM_ID_MAC_ACCESS_CONTACTS); 543 identifiers_[0] == POPUP_ITEM_ID_MAC_ACCESS_CONTACTS);
535 } 544 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 634
626 names_.clear(); 635 names_.clear();
627 subtexts_.clear(); 636 subtexts_.clear();
628 icons_.clear(); 637 icons_.clear();
629 identifiers_.clear(); 638 identifiers_.clear();
630 full_names_.clear(); 639 full_names_.clear();
631 640
632 selected_line_ = kNoSelection; 641 selected_line_ = kNoSelection;
633 } 642 }
634 643
644 int AutofillPopupControllerImpl::GetFirstSelectableLine() {
645 if (identifiers().size() < 1 || identifiers()[0] != POPUP_ITEM_ID_TITLE)
646 return 0;
647
648 return 1;
649 }
650
635 } // namespace autofill 651 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698