Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: components/sessions/core/serialized_navigation_driver.h

Issue 2759333002: Move chrome-specific SerializedNavigation code to chrome/. (Closed)
Patch Set: Rebase, fix Android? Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_ 5 #ifndef COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_
6 #define COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_ 6 #define COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h"
10 #include "components/sessions/core/sessions_export.h" 11 #include "components/sessions/core/sessions_export.h"
11 12
12 namespace sessions { 13 namespace sessions {
13 14
14 class SerializedNavigationEntry; 15 class SerializedNavigationEntry;
15 16
16 // The SerializedNavigationDriver interface allows SerializedNavigationEntry to 17 // The SerializedNavigationDriver interface allows SerializedNavigationEntry to
17 // obtain information from a singleton driver object. A concrete implementation 18 // obtain information from a singleton driver object. A concrete implementation
18 // must be provided by the driver on each platform. 19 // must be provided by the driver on each platform.
19 class SESSIONS_EXPORT SerializedNavigationDriver { 20 class SESSIONS_EXPORT SerializedNavigationDriver {
20 public: 21 public:
21 virtual ~SerializedNavigationDriver() {} 22 using SanitizeCallback = base::Callback<void(SerializedNavigationEntry*)>;
sky 2017/03/21 14:47:39 This seems like a roundabout way of overriding San
Lei Zhang 2017/03/21 17:12:51 Wouldn't I need to move SerializedNavigationDriver
sky 2017/03/21 17:50:59 Good point. How about having setters that content
22 23
23 // Returns the singleton SerializedNavigationDriver. 24 // Returns the singleton SerializedNavigationDriver.
24 static SerializedNavigationDriver* Get(); 25 static SerializedNavigationDriver* Get();
25 26
27 // Sets the callback to use for Sanitize().
28 static void SetSanitizeCallback(const SanitizeCallback& callback);
29
26 // Returns the default referrer policy. 30 // Returns the default referrer policy.
27 virtual int GetDefaultReferrerPolicy() const = 0; 31 virtual int GetDefaultReferrerPolicy() const = 0;
28 32
29 // Maps current referrer policies to old values to work around 33 // Maps current referrer policies to old values to work around
30 // crbug.com/450589. Returns false if the referrer should be stripped. 34 // crbug.com/450589. Returns false if the referrer should be stripped.
31 virtual bool MapReferrerPolicyToOldValues( 35 virtual bool MapReferrerPolicyToOldValues(
32 int referrer_policy, 36 int referrer_policy,
33 int* mapped_referrer_policy) const = 0; 37 int* mapped_referrer_policy) const = 0;
34 38
35 // Sanitizes a referrer policy that might either be in the old or the new 39 // Sanitizes a referrer policy that might either be in the old or the new
36 // format. Returns false if the referrer should be stripped. 40 // format. Returns false if the referrer should be stripped.
37 virtual bool MapReferrerPolicyToNewValues( 41 virtual bool MapReferrerPolicyToNewValues(
38 int referrer_policy, 42 int referrer_policy,
39 int* mapped_referrer_policy) const = 0; 43 int* mapped_referrer_policy) const = 0;
40 44
41 // Returns a sanitized version of the given |navigation|'s encoded_page_state 45 // Returns a sanitized version of the given |navigation|'s encoded_page_state
42 // suitable for writing to disk. 46 // suitable for writing to disk.
43 virtual std::string GetSanitizedPageStateForPickle( 47 virtual std::string GetSanitizedPageStateForPickle(
44 const SerializedNavigationEntry* navigation) const = 0; 48 const SerializedNavigationEntry* navigation) const = 0;
45 49
46 // Sanitizes the data in the given |navigation| to be more robust against 50 // Sanitizes the data in the given |navigation| to be more robust against
47 // faulty data written by older versions. 51 // faulty data written by older versions.
48 virtual void Sanitize(SerializedNavigationEntry* navigation) const = 0; 52 virtual void Sanitize(SerializedNavigationEntry* navigation) const = 0;
49 53
50 // Removes the referrer from the encoded page state. 54 // Removes the referrer from the encoded page state.
51 virtual std::string StripReferrerFromPageState( 55 virtual std::string StripReferrerFromPageState(
52 const std::string& page_state) const = 0; 56 const std::string& page_state) const = 0;
57
58 protected:
59 virtual ~SerializedNavigationDriver() {}
53 }; 60 };
54 61
55 } // namespace sessions 62 } // namespace sessions
56 63
57 #endif // COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_ 64 #endif // COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698