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

Unified Diff: components/sessions/content/content_serialized_navigation_builder.cc

Issue 2310363002: Persist offline page info in a navigation entry if needed (Closed)
Patch Set: Fix win compiling error due to using unique_ptr map in SESSIONS_EXPORT class Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/sessions/content/content_serialized_navigation_builder.cc
diff --git a/components/sessions/content/content_serialized_navigation_builder.cc b/components/sessions/content/content_serialized_navigation_builder.cc
index 59df5cc2d016730fa5a64ff1c9875b12ad3cd696..1894bcb8869b59898d0e708e6340aa5c782301c2 100644
--- a/components/sessions/content/content_serialized_navigation_builder.cc
+++ b/components/sessions/content/content_serialized_navigation_builder.cc
@@ -4,7 +4,10 @@
#include "components/sessions/content/content_serialized_navigation_builder.h"
+#include "base/logging.h"
#include "components/sessions/content/content_record_password_state.h"
+#include "components/sessions/content/content_serialized_navigation_driver.h"
+#include "components/sessions/content/extended_info_handler.h"
#include "components/sessions/core/serialized_navigation_entry.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/favicon_status.h"
@@ -42,6 +45,16 @@ ContentSerializedNavigationBuilder::FromNavigationEntry(
navigation.redirect_chain_ = entry.GetRedirectChain();
navigation.password_state_ = GetPasswordStateFromNavigation(entry);
+ for (const auto& handler_entry :
+ ContentSerializedNavigationDriver::GetInstance()
+ ->GetAllExtendedInfoHandlers()) {
+ ExtendedInfoHandler* handler = handler_entry.second.get();
+ DCHECK(handler);
+ std::string value = handler->GetExtendedInfo(entry);
+ if (!value.empty())
+ navigation.extended_info_map_[handler_entry.first] = value;
+ }
+
return navigation;
}
@@ -78,6 +91,20 @@ ContentSerializedNavigationBuilder::ToNavigationEntry(
entry->SetHttpStatusCode(navigation->http_status_code_);
entry->SetRedirectChain(navigation->redirect_chain_);
+ const ContentSerializedNavigationDriver::ExtendedInfoHandlerMap&
+ extended_info_handlers = ContentSerializedNavigationDriver::GetInstance()
+ ->GetAllExtendedInfoHandlers();
+ for (const auto& extended_info_entry : navigation->extended_info_map_) {
+ const std::string& key = extended_info_entry.first;
+ if (!extended_info_handlers.count(key))
+ continue;
+ ExtendedInfoHandler* extended_info_handler =
+ extended_info_handlers.at(key).get();
+ DCHECK(extended_info_handler);
+ extended_info_handler->RestoreExtendedInfo(extended_info_entry.second,
+ entry.get());
+ }
+
// These fields should have default values.
DCHECK_EQ(SerializedNavigationEntry::STATE_INVALID,
navigation->blocked_state_);
« no previous file with comments | « components/sessions/BUILD.gn ('k') | components/sessions/content/content_serialized_navigation_builder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698