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

Side by Side Diff: components/sessions/content/content_serialized_navigation_builder.cc

Issue 2264633003: Workaround for reading bad PageState from session history. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/sessions/core/serialized_navigation_entry.h" 7 #include "components/sessions/core/serialized_navigation_entry.h"
8 #include "content/public/browser/browser_context.h" 8 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/favicon_status.h" 9 #include "content/public/browser/favicon_status.h"
10 #include "content/public/browser/navigation_controller.h" 10 #include "content/public/browser/navigation_controller.h"
11 #include "content/public/browser/navigation_entry.h" 11 #include "content/public/browser/navigation_entry.h"
12 #include "content/public/common/page_state.h" 12 #include "content/public/common/page_state.h"
13 #include "content/public/common/referrer.h" 13 #include "content/public/common/referrer.h"
14 14
15 namespace sessions { 15 namespace sessions {
16 16
17 // static 17 // static
18 SerializedNavigationEntry 18 SerializedNavigationEntry
19 ContentSerializedNavigationBuilder::FromNavigationEntry( 19 ContentSerializedNavigationBuilder::FromNavigationEntry(
20 int index, 20 int index,
21 const content::NavigationEntry& entry) { 21 const content::NavigationEntry& entry) {
22 SerializedNavigationEntry navigation; 22 SerializedNavigationEntry navigation;
23 navigation.index_ = index; 23 navigation.index_ = index;
24 navigation.unique_id_ = entry.GetUniqueID(); 24 navigation.unique_id_ = entry.GetUniqueID();
25 navigation.referrer_url_ = entry.GetReferrer().url; 25 navigation.referrer_url_ = entry.GetReferrer().url;
26 navigation.referrer_policy_ = entry.GetReferrer().policy; 26 navigation.referrer_policy_ = entry.GetReferrer().policy;
27 navigation.virtual_url_ = entry.GetVirtualURL(); 27 navigation.virtual_url_ = entry.GetVirtualURL();
28 navigation.title_ = entry.GetTitle(); 28 navigation.title_ = entry.GetTitle();
29 DLOG(INFO) << "csnb from: PageState:" << entry.GetPageState().ToEncodedData();
29 navigation.encoded_page_state_ = entry.GetPageState().ToEncodedData(); 30 navigation.encoded_page_state_ = entry.GetPageState().ToEncodedData();
30 navigation.transition_type_ = entry.GetTransitionType(); 31 navigation.transition_type_ = entry.GetTransitionType();
31 navigation.has_post_data_ = entry.GetHasPostData(); 32 navigation.has_post_data_ = entry.GetHasPostData();
32 navigation.post_id_ = entry.GetPostID(); 33 navigation.post_id_ = entry.GetPostID();
33 navigation.original_request_url_ = entry.GetOriginalRequestURL(); 34 navigation.original_request_url_ = entry.GetOriginalRequestURL();
34 navigation.is_overriding_user_agent_ = entry.GetIsOverridingUserAgent(); 35 navigation.is_overriding_user_agent_ = entry.GetIsOverridingUserAgent();
35 navigation.timestamp_ = entry.GetTimestamp(); 36 navigation.timestamp_ = entry.GetTimestamp();
36 navigation.is_restored_ = entry.IsRestored(); 37 navigation.is_restored_ = entry.IsRestored();
37 entry.GetExtraData(kSearchTermsKey, &navigation.search_terms_); 38 entry.GetExtraData(kSearchTermsKey, &navigation.search_terms_);
38 if (entry.GetFavicon().valid) 39 if (entry.GetFavicon().valid)
(...skipping 18 matching lines...) Expand all
57 content::Referrer::SanitizeForRequest( 58 content::Referrer::SanitizeForRequest(
58 navigation->virtual_url_, 59 navigation->virtual_url_,
59 content::Referrer(navigation->referrer_url_, policy)), 60 content::Referrer(navigation->referrer_url_, policy)),
60 // Use a transition type of reload so that we don't incorrectly 61 // Use a transition type of reload so that we don't incorrectly
61 // increase the typed count. 62 // increase the typed count.
62 ui::PAGE_TRANSITION_RELOAD, false, 63 ui::PAGE_TRANSITION_RELOAD, false,
63 // The extra headers are not sync'ed across sessions. 64 // The extra headers are not sync'ed across sessions.
64 std::string(), browser_context)); 65 std::string(), browser_context));
65 66
66 entry->SetTitle(navigation->title_); 67 entry->SetTitle(navigation->title_);
68 DLOG(INFO) << "csnb to: PageState: " << navigation->encoded_page_state_;
67 entry->SetPageState(content::PageState::CreateFromEncodedData( 69 entry->SetPageState(content::PageState::CreateFromEncodedData(
68 navigation->encoded_page_state_)); 70 navigation->encoded_page_state_));
69 entry->SetPageID(page_id); 71 entry->SetPageID(page_id);
70 entry->SetHasPostData(navigation->has_post_data_); 72 entry->SetHasPostData(navigation->has_post_data_);
71 entry->SetPostID(navigation->post_id_); 73 entry->SetPostID(navigation->post_id_);
72 entry->SetOriginalRequestURL(navigation->original_request_url_); 74 entry->SetOriginalRequestURL(navigation->original_request_url_);
73 entry->SetIsOverridingUserAgent(navigation->is_overriding_user_agent_); 75 entry->SetIsOverridingUserAgent(navigation->is_overriding_user_agent_);
74 entry->SetTimestamp(navigation->timestamp_); 76 entry->SetTimestamp(navigation->timestamp_);
75 entry->SetExtraData(kSearchTermsKey, navigation->search_terms_); 77 entry->SetExtraData(kSearchTermsKey, navigation->search_terms_);
76 entry->SetHttpStatusCode(navigation->http_status_code_); 78 entry->SetHttpStatusCode(navigation->http_status_code_);
(...skipping 16 matching lines...) Expand all
93 std::vector<std::unique_ptr<content::NavigationEntry>> entries; 95 std::vector<std::unique_ptr<content::NavigationEntry>> entries;
94 entries.reserve(navigations.size()); 96 entries.reserve(navigations.size());
95 for (const auto& navigation : navigations) { 97 for (const auto& navigation : navigations) {
96 entries.push_back(ToNavigationEntry(&navigation, page_id, browser_context)); 98 entries.push_back(ToNavigationEntry(&navigation, page_id, browser_context));
97 ++page_id; 99 ++page_id;
98 } 100 }
99 return entries; 101 return entries;
100 } 102 }
101 103
102 } // namespace sessions 104 } // namespace sessions
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698