Chromium Code Reviews| OLD | NEW | 
|---|---|
| 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" | 8 #include "components/sessions/core/serialized_navigation_driver.h" | 
| 9 | 9 | 
| 10 #include <map> | |
| 11 | |
| 10 #include "components/sessions/core/sessions_export.h" | 12 #include "components/sessions/core/sessions_export.h" | 
| 11 | 13 | 
| 12 namespace base { | 14 namespace base { | 
| 13 template <typename T> struct DefaultSingletonTraits; | 15 template <typename T> struct DefaultSingletonTraits; | 
| 14 } | 16 } | 
| 15 | 17 | 
| 16 namespace sessions { | 18 namespace sessions { | 
| 17 | 19 | 
| 20 class ExtendedInfoHandler; | |
| 21 | |
| 18 // Provides an implementation of SerializedNavigationDriver that is backed by | 22 // Provides an implementation of SerializedNavigationDriver that is backed by | 
| 19 // content classes. | 23 // content classes. | 
| 20 class SESSIONS_EXPORT ContentSerializedNavigationDriver | 24 class SESSIONS_EXPORT ContentSerializedNavigationDriver | 
| 21 : public SerializedNavigationDriver { | 25 : public SerializedNavigationDriver { | 
| 22 public: | 26 public: | 
| 23 ~ContentSerializedNavigationDriver() override; | 27 ~ContentSerializedNavigationDriver() override; | 
| 24 | 28 | 
| 25 // Returns the singleton ContentSerializedNavigationDriver. Almost all | 29 // Returns the singleton ContentSerializedNavigationDriver. Almost all | 
| 26 // callers should use SerializedNavigationDriver::Get() instead. | 30 // callers should use SerializedNavigationDriver::Get() instead. | 
| 27 static ContentSerializedNavigationDriver* GetInstance(); | 31 static ContentSerializedNavigationDriver* GetInstance(); | 
| 28 | 32 | 
| 29 // SerializedNavigationDriver implementation. | 33 // SerializedNavigationDriver implementation. | 
| 30 int GetDefaultReferrerPolicy() const override; | 34 int GetDefaultReferrerPolicy() const override; | 
| 31 bool MapReferrerPolicyToOldValues(int referrer_policy, | 35 bool MapReferrerPolicyToOldValues(int referrer_policy, | 
| 32 int* mapped_referrer_policy) const override; | 36 int* mapped_referrer_policy) const override; | 
| 33 bool MapReferrerPolicyToNewValues(int referrer_policy, | 37 bool MapReferrerPolicyToNewValues(int referrer_policy, | 
| 34 int* mapped_referrer_policy) const override; | 38 int* mapped_referrer_policy) const override; | 
| 35 std::string GetSanitizedPageStateForPickle( | 39 std::string GetSanitizedPageStateForPickle( | 
| 36 const SerializedNavigationEntry* navigation) const override; | 40 const SerializedNavigationEntry* navigation) const override; | 
| 37 void Sanitize(SerializedNavigationEntry* navigation) const override; | 41 void Sanitize(SerializedNavigationEntry* navigation) const override; | 
| 38 std::string StripReferrerFromPageState( | 42 std::string StripReferrerFromPageState( | 
| 39 const std::string& page_state) const override; | 43 const std::string& page_state) const override; | 
| 40 | 44 | 
| 45 // Registers a handler that is used to read and write the extended | |
| 46 // info stored in SerializedNavigationEntry. | |
| 
 
sky
2016/09/29 03:08:19
Also add 'As part of serialization |key| is writte
 
jianli
2016/09/29 22:02:29
Done.
 
 | |
| 47 void RegisterExtendedInfoHandler( | |
| 48 const std::string& key, | |
| 49 std::unique_ptr<ExtendedInfoHandler> handler); | |
| 50 | |
| 51 using ExtendedInfoHandlerMap = | |
| 52 std::map<std::string, std::unique_ptr<ExtendedInfoHandler>>; | |
| 53 | |
| 54 // Returns all the registered handlers to deal with the extended info. | |
| 55 const ExtendedInfoHandlerMap& GetAllExtendedInfoHandlers() const; | |
| 56 | |
| 41 private: | 57 private: | 
| 42 ContentSerializedNavigationDriver(); | 58 ContentSerializedNavigationDriver(); | 
| 43 friend struct base::DefaultSingletonTraits<ContentSerializedNavigationDriver>; | 59 friend struct base::DefaultSingletonTraits<ContentSerializedNavigationDriver>; | 
| 60 | |
| 61 ExtendedInfoHandlerMap extended_info_handler_map_; | |
| 44 }; | 62 }; | 
| 45 | 63 | 
| 46 } // namespace sessions | 64 } // namespace sessions | 
| 47 | 65 | 
| 48 #endif // COMPONENTS_SESSIONS_CONTENT_CONTENT_SERIALIZED_NAVIGATION_DRIVER_H_ | 66 #endif // COMPONENTS_SESSIONS_CONTENT_CONTENT_SERIALIZED_NAVIGATION_DRIVER_H_ | 
| OLD | NEW |