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

Side by Side Diff: chrome/renderer/autofill_helper.cc

Issue 5263007: Should not show autofill drop-down for a user/pw form (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/renderer/autofill_helper.h" 5 #include "chrome/renderer/autofill_helper.h"
6 6
7 #include "app/keyboard_codes.h" 7 #include "app/keyboard_codes.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/common/chrome_constants.h" 10 #include "chrome/common/chrome_constants.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 v.erase(v.begin()); 85 v.erase(v.begin());
86 l.erase(l.begin()); 86 l.erase(l.begin());
87 i.erase(i.begin()); 87 i.erase(i.begin());
88 ids.erase(ids.begin()); 88 ids.erase(ids.begin());
89 } 89 }
90 90
91 // If we were about to show a warning and we shouldn't, don't. 91 // If we were about to show a warning and we shouldn't, don't.
92 if (ids[0] < 0 && !display_warning_if_disabled_) 92 if (ids[0] < 0 && !display_warning_if_disabled_)
93 return; 93 return;
94 94
95 // Only include "AutoFill Options" special menu item if we have AutoFill
96 // items, identified by |unique_ids| having at least one valid value.
97 bool has_autofill_item = false;
98 for (size_t i = 0; i < ids.size(); ++i) {
99 if (ids[i] > 0) {
100 has_autofill_item = true;
101 break;
102 }
103 }
104
95 // The form has been auto-filled, so give the user the chance to clear the 105 // The form has been auto-filled, so give the user the chance to clear the
96 // form. Append the 'Clear form' menu item. 106 // form. Append the 'Clear form' menu item.
97 if (form_manager_.FormWithNodeIsAutoFilled(autofill_query_node_)) { 107 if (has_autofill_item &&
108 form_manager_.FormWithNodeIsAutoFilled(autofill_query_node_)) {
98 v.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM)); 109 v.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM));
99 l.push_back(string16()); 110 l.push_back(string16());
100 i.push_back(string16()); 111 i.push_back(string16());
101 ids.push_back(0); 112 ids.push_back(0);
102 suggestions_clear_index_ = v.size() - 1; 113 suggestions_clear_index_ = v.size() - 1;
103 separator_index = v.size() - 1; 114 separator_index = v.size() - 1;
104 } 115 }
105 116
106 // Only include "AutoFill Options" special menu item if we have AutoFill 117 if (has_autofill_item) {
107 // items, identified by |unique_ids| having at least one valid value.
108 bool show_options = false;
109 for (size_t i = 0; i < ids.size(); ++i) {
110 if (ids[i] > 0) {
111 show_options = true;
112 break;
113 }
114 }
115 if (show_options) {
116 // Append the 'Chrome Autofill options' menu item; 118 // Append the 'Chrome Autofill options' menu item;
117 v.push_back(l10n_util::GetStringFUTF16(IDS_AUTOFILL_OPTIONS_POPUP, 119 v.push_back(l10n_util::GetStringFUTF16(IDS_AUTOFILL_OPTIONS_POPUP,
118 WideToUTF16(chrome::kBrowserAppName))); 120 WideToUTF16(chrome::kBrowserAppName)));
119 l.push_back(string16()); 121 l.push_back(string16());
120 i.push_back(string16()); 122 i.push_back(string16());
121 ids.push_back(0); 123 ids.push_back(0);
122 suggestions_options_index_ = v.size() - 1; 124 suggestions_options_index_ = v.size() - 1;
123 separator_index = values.size(); 125 separator_index = values.size();
124 } 126 }
125 127
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 field); 332 field);
331 333
332 // WebFormControlElementToFormField does not scrape the DOM for the field 334 // WebFormControlElementToFormField does not scrape the DOM for the field
333 // label, so find the label here. 335 // label, so find the label here.
334 // TODO(jhawkins): Add form and field identities so we can use the cached form 336 // TODO(jhawkins): Add form and field identities so we can use the cached form
335 // data in FormManager. 337 // data in FormManager.
336 field->set_label(FormManager::LabelForElement(element)); 338 field->set_label(FormManager::LabelForElement(element));
337 339
338 return true; 340 return true;
339 } 341 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698