referrer_util.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. #ifndef IOS_WEB_COMMON_REFERRER_UTIL_H_
  5. #define IOS_WEB_COMMON_REFERRER_UTIL_H_
  6. #include <string>
  7. #include "ios/web/public/navigation/referrer.h"
  8. #include "net/url_request/referrer_policy.h"
  9. class GURL;
  10. namespace web {
  11. // Returns the string that should be sent as the Referer header value for
  12. // navigating to |destination| from the given referrer, taking the referrer
  13. // policy into account. Returns an empty string if no Referer should be sent.
  14. std::string ReferrerHeaderValueForNavigation(const GURL& destination,
  15. const web::Referrer& referrer);
  16. // Returns the policy that should be used to process subsequent forwards, if
  17. // any.
  18. // TODO(stuartmorgan): Replace this with ReferrerForNavigation, since it should
  19. // always be used with ReferrerHeaderValueForNavigation anyway.
  20. net::ReferrerPolicy PolicyForNavigation(const GURL& destination,
  21. const web::Referrer& referrer);
  22. // Returns the WebReferrerPolicy corresponding to the given policy string
  23. // (e.g., 'always', 'never', 'origin', 'default'). The string is assumed to
  24. // be lowercase already. Unrecognized values will be treated as Default.
  25. ReferrerPolicy ReferrerPolicyFromString(const std::string& policy);
  26. } // namespace web
  27. #endif // IOS_WEB_COMMON_REFERRER_UTIL_H_