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

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

Issue 845693002: [Password Generation] Require full form match to allow generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « chrome/renderer/autofill/password_generation_agent_browsertest.cc ('k') | 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 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/password_generation_agent.h" 5 #include "components/autofill/content/renderer/password_generation_agent.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "components/autofill/content/common/autofill_messages.h" 10 #include "components/autofill/content/common/autofill_messages.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return true; 63 return true;
64 } 64 }
65 65
66 return false; 66 return false;
67 } 67 }
68 68
69 bool ContainsURL(const std::vector<GURL>& urls, const GURL& url) { 69 bool ContainsURL(const std::vector<GURL>& urls, const GURL& url) {
70 return std::find(urls.begin(), urls.end(), url) != urls.end(); 70 return std::find(urls.begin(), urls.end(), url) != urls.end();
71 } 71 }
72 72
73 // Returns true if the |form1| is essentially equal to |form2|.
74 bool FormsAreEqual(const autofill::FormData& form1,
75 const PasswordForm& form2) {
76 // TODO(zysxqn): use more signals than just origin to compare.
77 // Note that FormData strips the fragement from the url while PasswordForm
78 // strips both the fragement and the path, so we can't just compare these
79 // two directly.
80 return form1.origin.GetOrigin() == form2.origin.GetOrigin();
81 }
82
83 bool ContainsForm(const std::vector<autofill::FormData>& forms, 73 bool ContainsForm(const std::vector<autofill::FormData>& forms,
84 const PasswordForm& form) { 74 const PasswordForm& form) {
85 for (std::vector<autofill::FormData>::const_iterator it = 75 for (std::vector<autofill::FormData>::const_iterator it =
86 forms.begin(); it != forms.end(); ++it) { 76 forms.begin(); it != forms.end(); ++it) {
87 if (FormsAreEqual(*it, form)) 77 if (it->SameFormAs(form.form_data))
88 return true; 78 return true;
89 } 79 }
90 return false; 80 return false;
91 } 81 }
92 82
93 void CopyValueToAllInputElements( 83 void CopyValueToAllInputElements(
94 const blink::WebString value, 84 const blink::WebString value,
95 std::vector<blink::WebInputElement>* elements) { 85 std::vector<blink::WebInputElement>* elements) {
96 for (std::vector<blink::WebInputElement>::iterator it = elements->begin(); 86 for (std::vector<blink::WebInputElement>::iterator it = elements->begin();
97 it != elements->end(); ++it) { 87 it != elements->end(); ++it) {
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 *possible_account_creation_form_)); 389 *possible_account_creation_form_));
400 390
401 editing_popup_shown_ = true; 391 editing_popup_shown_ = true;
402 } 392 }
403 393
404 void PasswordGenerationAgent::HidePopup() { 394 void PasswordGenerationAgent::HidePopup() {
405 Send(new AutofillHostMsg_HidePasswordGenerationPopup(routing_id())); 395 Send(new AutofillHostMsg_HidePasswordGenerationPopup(routing_id()));
406 } 396 }
407 397
408 } // namespace autofill 398 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/password_generation_agent_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698