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

Side by Side 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, 2 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 #include "components/sessions/content/content_serialized_navigation_builder.h" 5 #include "components/sessions/content/content_serialized_navigation_builder.h"
6 6
7 #include "base/logging.h"
7 #include "components/sessions/content/content_record_password_state.h" 8 #include "components/sessions/content/content_record_password_state.h"
9 #include "components/sessions/content/content_serialized_navigation_driver.h"
10 #include "components/sessions/content/extended_info_handler.h"
8 #include "components/sessions/core/serialized_navigation_entry.h" 11 #include "components/sessions/core/serialized_navigation_entry.h"
9 #include "content/public/browser/browser_context.h" 12 #include "content/public/browser/browser_context.h"
10 #include "content/public/browser/favicon_status.h" 13 #include "content/public/browser/favicon_status.h"
11 #include "content/public/browser/navigation_controller.h" 14 #include "content/public/browser/navigation_controller.h"
12 #include "content/public/browser/navigation_entry.h" 15 #include "content/public/browser/navigation_entry.h"
13 #include "content/public/common/page_state.h" 16 #include "content/public/common/page_state.h"
14 #include "content/public/common/referrer.h" 17 #include "content/public/common/referrer.h"
15 18
16 namespace sessions { 19 namespace sessions {
17 20
(...skipping 17 matching lines...) Expand all
35 navigation.is_overriding_user_agent_ = entry.GetIsOverridingUserAgent(); 38 navigation.is_overriding_user_agent_ = entry.GetIsOverridingUserAgent();
36 navigation.timestamp_ = entry.GetTimestamp(); 39 navigation.timestamp_ = entry.GetTimestamp();
37 navigation.is_restored_ = entry.IsRestored(); 40 navigation.is_restored_ = entry.IsRestored();
38 entry.GetExtraData(kSearchTermsKey, &navigation.search_terms_); 41 entry.GetExtraData(kSearchTermsKey, &navigation.search_terms_);
39 if (entry.GetFavicon().valid) 42 if (entry.GetFavicon().valid)
40 navigation.favicon_url_ = entry.GetFavicon().url; 43 navigation.favicon_url_ = entry.GetFavicon().url;
41 navigation.http_status_code_ = entry.GetHttpStatusCode(); 44 navigation.http_status_code_ = entry.GetHttpStatusCode();
42 navigation.redirect_chain_ = entry.GetRedirectChain(); 45 navigation.redirect_chain_ = entry.GetRedirectChain();
43 navigation.password_state_ = GetPasswordStateFromNavigation(entry); 46 navigation.password_state_ = GetPasswordStateFromNavigation(entry);
44 47
48 for (const auto& handler_entry :
49 ContentSerializedNavigationDriver::GetInstance()
50 ->GetAllExtendedInfoHandlers()) {
51 ExtendedInfoHandler* handler = handler_entry.second.get();
52 DCHECK(handler);
53 std::string value = handler->GetExtendedInfo(entry);
54 if (!value.empty())
55 navigation.extended_info_map_[handler_entry.first] = value;
56 }
57
45 return navigation; 58 return navigation;
46 } 59 }
47 60
48 // static 61 // static
49 std::unique_ptr<content::NavigationEntry> 62 std::unique_ptr<content::NavigationEntry>
50 ContentSerializedNavigationBuilder::ToNavigationEntry( 63 ContentSerializedNavigationBuilder::ToNavigationEntry(
51 const SerializedNavigationEntry* navigation, 64 const SerializedNavigationEntry* navigation,
52 int page_id, 65 int page_id,
53 content::BrowserContext* browser_context) { 66 content::BrowserContext* browser_context) {
54 blink::WebReferrerPolicy policy = 67 blink::WebReferrerPolicy policy =
(...skipping 16 matching lines...) Expand all
71 entry->SetPageID(page_id); 84 entry->SetPageID(page_id);
72 entry->SetHasPostData(navigation->has_post_data_); 85 entry->SetHasPostData(navigation->has_post_data_);
73 entry->SetPostID(navigation->post_id_); 86 entry->SetPostID(navigation->post_id_);
74 entry->SetOriginalRequestURL(navigation->original_request_url_); 87 entry->SetOriginalRequestURL(navigation->original_request_url_);
75 entry->SetIsOverridingUserAgent(navigation->is_overriding_user_agent_); 88 entry->SetIsOverridingUserAgent(navigation->is_overriding_user_agent_);
76 entry->SetTimestamp(navigation->timestamp_); 89 entry->SetTimestamp(navigation->timestamp_);
77 entry->SetExtraData(kSearchTermsKey, navigation->search_terms_); 90 entry->SetExtraData(kSearchTermsKey, navigation->search_terms_);
78 entry->SetHttpStatusCode(navigation->http_status_code_); 91 entry->SetHttpStatusCode(navigation->http_status_code_);
79 entry->SetRedirectChain(navigation->redirect_chain_); 92 entry->SetRedirectChain(navigation->redirect_chain_);
80 93
94 const ContentSerializedNavigationDriver::ExtendedInfoHandlerMap&
95 extended_info_handlers = ContentSerializedNavigationDriver::GetInstance()
96 ->GetAllExtendedInfoHandlers();
97 for (const auto& extended_info_entry : navigation->extended_info_map_) {
98 const std::string& key = extended_info_entry.first;
99 if (!extended_info_handlers.count(key))
100 continue;
101 ExtendedInfoHandler* extended_info_handler =
102 extended_info_handlers.at(key).get();
103 DCHECK(extended_info_handler);
104 extended_info_handler->RestoreExtendedInfo(extended_info_entry.second,
105 entry.get());
106 }
107
81 // These fields should have default values. 108 // These fields should have default values.
82 DCHECK_EQ(SerializedNavigationEntry::STATE_INVALID, 109 DCHECK_EQ(SerializedNavigationEntry::STATE_INVALID,
83 navigation->blocked_state_); 110 navigation->blocked_state_);
84 DCHECK_EQ(0u, navigation->content_pack_categories_.size()); 111 DCHECK_EQ(0u, navigation->content_pack_categories_.size());
85 112
86 return entry; 113 return entry;
87 } 114 }
88 115
89 // static 116 // static
90 std::vector<std::unique_ptr<content::NavigationEntry>> 117 std::vector<std::unique_ptr<content::NavigationEntry>>
91 ContentSerializedNavigationBuilder::ToNavigationEntries( 118 ContentSerializedNavigationBuilder::ToNavigationEntries(
92 const std::vector<SerializedNavigationEntry>& navigations, 119 const std::vector<SerializedNavigationEntry>& navigations,
93 content::BrowserContext* browser_context) { 120 content::BrowserContext* browser_context) {
94 int page_id = 0; 121 int page_id = 0;
95 std::vector<std::unique_ptr<content::NavigationEntry>> entries; 122 std::vector<std::unique_ptr<content::NavigationEntry>> entries;
96 entries.reserve(navigations.size()); 123 entries.reserve(navigations.size());
97 for (const auto& navigation : navigations) { 124 for (const auto& navigation : navigations) {
98 entries.push_back(ToNavigationEntry(&navigation, page_id, browser_context)); 125 entries.push_back(ToNavigationEntry(&navigation, page_id, browser_context));
99 ++page_id; 126 ++page_id;
100 } 127 }
101 return entries; 128 return entries;
102 } 129 }
103 130
104 } // namespace sessions 131 } // namespace sessions
OLDNEW
« 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