referrer_policy.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2020 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. #ifndef NET_URL_REQUEST_REFERRER_POLICY_H_
  5. #define NET_URL_REQUEST_REFERRER_POLICY_H_
  6. namespace net {
  7. // A ReferrerPolicy controls the contents of the Referer header when URLRequest
  8. // following HTTP redirects. Note that setting a ReferrerPolicy on the request
  9. // has no effect on the Referer header of the initial leg of the request; the
  10. // caller is responsible for setting the initial Referer, and the ReferrerPolicy
  11. // only controls what happens to the Referer while following redirects.
  12. //
  13. // NOTE: This enum is persisted to histograms. Do not change or reorder values.
  14. // TODO(~M89): Once the Net.URLRequest.ReferrerPolicyForRequest metric is
  15. // retired.
  16. enum class ReferrerPolicy {
  17. // Clear the referrer header if the header value is HTTPS but the request
  18. // destination is HTTP. This is the default behavior of URLRequest.
  19. CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE = 0,
  20. // A slight variant on CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE:
  21. // If the request destination is HTTP, an HTTPS referrer will be cleared. If
  22. // the request's destination is cross-origin with the referrer (but does not
  23. // downgrade), the referrer's granularity will be stripped down to an origin
  24. // rather than a full URL. Same-origin requests will send the full referrer.
  25. REDUCE_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN = 1,
  26. // Strip the referrer down to an origin when the origin of the referrer is
  27. // different from the destination's origin.
  28. ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN = 2,
  29. // Never change the referrer.
  30. NEVER_CLEAR = 3,
  31. // Strip the referrer down to the origin regardless of the redirect
  32. // location.
  33. ORIGIN = 4,
  34. // Clear the referrer when the request's referrer is cross-origin with
  35. // the request's destination.
  36. CLEAR_ON_TRANSITION_CROSS_ORIGIN = 5,
  37. // Strip the referrer down to the origin, but clear it entirely if the
  38. // referrer value is HTTPS and the destination is HTTP.
  39. ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE = 6,
  40. // Always clear the referrer regardless of the request destination.
  41. NO_REFERRER = 7,
  42. MAX = NO_REFERRER,
  43. };
  44. } // namespace net
  45. #endif // NET_URL_REQUEST_REFERRER_POLICY_H_