Don't preload rarely seen large images
[chromium-blink-merge.git] / components / sessions / ios / ios_serialized_navigation_builder.cc
blob135b7d5b8b596b9d4154cdfb1a8de319f3c7347f
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
3 // found in the LICENSE file.
5 #include "components/sessions/ios/ios_serialized_navigation_builder.h"
7 #include "components/sessions/serialized_navigation_entry.h"
8 #include "ios/web/public/favicon_status.h"
9 #include "ios/web/public/navigation_item.h"
10 #include "ios/web/public/referrer.h"
12 namespace sessions {
14 // static
15 SerializedNavigationEntry
16 IOSSerializedNavigationBuilder::FromNavigationItem(
17 int index, const web::NavigationItem& item) {
18 SerializedNavigationEntry navigation;
19 navigation.index_ = index;
20 navigation.unique_id_ = item.GetUniqueID();
21 navigation.referrer_url_ = item.GetReferrer().url;
22 navigation.referrer_policy_ = item.GetReferrer().policy;
23 navigation.virtual_url_ = item.GetVirtualURL();
24 navigation.title_ = item.GetTitle();
25 navigation.transition_type_ = item.GetTransitionType();
26 navigation.timestamp_ = item.GetTimestamp();
27 if (item.GetFavicon().valid)
28 navigation.favicon_url_ = item.GetFavicon().url;
30 return navigation;
33 // static
34 scoped_ptr<web::NavigationItem>
35 IOSSerializedNavigationBuilder::ToNavigationItem(
36 const SerializedNavigationEntry* navigation, int page_id) {
37 scoped_ptr<web::NavigationItem> item(web::NavigationItem::Create());
39 item->SetURL(navigation->virtual_url_);
40 item->SetReferrer(web::Referrer(
41 navigation->referrer_url_,
42 static_cast<web::ReferrerPolicy>(navigation->referrer_policy_)));
43 item->SetTitle(navigation->title_);
44 item->SetPageID(page_id);
45 item->SetTransitionType(ui::PAGE_TRANSITION_RELOAD);
46 item->SetTimestamp(navigation->timestamp_);
48 if (navigation->favicon_url_.is_valid()) {
49 item->GetFavicon().url = navigation->favicon_url_;
52 return item.Pass();
55 } // namespace sessions