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

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: Add extended info support 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..f16f34d9d3fc9d673c5fe226b2774223eb8ee000 100644
--- a/components/sessions/content/content_serialized_navigation_builder.cc
+++ b/components/sessions/content/content_serialized_navigation_builder.cc
@@ -4,7 +4,11 @@
#include "components/sessions/content/content_serialized_navigation_builder.h"
+#include "base/macros.h"
+#include "base/strings/string_tokenizer.h"
+#include "base/strings/string_util.h"
#include "components/sessions/content/content_record_password_state.h"
+#include "components/sessions/core/serialized_navigation_driver.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 +46,15 @@ ContentSerializedNavigationBuilder::FromNavigationEntry(
navigation.redirect_chain_ = entry.GetRedirectChain();
navigation.password_state_ = GetPasswordStateFromNavigation(entry);
+ for (const auto& handler_entry :
+ SerializedNavigationDriver::Get()->GetAllExtendedInfoHandlers()) {
+ SerializedNavigationDriver::ExtendedInfoHandler* handler =
+ handler_entry.second.get();
+ DCHECK(handler);
+ navigation.extended_info_map_[handler_entry.first] =
+ handler->GetExtendedInfo(entry);
+ }
+
return navigation;
}
@@ -78,6 +91,18 @@ ContentSerializedNavigationBuilder::ToNavigationEntry(
entry->SetHttpStatusCode(navigation->http_status_code_);
entry->SetRedirectChain(navigation->redirect_chain_);
+ for (const auto& handler_entry :
+ SerializedNavigationDriver::Get()->GetAllExtendedInfoHandlers()) {
+ const std::string& key = handler_entry.first;
+ if (!navigation->extended_info_map_.count(key))
+ continue;
+ SerializedNavigationDriver::ExtendedInfoHandler* handler =
+ handler_entry.second.get();
+ DCHECK(handler);
+ const std::string& value = navigation->extended_info_map_.at(key);
+ handler->RestoreExtendedInfo(value, entry.get());
+ }
+
// These fields should have default values.
DCHECK_EQ(SerializedNavigationEntry::STATE_INVALID,
navigation->blocked_state_);

Powered by Google App Engine
This is Rietveld 408576698