| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/serialized_navigation_entry.h" | 5 #include "components/sessions/serialized_navigation_entry.h" |
| 6 | 6 |
| 7 #include "base/pickle.h" | 7 #include "base/pickle.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.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" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 SerializedNavigationEntry SerializedNavigationEntry::FromSyncData( | 62 SerializedNavigationEntry SerializedNavigationEntry::FromSyncData( |
| 63 int index, | 63 int index, |
| 64 const sync_pb::TabNavigation& sync_data) { | 64 const sync_pb::TabNavigation& sync_data) { |
| 65 SerializedNavigationEntry navigation; | 65 SerializedNavigationEntry navigation; |
| 66 navigation.index_ = index; | 66 navigation.index_ = index; |
| 67 navigation.unique_id_ = sync_data.unique_id(); | 67 navigation.unique_id_ = sync_data.unique_id(); |
| 68 navigation.referrer_ = | 68 navigation.referrer_ = |
| 69 content::Referrer(GURL(sync_data.referrer()), | 69 content::Referrer(GURL(sync_data.referrer()), |
| 70 WebKit::WebReferrerPolicyDefault); | 70 blink::WebReferrerPolicyDefault); |
| 71 navigation.virtual_url_ = GURL(sync_data.virtual_url()); | 71 navigation.virtual_url_ = GURL(sync_data.virtual_url()); |
| 72 navigation.title_ = UTF8ToUTF16(sync_data.title()); | 72 navigation.title_ = UTF8ToUTF16(sync_data.title()); |
| 73 navigation.page_state_ = | 73 navigation.page_state_ = |
| 74 content::PageState::CreateFromEncodedData(sync_data.state()); | 74 content::PageState::CreateFromEncodedData(sync_data.state()); |
| 75 | 75 |
| 76 uint32 transition = 0; | 76 uint32 transition = 0; |
| 77 if (sync_data.has_page_transition()) { | 77 if (sync_data.has_page_transition()) { |
| 78 switch (sync_data.page_transition()) { | 78 switch (sync_data.page_transition()) { |
| 79 case sync_pb::SyncEnums_PageTransition_LINK: | 79 case sync_pb::SyncEnums_PageTransition_LINK: |
| 80 transition = content::PAGE_TRANSITION_LINK; | 80 transition = content::PAGE_TRANSITION_LINK; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 if (has_type_mask) { | 286 if (has_type_mask) { |
| 287 has_post_data_ = type_mask & HAS_POST_DATA; | 287 has_post_data_ = type_mask & HAS_POST_DATA; |
| 288 // the "referrer" property was added after type_mask to the written | 288 // the "referrer" property was added after type_mask to the written |
| 289 // stream. As such, we don't fail if it can't be read. | 289 // stream. As such, we don't fail if it can't be read. |
| 290 std::string referrer_spec; | 290 std::string referrer_spec; |
| 291 if (!iterator->ReadString(&referrer_spec)) | 291 if (!iterator->ReadString(&referrer_spec)) |
| 292 referrer_spec = std::string(); | 292 referrer_spec = std::string(); |
| 293 // The "referrer policy" property was added even later, so we fall back to | 293 // The "referrer policy" property was added even later, so we fall back to |
| 294 // the default policy if the property is not present. | 294 // the default policy if the property is not present. |
| 295 int policy_int; | 295 int policy_int; |
| 296 WebKit::WebReferrerPolicy policy; | 296 blink::WebReferrerPolicy policy; |
| 297 if (iterator->ReadInt(&policy_int)) | 297 if (iterator->ReadInt(&policy_int)) |
| 298 policy = static_cast<WebKit::WebReferrerPolicy>(policy_int); | 298 policy = static_cast<blink::WebReferrerPolicy>(policy_int); |
| 299 else | 299 else |
| 300 policy = WebKit::WebReferrerPolicyDefault; | 300 policy = blink::WebReferrerPolicyDefault; |
| 301 referrer_ = content::Referrer(GURL(referrer_spec), policy); | 301 referrer_ = content::Referrer(GURL(referrer_spec), policy); |
| 302 | 302 |
| 303 // If the original URL can't be found, leave it empty. | 303 // If the original URL can't be found, leave it empty. |
| 304 std::string original_request_url_spec; | 304 std::string original_request_url_spec; |
| 305 if (!iterator->ReadString(&original_request_url_spec)) | 305 if (!iterator->ReadString(&original_request_url_spec)) |
| 306 original_request_url_spec = std::string(); | 306 original_request_url_spec = std::string(); |
| 307 original_request_url_ = GURL(original_request_url_spec); | 307 original_request_url_ = GURL(original_request_url_spec); |
| 308 | 308 |
| 309 // Default to not overriding the user agent if we don't have info. | 309 // Default to not overriding the user agent if we don't have info. |
| 310 if (!iterator->ReadBool(&is_overriding_user_agent_)) | 310 if (!iterator->ReadBool(&is_overriding_user_agent_)) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 for (std::vector<SerializedNavigationEntry>::const_iterator | 479 for (std::vector<SerializedNavigationEntry>::const_iterator |
| 480 it = navigations.begin(); it != navigations.end(); ++it) { | 480 it = navigations.begin(); it != navigations.end(); ++it) { |
| 481 entries.push_back( | 481 entries.push_back( |
| 482 it->ToNavigationEntry(page_id, browser_context).release()); | 482 it->ToNavigationEntry(page_id, browser_context).release()); |
| 483 ++page_id; | 483 ++page_id; |
| 484 } | 484 } |
| 485 return entries; | 485 return entries; |
| 486 } | 486 } |
| 487 | 487 |
| 488 } // namespace sessions | 488 } // namespace sessions |
| OLD | NEW |