Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / sessions / core / serialized_navigation_driver.h
blobce02ec3b3ba4d7b72aefaf2dbb18ce379830e721
1 // Copyright 2014 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 COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_
6 #define COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_
8 #include <string>
10 #include "components/sessions/sessions_export.h"
12 namespace sessions {
14 class SerializedNavigationEntry;
16 // The SerializedNavigationDriver interface allows SerializedNavigationEntry to
17 // obtain information from a singleton driver object. A concrete implementation
18 // must be provided by the driver on each platform.
19 class SESSIONS_EXPORT_PRIVATE SerializedNavigationDriver {
20 public:
21 virtual ~SerializedNavigationDriver() {}
23 // Returns the singleton SerializedNavigationDriver.
24 static SerializedNavigationDriver* Get();
26 // Returns the default referrer policy.
27 virtual int GetDefaultReferrerPolicy() const = 0;
29 // Maps current referrer policies to old values to work around
30 // crbug.com/450589. Returns false if the referrer should be stripped.
31 virtual bool MapReferrerPolicyToOldValues(
32 int referrer_policy,
33 int* mapped_referrer_policy) const = 0;
35 // Sanitizes a referrer policy that might either be in the old or the new
36 // format. Returns false if the referrer should be stripped.
37 virtual bool MapReferrerPolicyToNewValues(
38 int referrer_policy,
39 int* mapped_referrer_policy) const = 0;
41 // Returns a sanitized version of the given |navigation|'s encoded_page_state
42 // suitable for writing to disk.
43 virtual std::string GetSanitizedPageStateForPickle(
44 const SerializedNavigationEntry* navigation) const = 0;
46 // Sanitizes the data in the given |navigation| to be more robust against
47 // faulty data written by older versions.
48 virtual void Sanitize(SerializedNavigationEntry* navigation) const = 0;
50 // Removes the referrer from the encoded page state.
51 virtual std::string StripReferrerFromPageState(
52 const std::string& page_state) const = 0;
55 } // namespace sessions
57 #endif // COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_