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 5 #ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_LOADER_REFERRER_UTILS_H_ 6 #define THIRD_PARTY_BLINK_PUBLIC_COMMON_LOADER_REFERRER_UTILS_H_ 7 8 #include "base/optional.h" 9 #include "net/url_request/referrer_policy.h" 10 #include "services/network/public/mojom/referrer_policy.mojom-shared.h" 11 #include "third_party/blink/public/common/common_export.h" 12 13 namespace blink { 14 15 class ReferrerUtils { 16 public: 17 static BLINK_COMMON_EXPORT network::mojom::ReferrerPolicy 18 NetToMojoReferrerPolicy(net::ReferrerPolicy net_policy); 19 20 static BLINK_COMMON_EXPORT net::ReferrerPolicy GetDefaultNetReferrerPolicy(); 21 22 // The ReferrerPolicy enum contains a member kDefault, which is not a real 23 // referrer policy, but instead Blink fallbacks to kNoReferrerWhenDowngrade 24 // when a certain condition is met. The function below is provided so that a 25 // referrer policy which may be kDefault can be resolved to a valid value. 26 static BLINK_COMMON_EXPORT network::mojom::ReferrerPolicy 27 MojoReferrerPolicyResolveDefault(network::mojom::ReferrerPolicy); 28 29 // Configures retaining the pre-M80 default referrer 30 // policy of no-referrer-when-downgrade. 31 // TODO(crbug.com/1016541): After M88, remove when the corresponding 32 // enterprise policy has been deleted. 33 static BLINK_COMMON_EXPORT void SetForceLegacyDefaultReferrerPolicy( 34 bool force); 35 static BLINK_COMMON_EXPORT bool ShouldForceLegacyDefaultReferrerPolicy(); 36 37 static BLINK_COMMON_EXPORT bool IsReducedReferrerGranularityEnabled(); 38 }; 39 40 } // namespace blink 41 42 #endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_LOADER_REFERRER_UTILS_H_ 43