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

Side by Side Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 1184913002: [Password Manager] Suppress UI when password generation is active (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Second try Created 5 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/content/renderer/autofill_agent.h" 5 #include "components/autofill/content/renderer/autofill_agent.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 : content::RenderFrameObserver(render_frame), 149 : content::RenderFrameObserver(render_frame),
150 form_cache_(*render_frame->GetWebFrame()), 150 form_cache_(*render_frame->GetWebFrame()),
151 password_autofill_agent_(password_autofill_agent), 151 password_autofill_agent_(password_autofill_agent),
152 password_generation_agent_(password_generation_agent), 152 password_generation_agent_(password_generation_agent),
153 legacy_(render_frame->GetRenderView(), this), 153 legacy_(render_frame->GetRenderView(), this),
154 autofill_query_id_(0), 154 autofill_query_id_(0),
155 was_query_node_autofilled_(false), 155 was_query_node_autofilled_(false),
156 has_shown_autofill_popup_for_current_edit_(false), 156 has_shown_autofill_popup_for_current_edit_(false),
157 ignore_text_changes_(false), 157 ignore_text_changes_(false),
158 is_popup_possibly_visible_(false), 158 is_popup_possibly_visible_(false),
159 is_generation_popup_possibly_visible_(false),
159 weak_ptr_factory_(this) { 160 weak_ptr_factory_(this) {
160 render_frame->GetWebFrame()->setAutofillClient(this); 161 render_frame->GetWebFrame()->setAutofillClient(this);
161 162
162 // This owns itself, and will delete itself when |render_frame| is destructed 163 // This owns itself, and will delete itself when |render_frame| is destructed
163 // (same as AutofillAgent). 164 // (same as AutofillAgent). This object must be constructed after
165 // AutofillAgent so that password generation UI is shown before password
166 // manager UI (see https://crbug.com/498545).
164 new PageClickTracker(render_frame, this); 167 new PageClickTracker(render_frame, this);
165 } 168 }
166 169
167 AutofillAgent::~AutofillAgent() {} 170 AutofillAgent::~AutofillAgent() {}
168 171
169 bool AutofillAgent::FormDataCompare::operator()(const FormData& lhs, 172 bool AutofillAgent::FormDataCompare::operator()(const FormData& lhs,
170 const FormData& rhs) const { 173 const FormData& rhs) const {
171 if (lhs.name != rhs.name) 174 if (lhs.name != rhs.name)
172 return lhs.name < rhs.name; 175 return lhs.name < rhs.name;
173 if (lhs.origin != rhs.origin) 176 if (lhs.origin != rhs.origin)
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 276 }
274 277
275 void AutofillAgent::FocusChangeComplete() { 278 void AutofillAgent::FocusChangeComplete() {
276 WebDocument doc = render_frame()->GetWebFrame()->document(); 279 WebDocument doc = render_frame()->GetWebFrame()->document();
277 WebElement focused_element; 280 WebElement focused_element;
278 if (!doc.isNull()) 281 if (!doc.isNull())
279 focused_element = doc.focusedElement(); 282 focused_element = doc.focusedElement();
280 283
281 if (!focused_element.isNull() && password_generation_agent_ && 284 if (!focused_element.isNull() && password_generation_agent_ &&
282 password_generation_agent_->FocusedNodeHasChanged(focused_element)) { 285 password_generation_agent_->FocusedNodeHasChanged(focused_element)) {
286 is_generation_popup_possibly_visible_ = true;
283 is_popup_possibly_visible_ = true; 287 is_popup_possibly_visible_ = true;
284 } 288 }
285 } 289 }
286 290
287 void AutofillAgent::didRequestAutocomplete( 291 void AutofillAgent::didRequestAutocomplete(
288 const WebFormElement& form) { 292 const WebFormElement& form) {
289 DCHECK_EQ(form.document().frame(), render_frame()->GetWebFrame()); 293 DCHECK_EQ(form.document().frame(), render_frame()->GetWebFrame());
290 294
291 // Disallow the dialog over non-https or broken https, except when the 295 // Disallow the dialog over non-https or broken https, except when the
292 // ignore SSL flag is passed. See http://crbug.com/272512. 296 // ignore SSL flag is passed. See http://crbug.com/272512.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 const WebFormControlElement& element, 349 const WebFormControlElement& element,
346 bool was_focused) { 350 bool was_focused) {
347 // TODO(estade): Remove this check when PageClickTracker is per-frame. 351 // TODO(estade): Remove this check when PageClickTracker is per-frame.
348 if (element.document().frame() != render_frame()->GetWebFrame()) 352 if (element.document().frame() != render_frame()->GetWebFrame())
349 return; 353 return;
350 354
351 const WebInputElement* input_element = toWebInputElement(&element); 355 const WebInputElement* input_element = toWebInputElement(&element);
352 if (!input_element && !IsTextAreaElement(element)) 356 if (!input_element && !IsTextAreaElement(element))
353 return; 357 return;
354 358
359 if (is_generation_popup_possibly_visible_)
360 return;
361
355 ShowSuggestionsOptions options; 362 ShowSuggestionsOptions options;
356 options.autofill_on_empty_values = true; 363 options.autofill_on_empty_values = true;
357 options.show_full_suggestion_list = element.isAutofilled(); 364 options.show_full_suggestion_list = element.isAutofilled();
358 365
359 // On Android, default to showing the dropdown on field focus. 366 // On Android, default to showing the dropdown on field focus.
360 // On desktop, require an extra click after field focus. 367 // On desktop, require an extra click after field focus.
361 // See http://crbug.com/427660 368 // See http://crbug.com/427660
362 #if defined(OS_ANDROID) 369 #if defined(OS_ANDROID)
363 bool single_click_autofill = 370 bool single_click_autofill =
364 !base::CommandLine::ForCurrentProcess()->HasSwitch( 371 !base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 (options.requires_caret_at_end && 657 (options.requires_caret_at_end &&
651 (element.selectionStart() != element.selectionEnd() || 658 (element.selectionStart() != element.selectionEnd() ||
652 element.selectionEnd() != static_cast<int>(value.length()))))) { 659 element.selectionEnd() != static_cast<int>(value.length()))))) {
653 // Any popup currently showing is obsolete. 660 // Any popup currently showing is obsolete.
654 HidePopup(); 661 HidePopup();
655 return; 662 return;
656 } 663 }
657 664
658 element_ = element; 665 element_ = element;
659 if (IsAutofillableInputElement(input_element) && 666 if (IsAutofillableInputElement(input_element) &&
660 (password_autofill_agent_->ShowSuggestions( 667 password_autofill_agent_->ShowSuggestions(
661 *input_element, options.show_full_suggestion_list) || 668 *input_element, options.show_full_suggestion_list)) {
662 options.show_password_suggestions_only)) {
663 is_popup_possibly_visible_ = true; 669 is_popup_possibly_visible_ = true;
664 return; 670 return;
665 } 671 }
666 672
673 if (options.show_password_suggestions_only)
674 return;
Ilya Sherman 2015/06/16 02:24:09 This is a small bugfix that's otherwise unrelated
Garrett Casto 2015/06/16 06:15:04 Yes. My original intent was to not introduce a new
675
667 // Password field elements should only have suggestions shown by the password 676 // Password field elements should only have suggestions shown by the password
668 // autofill agent. 677 // autofill agent.
669 if (input_element && input_element->isPasswordField()) 678 if (input_element && input_element->isPasswordField())
670 return; 679 return;
671 680
672 QueryAutofillSuggestions(element, options.datalist_only); 681 QueryAutofillSuggestions(element, options.datalist_only);
673 } 682 }
674 683
675 void AutofillAgent::QueryAutofillSuggestions( 684 void AutofillAgent::QueryAutofillSuggestions(
676 const WebFormControlElement& element, 685 const WebFormControlElement& element,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 if (!forms.empty() || !frame->parent()) { 755 if (!forms.empty() || !frame->parent()) {
747 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, 756 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms,
748 forms_seen_timestamp)); 757 forms_seen_timestamp));
749 } 758 }
750 } 759 }
751 760
752 void AutofillAgent::HidePopup() { 761 void AutofillAgent::HidePopup() {
753 if (!is_popup_possibly_visible_) 762 if (!is_popup_possibly_visible_)
754 return; 763 return;
755 is_popup_possibly_visible_ = false; 764 is_popup_possibly_visible_ = false;
765 is_generation_popup_possibly_visible_ = false;
756 Send(new AutofillHostMsg_HidePopup(routing_id())); 766 Send(new AutofillHostMsg_HidePopup(routing_id()));
757 } 767 }
758 768
759 bool AutofillAgent::IsUserGesture() const { 769 bool AutofillAgent::IsUserGesture() const {
760 return WebUserGestureIndicator::isProcessingUserGesture(); 770 return WebUserGestureIndicator::isProcessingUserGesture();
761 } 771 }
762 772
763 void AutofillAgent::didAssociateFormControls(const WebVector<WebNode>& nodes) { 773 void AutofillAgent::didAssociateFormControls(const WebVector<WebNode>& nodes) {
764 for (size_t i = 0; i < nodes.size(); ++i) { 774 for (size_t i = 0; i < nodes.size(); ++i) {
765 WebLocalFrame* frame = nodes[i].document().frame(); 775 WebLocalFrame* frame = nodes[i].document().frame();
(...skipping 28 matching lines...) Expand all
794 804
795 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { 805 void AutofillAgent::LegacyAutofillAgent::OnDestruct() {
796 // No-op. Don't delete |this|. 806 // No-op. Don't delete |this|.
797 } 807 }
798 808
799 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { 809 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() {
800 agent_->FocusChangeComplete(); 810 agent_->FocusChangeComplete();
801 } 811 }
802 812
803 } // namespace autofill 813 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698