OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 #import "ios/web/navigation/navigation_item_storage_builder.h" | 5 #import "ios/web/navigation/navigation_item_storage_builder.h" |
6 | 6 |
7 #import "ios/web/navigation/navigation_item_impl.h" | 7 #import "ios/web/navigation/navigation_item_impl.h" |
8 #import "ios/web/public/crw_navigation_item_storage.h" | 8 #import "ios/web/public/crw_navigation_item_storage.h" |
9 | 9 |
10 #if !defined(__has_feature) || !__has_feature(objc_arc) | 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
11 #error "This file requires ARC support." | 11 #error "This file requires ARC support." |
12 #endif | 12 #endif |
13 | 13 |
14 namespace web { | 14 namespace web { |
15 | 15 |
16 CRWNavigationItemStorage* NavigationItemStorageBuilder::BuildStorage( | 16 CRWNavigationItemStorage* NavigationItemStorageBuilder::BuildStorage( |
17 NavigationItemImpl* navigation_item) const { | 17 NavigationItemImpl* navigation_item) const { |
18 DCHECK(navigation_item); | 18 DCHECK(navigation_item); |
19 CRWNavigationItemStorage* storage = [[CRWNavigationItemStorage alloc] init]; | 19 CRWNavigationItemStorage* storage = [[CRWNavigationItemStorage alloc] init]; |
20 storage.virtualURL = navigation_item->GetVirtualURL(); | 20 storage.virtualURL = navigation_item->GetVirtualURL(); |
21 storage.referrer = navigation_item->GetReferrer(); | 21 storage.referrer = navigation_item->GetReferrer(); |
22 storage.timestamp = navigation_item->GetTimestamp(); | 22 storage.timestamp = navigation_item->GetTimestamp(); |
23 storage.title = navigation_item->GetTitle(); | 23 storage.title = navigation_item->GetTitle(); |
24 storage.displayState = navigation_item->GetPageDisplayState(); | 24 storage.displayState = navigation_item->GetPageDisplayState(); |
25 storage.shouldSkipRepostFormConfirmation = | 25 storage.shouldSkipRepostFormConfirmation = |
26 navigation_item->ShouldSkipRepostFormConfirmation(); | 26 navigation_item->ShouldSkipRepostFormConfirmation(); |
27 storage.overridingUserAgent = navigation_item->IsOverridingUserAgent(); | 27 storage.userAgentType = navigation_item->GetUserAgentType(); |
28 storage.POSTData = navigation_item->GetPostData(); | 28 storage.POSTData = navigation_item->GetPostData(); |
29 storage.HTTPRequestHeaders = navigation_item->GetHttpRequestHeaders(); | 29 storage.HTTPRequestHeaders = navigation_item->GetHttpRequestHeaders(); |
30 return storage; | 30 return storage; |
31 } | 31 } |
32 | 32 |
33 std::unique_ptr<NavigationItemImpl> | 33 std::unique_ptr<NavigationItemImpl> |
34 NavigationItemStorageBuilder::BuildNavigationItemImpl( | 34 NavigationItemStorageBuilder::BuildNavigationItemImpl( |
35 CRWNavigationItemStorage* navigation_item_storage) const { | 35 CRWNavigationItemStorage* navigation_item_storage) const { |
36 std::unique_ptr<NavigationItemImpl> item(new web::NavigationItemImpl()); | 36 std::unique_ptr<NavigationItemImpl> item(new web::NavigationItemImpl()); |
37 // While the virtual URL is persisted, we still need the original request URL | 37 // While the virtual URL is persisted, we still need the original request URL |
38 // and the non-virtual URL to be set upon NavigationItem creation. Since | 38 // and the non-virtual URL to be set upon NavigationItem creation. Since |
39 // GetVirtualURL() returns |url_| for the non-overridden case, this will also | 39 // GetVirtualURL() returns |url_| for the non-overridden case, this will also |
40 // update the virtual URL reported by this object. | 40 // update the virtual URL reported by this object. |
41 item->original_request_url_ = navigation_item_storage.virtualURL; | 41 item->original_request_url_ = navigation_item_storage.virtualURL; |
42 item->url_ = navigation_item_storage.virtualURL; | 42 item->url_ = navigation_item_storage.virtualURL; |
43 item->referrer_ = navigation_item_storage.referrer; | 43 item->referrer_ = navigation_item_storage.referrer; |
44 item->timestamp_ = navigation_item_storage.timestamp; | 44 item->timestamp_ = navigation_item_storage.timestamp; |
45 item->title_ = navigation_item_storage.title; | 45 item->title_ = navigation_item_storage.title; |
46 item->page_display_state_ = navigation_item_storage.displayState; | 46 item->page_display_state_ = navigation_item_storage.displayState; |
47 item->should_skip_repost_form_confirmation_ = | 47 item->should_skip_repost_form_confirmation_ = |
48 navigation_item_storage.shouldSkipRepostFormConfirmation; | 48 navigation_item_storage.shouldSkipRepostFormConfirmation; |
49 item->is_overriding_user_agent_ = navigation_item_storage.overridingUserAgent; | 49 item->user_agent_type_ = navigation_item_storage.userAgentType; |
50 item->post_data_.reset(navigation_item_storage.POSTData); | 50 item->post_data_.reset(navigation_item_storage.POSTData); |
51 item->http_request_headers_.reset( | 51 item->http_request_headers_.reset( |
52 [navigation_item_storage.HTTPRequestHeaders mutableCopy]); | 52 [navigation_item_storage.HTTPRequestHeaders mutableCopy]); |
53 return item; | 53 return item; |
54 } | 54 } |
55 | 55 |
56 } // namespace web | 56 } // namespace web |
OLD | NEW |