Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / password_manager / psl_matching_helper.h
blob1512dd61d112ccd0dc05cfa721b65f01a2124fe6
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.
5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PSL_MATCHING_HELPER_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PSL_MATCHING_HELPER_H_
8 #include <string>
10 #include "base/basictypes.h"
12 class GURL;
14 namespace autofill {
15 struct PasswordForm;
16 } // namespace autofill
18 class PSLMatchingHelper {
19 public:
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.
23 enum PSLDomainMatchMetric {
24 PSL_DOMAIN_MATCH_DISABLED = 0,
25 PSL_DOMAIN_MATCH_NONE,
26 PSL_DOMAIN_MATCH_FOUND,
27 PSL_DOMAIN_MATCH_COUNT
30 PSLMatchingHelper();
31 ~PSLMatchingHelper();
33 bool IsMatchingEnabled() const;
35 // Using the public suffix list for matching the origin is only needed for
36 // websites that do not have a single hostname for entering credentials. It
37 // would be better for their users if they did, but until then we help them
38 // find
39 // credentials across different hostnames. We know that accounts.google.com is
40 // the only hostname we should be accepting credentials on for any domain
41 // under
42 // google.com, so we can apply a tighter policy for that domain.
43 // For owners of domains where a single hostname is always used when your
44 // users are entering their credentials, please contact palmer@chromium.org,
45 // nyquist@chromium.org or file a bug at http://crbug.com/ to be added here.
46 bool ShouldPSLDomainMatchingApply(
47 const std::string& registry_controlled_domain) const;
49 // Two URLs are considered a Public Suffix Domain match if they have the same
50 // scheme, ports, and their registry controlled domains are equal.
51 static bool IsPublicSuffixDomainMatch(const std::string& url1,
52 const std::string& url2);
54 // Two hosts are considered to belong to the same website when they share the
55 // registry-controlled domain part.
56 static std::string GetRegistryControlledDomain(const GURL& signon_realm);
58 // This overrides both the command line flags and platform restrictions. This
59 // function is not thread safe, and should be called before any other methods
60 // of |PSLMatchingHelper| are called.
61 static void EnablePublicSuffixDomainMatchingForTesting();
63 private:
64 static bool DeterminePSLEnabled();
66 const bool psl_enabled_;
68 // Default is false, once set to true, overrides |psl_enabled_|.
69 static bool psl_enabled_override_;
71 DISALLOW_COPY_AND_ASSIGN(PSLMatchingHelper);
74 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PSL_MATCHING_HELPER_H_