blob: 4130d7b02a6a4441eeb9cf38b20121205206a574 [file] [log] [blame]
// Copyright 2017 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 <map>
#include <memory>
#include <string>
#include <vector>
namespace autofill {
struct PasswordForm;
namespace password_manager {
// Multimap from sort key to password forms.
using DuplicatesMap =
std::multimap<std::string, std::unique_ptr<autofill::PasswordForm>>;
// Creates key for sorting password or password exception entries. The key is
// eTLD+1 followed by the reversed list of domains (e.g.
// => and
// the scheme. If |form| is not blacklisted, username, password and federation
// are appended to the key. If not, no further information is added. For Android
// credentials the canocial spec is included.
std::string CreateSortKey(const autofill::PasswordForm& form);
// Sort entries of |list| based on sort key. The key is the concatenation of
// origin, entry type (non-Android credential, Android w/ affiliated web realm
// or Android w/o affiliated web realm). If a form in |list| is not blacklisted,
// username, password and federation are also included in sort key. If there are
// several forms with the same key, all such forms but the first one are stored
// in |duplicates| instead of |list|.
void SortEntriesAndHideDuplicates(
std::vector<std::unique_ptr<autofill::PasswordForm>>* list,
DuplicatesMap* duplicates);
} // namespace password_manager