| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |