Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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. | |
|
Eugene But (OOO till 7-30)
2017/01/31 22:12:26
Could you please add a unit test for this class.
| |
| 4 | |
| 5 #import "ios/web/navigation/navigation_item_storage_builder.h" | |
| 6 | |
| 7 #import "ios/web/navigation/navigation_item_impl.h" | |
| 8 #import "ios/web/public/crw_navigation_item_storage.h" | |
| 9 | |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 11 #error "This file requires ARC support." | |
| 12 #endif | |
| 13 | |
| 14 namespace web { | |
| 15 | |
| 16 CRWNavigationItemStorage* NavigationItemStorageBuilder::BuildSerialization( | |
| 17 NavigationItemImpl* navigation_item) const { | |
| 18 DCHECK(navigation_item); | |
| 19 CRWNavigationItemStorage* storage = [[CRWNavigationItemStorage alloc] init]; | |
| 20 storage.virtualURL = navigation_item->GetVirtualURL(); | |
| 21 storage.referrer = navigation_item->GetReferrer(); | |
| 22 storage.timestamp = navigation_item->GetTimestamp(); | |
| 23 storage.title = navigation_item->GetTitle(); | |
| 24 storage.displayState = navigation_item->GetPageDisplayState(); | |
| 25 storage.shouldSkipRepostFormConfirmation = | |
| 26 navigation_item->ShouldSkipRepostFormConfirmation(); | |
| 27 storage.overridingUserAgent = navigation_item->IsOverridingUserAgent(); | |
| 28 storage.POSTData = navigation_item->GetPostData(); | |
| 29 storage.HTTPRequestHeaders = navigation_item->GetHttpRequestHeaders(); | |
| 30 return storage; | |
| 31 } | |
| 32 | |
| 33 std::unique_ptr<NavigationItemImpl> | |
| 34 NavigationItemStorageBuilder::BuildNavigationItemImpl( | |
| 35 CRWNavigationItemStorage* navigation_item_storage) const { | |
| 36 std::unique_ptr<NavigationItemImpl> item(new web::NavigationItemImpl()); | |
| 37 item->virtual_url_ = navigation_item_storage.virtualURL; | |
| 38 item->referrer_ = navigation_item_storage.referrer; | |
| 39 item->timestamp_ = navigation_item_storage.timestamp; | |
| 40 item->title_ = navigation_item_storage.title; | |
| 41 item->page_display_state_ = navigation_item_storage.displayState; | |
| 42 item->should_skip_repost_form_confirmation_ = | |
| 43 navigation_item_storage.shouldSkipRepostFormConfirmation; | |
| 44 item->is_overriding_user_agent_ = navigation_item_storage.overridingUserAgent; | |
| 45 item->post_data_.reset(navigation_item_storage.POSTData); | |
| 46 item->http_request_headers_.reset( | |
| 47 [navigation_item_storage.HTTPRequestHeaders mutableCopy]); | |
| 48 return item; | |
| 49 } | |
| 50 | |
| 51 } // namespace web | |
| OLD | NEW |