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

Side by Side Diff: components/sessions/content/content_serialized_navigation_driver.h

Issue 2759333002: Move chrome-specific SerializedNavigation code to chrome/. (Closed)
Patch Set: 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_CONTENT_CONTENT_SERIALIZED_NAVIGATION_DRIVER_H_ 5 #ifndef COMPONENTS_SESSIONS_CONTENT_CONTENT_SERIALIZED_NAVIGATION_DRIVER_H_
6 #define COMPONENTS_SESSIONS_CONTENT_CONTENT_SERIALIZED_NAVIGATION_DRIVER_H_ 6 #define COMPONENTS_SESSIONS_CONTENT_CONTENT_SERIALIZED_NAVIGATION_DRIVER_H_
7 7
8 #include "components/sessions/core/serialized_navigation_driver.h"
9
10 #include <map> 8 #include <map>
11 #include <memory> 9 #include <memory>
12 #include <string> 10 #include <string>
13 11
14 #include "base/macros.h" 12 #include "base/macros.h"
15 #include "components/sessions/content/extended_info_handler.h" 13 #include "components/sessions/content/extended_info_handler.h"
14 #include "components/sessions/core/serialized_navigation_driver.h"
16 #include "components/sessions/core/sessions_export.h" 15 #include "components/sessions/core/sessions_export.h"
17 16
18 namespace base { 17 namespace base {
19 template <typename T> struct DefaultSingletonTraits; 18 template <typename T> struct DefaultSingletonTraits;
20 } 19 }
21 20
22 namespace sessions { 21 namespace sessions {
23 22
24 // Provides an implementation of SerializedNavigationDriver that is backed by 23 // Provides an implementation of SerializedNavigationDriver that is backed by
25 // content classes. 24 // content classes.
26 class SESSIONS_EXPORT ContentSerializedNavigationDriver 25 class SESSIONS_EXPORT ContentSerializedNavigationDriver
27 : public SerializedNavigationDriver { 26 : public SerializedNavigationDriver {
28 public: 27 public:
29 ~ContentSerializedNavigationDriver() override; 28 ~ContentSerializedNavigationDriver() override;
30 29
31 // Returns the singleton ContentSerializedNavigationDriver. Almost all 30 // Returns the singleton ContentSerializedNavigationDriver. Almost all
32 // callers should use SerializedNavigationDriver::Get() instead. 31 // callers should use SerializedNavigationDriver::Get() instead.
33 static ContentSerializedNavigationDriver* GetInstance(); 32 static ContentSerializedNavigationDriver* GetInstance();
34 33
34 // Allows an embedder to override the instance returned by GetInstance().
35 static void SetInstance(ContentSerializedNavigationDriver* instance);
36
35 // SerializedNavigationDriver implementation. 37 // SerializedNavigationDriver implementation.
36 int GetDefaultReferrerPolicy() const override; 38 int GetDefaultReferrerPolicy() const override;
37 bool MapReferrerPolicyToOldValues(int referrer_policy, 39 bool MapReferrerPolicyToOldValues(int referrer_policy,
38 int* mapped_referrer_policy) const override; 40 int* mapped_referrer_policy) const override;
39 bool MapReferrerPolicyToNewValues(int referrer_policy, 41 bool MapReferrerPolicyToNewValues(int referrer_policy,
40 int* mapped_referrer_policy) const override; 42 int* mapped_referrer_policy) const override;
41 std::string GetSanitizedPageStateForPickle( 43 std::string GetSanitizedPageStateForPickle(
42 const SerializedNavigationEntry* navigation) const override; 44 const SerializedNavigationEntry* navigation) const override;
43 void Sanitize(SerializedNavigationEntry* navigation) const override; 45 void Sanitize(SerializedNavigationEntry* navigation) const override;
44 std::string StripReferrerFromPageState( 46 std::string StripReferrerFromPageState(
45 const std::string& page_state) const override; 47 const std::string& page_state) const override;
46 48
47 // Registers a handler that is used to read and write the extended 49 // Registers a handler that is used to read and write the extended
48 // info stored in SerializedNavigationEntry. As part of serialization |key| 50 // info stored in SerializedNavigationEntry. As part of serialization |key|
49 // is written to disk, as such once a handler is registered it should always 51 // is written to disk, as such once a handler is registered it should always
50 // be registered to the same key. 52 // be registered to the same key.
51 void RegisterExtendedInfoHandler( 53 void RegisterExtendedInfoHandler(
52 const std::string& key, 54 const std::string& key,
53 std::unique_ptr<ExtendedInfoHandler> handler); 55 std::unique_ptr<ExtendedInfoHandler> handler);
54 56
55 using ExtendedInfoHandlerMap = 57 using ExtendedInfoHandlerMap =
56 std::map<std::string, std::unique_ptr<ExtendedInfoHandler>>; 58 std::map<std::string, std::unique_ptr<ExtendedInfoHandler>>;
57 59
58 // Returns all the registered handlers to deal with the extended info. 60 // Returns all the registered handlers to deal with the extended info.
59 const ExtendedInfoHandlerMap& GetAllExtendedInfoHandlers() const; 61 const ExtendedInfoHandlerMap& GetAllExtendedInfoHandlers() const;
60 62
63 protected:
64 ContentSerializedNavigationDriver();
65
61 private: 66 private:
62 friend struct base::DefaultSingletonTraits<ContentSerializedNavigationDriver>; 67 friend struct base::DefaultSingletonTraits<ContentSerializedNavigationDriver>;
63 friend class ContentSerializedNavigationBuilderTest; 68 friend class ContentSerializedNavigationBuilderTest;
64 69
65 ContentSerializedNavigationDriver();
66
67 ExtendedInfoHandlerMap extended_info_handler_map_; 70 ExtendedInfoHandlerMap extended_info_handler_map_;
68 71
69 DISALLOW_COPY_AND_ASSIGN(ContentSerializedNavigationDriver); 72 DISALLOW_COPY_AND_ASSIGN(ContentSerializedNavigationDriver);
70 }; 73 };
71 74
72 } // namespace sessions 75 } // namespace sessions
73 76
74 #endif // COMPONENTS_SESSIONS_CONTENT_CONTENT_SERIALIZED_NAVIGATION_DRIVER_H_ 77 #endif // COMPONENTS_SESSIONS_CONTENT_CONTENT_SERIALIZED_NAVIGATION_DRIVER_H_
OLDNEW
« no previous file with comments | « chrome/test/BUILD.gn ('k') | components/sessions/content/content_serialized_navigation_driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698