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

Unified Diff: components/password_manager/core/browser/password_form_data.cc

Issue 896903003: [PasswordManager clean-up] Merge copies of CreatePasswordFormFromData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@451018_more_scoped_vector
Patch Set: Rebased again Created 5 years, 10 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: components/password_manager/core/browser/password_form_data.cc
diff --git a/components/password_manager/core/browser/password_form_data.cc b/components/password_manager/core/browser/password_form_data.cc
deleted file mode 100644
index a53328eb2748be16ba08cdaba4444924aab8e410..0000000000000000000000000000000000000000
--- a/components/password_manager/core/browser/password_form_data.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "components/password_manager/core/browser/password_form_data.h"
-
-using autofill::PasswordForm;
-
-namespace password_manager {
-
-scoped_ptr<PasswordForm> CreatePasswordFormFromData(
- const PasswordFormData& form_data) {
- scoped_ptr<PasswordForm> form(new PasswordForm());
- form->scheme = form_data.scheme;
- form->preferred = form_data.preferred;
- form->ssl_valid = form_data.ssl_valid;
- form->date_created = base::Time::FromDoubleT(form_data.creation_time);
- if (form_data.signon_realm)
- form->signon_realm = std::string(form_data.signon_realm);
- if (form_data.origin)
- form->origin = GURL(form_data.origin);
- if (form_data.action)
- form->action = GURL(form_data.action);
- if (form_data.submit_element)
- form->submit_element = base::WideToUTF16(form_data.submit_element);
- if (form_data.username_element)
- form->username_element = base::WideToUTF16(form_data.username_element);
- if (form_data.password_element)
- form->password_element = base::WideToUTF16(form_data.password_element);
- if (form_data.username_value) {
- form->username_value = base::WideToUTF16(form_data.username_value);
- if (form_data.password_value)
- form->password_value = base::WideToUTF16(form_data.password_value);
- } else {
- form->blacklisted_by_user = true;
- }
- return form.Pass();
-}
-
-typedef std::set<const autofill::PasswordForm*> SetOfForms;
-
-bool ContainsSamePasswordFormsPtr(const std::vector<PasswordForm*>& first,
- const std::vector<PasswordForm*>& second) {
- if (first.size() != second.size())
- return false;
-
- // TODO(cramya): As per b/7079906, the STLport of Android causes a crash
- // if we use expectations(first.begin(), first.end()) to copy a vector
- // into a set rather than std::copy that is used below.
- // Need to revert this once STLport is fixed.
- SetOfForms expectations;
- std::copy(first.begin(), first.end(),
- std::inserter(expectations, expectations.begin()));
- for (unsigned int i = 0; i < second.size(); ++i) {
- const PasswordForm* actual = second[i];
- bool found_match = false;
- for (SetOfForms::iterator it = expectations.begin();
- it != expectations.end(); ++it) {
- const PasswordForm* expected = *it;
- if (*expected == *actual) {
- found_match = true;
- expectations.erase(it);
- break;
- }
- }
- if (!found_match) {
- LOG(ERROR) << "No match for:" << std::endl << *actual;
- return false;
- }
- }
- return true;
-}
-
-} // namespace password_manager

Powered by Google App Engine
This is Rietveld 408576698