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

Unified 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: Rebase on ToT Created 6 years, 2 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/ui/autofill/autofill_popup_controller_impl.cc
diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc
index 72e6c2b13c7e0e5130b93fa8cd6b2cd77fb03810..e8561a6cc89b8a478db16e01fa4291a31863797f 100644
--- a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc
@@ -118,6 +118,7 @@ AutofillPopupControllerImpl::AutofillPopupControllerImpl(
#else
warning_font_list_ = name_font_list_.DeriveWithStyle(gfx::Font::ITALIC);
#endif
+ title_font_list_ = name_font_list_.DeriveWithStyle(gfx::Font::BOLD);
#endif
}
@@ -127,8 +128,9 @@ void AutofillPopupControllerImpl::Show(
const std::vector<base::string16>& names,
const std::vector<base::string16>& subtexts,
const std::vector<base::string16>& icons,
- const std::vector<int>& identifiers) {
- SetValues(names, subtexts, icons, identifiers);
+ const std::vector<int>& identifiers,
+ const base::string16& title) {
Garrett Casto 2014/11/04 23:35:30 Given the way that this works for other labels, it
jww 2014/11/06 21:28:56 Done.
+ SetValues(names, subtexts, icons, identifiers, title);
#if !defined(OS_ANDROID)
// Android displays the long text with ellipsis using the view attributes.
@@ -260,7 +262,7 @@ bool AutofillPopupControllerImpl::HandleKeyPressEvent(
SelectNextLine();
return true;
case ui::VKEY_PRIOR: // Page up.
- SetSelectedLine(0);
+ SetSelectedLine(GetFirstSelectableLine());
return true;
case ui::VKEY_NEXT: // Page down.
SetSelectedLine(names().size() - 1);
@@ -405,6 +407,9 @@ const gfx::FontList& AutofillPopupControllerImpl::GetNameFontListForRow(
if (identifiers_[index] == POPUP_ITEM_ID_WARNING_MESSAGE)
return warning_font_list_;
+ if (identifiers_[index] == POPUP_ITEM_ID_TITLE)
+ return title_font_list_;
+
return name_font_list_;
}
@@ -421,6 +426,10 @@ void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) {
if (selected_line_ == selected_line)
return;
+ if (selected_line != kNoSelection && identifiers_.size() > 0 &&
+ identifiers_[selected_line] == POPUP_ITEM_ID_TITLE)
+ return;
+
if (selected_line_ != kNoSelection &&
static_cast<size_t>(selected_line_) < identifiers_.size())
InvalidateRow(selected_line_);
@@ -522,7 +531,8 @@ int AutofillPopupControllerImpl::GetRowHeightFromId(int identifier) const {
}
bool AutofillPopupControllerImpl::CanAccept(int id) {
- return id != POPUP_ITEM_ID_SEPARATOR && id != POPUP_ITEM_ID_WARNING_MESSAGE;
+ return id != POPUP_ITEM_ID_SEPARATOR && id != POPUP_ITEM_ID_WARNING_MESSAGE &&
+ id != POPUP_ITEM_ID_TITLE;
}
bool AutofillPopupControllerImpl::HasSuggestions() {
@@ -538,12 +548,21 @@ void AutofillPopupControllerImpl::SetValues(
const std::vector<base::string16>& names,
const std::vector<base::string16>& subtexts,
const std::vector<base::string16>& icons,
- const std::vector<int>& identifiers) {
+ const std::vector<int>& identifiers,
+ const base::string16& title) {
names_ = names;
full_names_ = names;
subtexts_ = subtexts;
icons_ = icons;
identifiers_ = identifiers;
+
+ if (!title.empty()) {
+ names_.insert(names_.begin(), title);
+ full_names_.insert(full_names_.begin(), title);
+ subtexts_.insert(subtexts_.begin(), base::string16());
+ icons_.insert(icons_.begin(), base::string16());
+ identifiers_.insert(identifiers_.begin(), POPUP_ITEM_ID_TITLE);
+ }
}
void AutofillPopupControllerImpl::ShowView() {
@@ -632,4 +651,11 @@ void AutofillPopupControllerImpl::ClearState() {
selected_line_ = kNoSelection;
}
+int AutofillPopupControllerImpl::GetFirstSelectableLine() {
+ if (identifiers().size() < 1 || identifiers()[0] != POPUP_ITEM_ID_TITLE)
+ return 0;
+
+ return 1;
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698