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 3// found in the LICENSE file. 4 5#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PSL_MATCHING_HELPER_H_ 6#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PSL_MATCHING_HELPER_H_ 7 8#include <string> 9 10#include "base/basictypes.h" 11 12class GURL; 13 14namespace autofill { 15struct PasswordForm; 16} // namespace autofill 17 18namespace password_manager { 19 20// Enum used for histogram tracking PSL Domain triggering. 21// New entries should only be added to the end of the enum (before *_COUNT) so 22// as to not disrupt existing data. 23enum PSLDomainMatchMetric { 24 PSL_DOMAIN_MATCH_NOT_USED = 0, 25 PSL_DOMAIN_MATCH_NONE, 26 PSL_DOMAIN_MATCH_FOUND, 27 PSL_DOMAIN_MATCH_COUNT 28}; 29 30// Using the public suffix list for matching the origin is only needed for 31// websites that do not have a single hostname for entering credentials. It 32// would be better for their users if they did, but until then we help them find 33// credentials across different hostnames. We know that accounts.google.com is 34// the only hostname we should be accepting credentials on for any domain under 35// google.com, so we can apply a tighter policy for that domain. For owners of 36// domains where a single hostname is always used when your users are entering 37// their credentials, please contact palmer@chromium.org, nyquist@chromium.org 38// or file a bug at http://crbug.com/ to be added here. 39bool ShouldPSLDomainMatchingApply( 40 const std::string& registry_controlled_domain); 41 42// Two URLs are considered a Public Suffix Domain match if they have the same 43// scheme, ports, and their registry controlled domains are equal. If one or 44// both arguments do not describe valid URLs, returns false. 45bool IsPublicSuffixDomainMatch(const std::string& url1, 46 const std::string& url2); 47 48// Two hosts are considered to belong to the same website when they share the 49// registry-controlled domain part. 50std::string GetRegistryControlledDomain(const GURL& signon_realm); 51 52} // namespace password_manager 53 54#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PSL_MATCHING_HELPER_H_ 55