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

Side by Side Diff: ios/web/navigation/crw_session_entry.mm

Issue 2578173005: Add GetOriginalRequestURL() to NavigationItem interface. (Closed)
Patch Set: Created 4 years 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 | « ios/web/navigation/crw_session_entry.h ('k') | ios/web/navigation/navigation_item_impl.h » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/crw_session_entry.h" 5 #import "ios/web/navigation/crw_session_entry.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 27 matching lines...) Expand all
38 NSString* const kSessionEntryTimestampKey = @"timestamp"; 38 NSString* const kSessionEntryTimestampKey = @"timestamp";
39 NSString* const kSessionEntryTitleKey = @"title"; 39 NSString* const kSessionEntryTitleKey = @"title";
40 NSString* const kSessionEntryPOSTDataKey = @"POSTData"; 40 NSString* const kSessionEntryPOSTDataKey = @"POSTData";
41 NSString* const kSessionEntryHTTPRequestHeadersKey = @"httpHeaders"; 41 NSString* const kSessionEntryHTTPRequestHeadersKey = @"httpHeaders";
42 NSString* const kSessionEntrySkipResubmitConfirmationKey = 42 NSString* const kSessionEntrySkipResubmitConfirmationKey =
43 @"skipResubmitDataConfirmation"; 43 @"skipResubmitDataConfirmation";
44 NSString* const kSessionEntryUseDesktopUserAgentKey = @"useDesktopUserAgent"; 44 NSString* const kSessionEntryUseDesktopUserAgentKey = @"useDesktopUserAgent";
45 } 45 }
46 46
47 @interface CRWSessionEntry () { 47 @interface CRWSessionEntry () {
48 // The original URL of the page. In cases where a redirect occurred, |url_|
49 // will contain the final post-redirect URL, and |originalUrl_| will contain
50 // the pre-redirect URL. This field is not persisted to disk.
51 GURL _originalUrl;
52
53 // The NavigationItemImpl corresponding to this CRWSessionEntry. 48 // The NavigationItemImpl corresponding to this CRWSessionEntry.
54 // TODO(stuartmorgan): Move ownership to NavigationManagerImpl. 49 // TODO(stuartmorgan): Move ownership to NavigationManagerImpl.
55 std::unique_ptr<web::NavigationItemImpl> _navigationItem; 50 std::unique_ptr<web::NavigationItemImpl> _navigationItem;
56 } 51 }
57 // Redefine originalUrl to be read-write.
58 @property(nonatomic, readwrite) const GURL& originalUrl;
59 52
60 // Converts a serialized NSDictionary to a web::PageDisplayState. 53 // Converts a serialized NSDictionary to a web::PageDisplayState.
61 + (web::PageDisplayState)pageDisplayStateFromDictionary: 54 + (web::PageDisplayState)pageDisplayStateFromDictionary:
62 (NSDictionary*)dictionary; 55 (NSDictionary*)dictionary;
63 // Serializes a web::PageDisplayState to an NSDictionary. 56 // Serializes a web::PageDisplayState to an NSDictionary.
64 + (NSDictionary*)dictionaryFromPageDisplayState: 57 + (NSDictionary*)dictionaryFromPageDisplayState:
65 (const web::PageDisplayState&)displayState; 58 (const web::PageDisplayState&)displayState;
66 // Returns a readable description of |displayState|. 59 // Returns a readable description of |displayState|.
67 + (NSString*)descriptionForPageDisplayState: 60 + (NSString*)descriptionForPageDisplayState:
68 (const web::PageDisplayState&)displayState; 61 (const web::PageDisplayState&)displayState;
69 @end 62 @end
70 63
71 @implementation CRWSessionEntry 64 @implementation CRWSessionEntry
72 65
73 @synthesize originalUrl = _originalUrl;
74
75 - (instancetype)initWithNavigationItem: 66 - (instancetype)initWithNavigationItem:
76 (std::unique_ptr<web::NavigationItem>)item { 67 (std::unique_ptr<web::NavigationItem>)item {
77 self = [super init]; 68 self = [super init];
78 if (self) { 69 if (self) {
79 _navigationItem.reset( 70 _navigationItem.reset(
80 static_cast<web::NavigationItemImpl*>(item.release())); 71 static_cast<web::NavigationItemImpl*>(item.release()));
81 self.originalUrl = _navigationItem->GetURL();
Eugene But (OOO till 7-30) 2016/12/16 22:18:18 Do we need to do this?: |_navigationItem->SetOrigi
kkhorimoto 2017/01/21 02:41:29 This line is no longer necessary, as the original
82 } 72 }
83 return self; 73 return self;
84 } 74 }
85 75
86 - (instancetype)initWithCoder:(NSCoder*)aDecoder { 76 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
87 self = [super init]; 77 self = [super init];
88 if (self) { 78 if (self) {
89 _navigationItem.reset(new web::NavigationItemImpl()); 79 _navigationItem.reset(new web::NavigationItemImpl());
90 80
91 // Desktop chrome only persists virtualUrl_ and uses it to feed the url 81 // Desktop chrome only persists virtualUrl_ and uses it to feed the url
92 // when creating a NavigationEntry. 82 // when creating a NavigationEntry.
93 GURL url; 83 GURL url;
94 if ([aDecoder containsValueForKey:web::kSessionEntryURLKey]) { 84 if ([aDecoder containsValueForKey:web::kSessionEntryURLKey]) {
95 url = GURL( 85 url = GURL(
96 web::nscoder_util::DecodeString(aDecoder, web::kSessionEntryURLKey)); 86 web::nscoder_util::DecodeString(aDecoder, web::kSessionEntryURLKey));
97 } else { 87 } else {
98 // Backward compatibility. 88 // Backward compatibility.
99 url = net::GURLWithNSURL( 89 url = net::GURLWithNSURL(
100 [aDecoder decodeObjectForKey:web::kSessionEntryURLDeperecatedKey]); 90 [aDecoder decodeObjectForKey:web::kSessionEntryURLDeperecatedKey]);
101 } 91 }
92 _navigationItem->SetOriginalRequestURL(url);
102 _navigationItem->SetURL(url); 93 _navigationItem->SetURL(url);
103 self.originalUrl = url;
104 94
105 if ([aDecoder containsValueForKey:web::kSessionEntryReferrerURLKey]) { 95 if ([aDecoder containsValueForKey:web::kSessionEntryReferrerURLKey]) {
106 const std::string referrerString(web::nscoder_util::DecodeString( 96 const std::string referrerString(web::nscoder_util::DecodeString(
107 aDecoder, web::kSessionEntryReferrerURLKey)); 97 aDecoder, web::kSessionEntryReferrerURLKey));
108 web::ReferrerPolicy referrerPolicy = static_cast<web::ReferrerPolicy>( 98 web::ReferrerPolicy referrerPolicy = static_cast<web::ReferrerPolicy>(
109 [aDecoder decodeIntForKey:web::kSessionEntryReferrerPolicyKey]); 99 [aDecoder decodeIntForKey:web::kSessionEntryReferrerPolicyKey]);
110 _navigationItem->SetReferrer( 100 _navigationItem->SetReferrer(
111 web::Referrer(GURL(referrerString), referrerPolicy)); 101 web::Referrer(GURL(referrerString), referrerPolicy));
112 } else { 102 } else {
113 // Backward compatibility. 103 // Backward compatibility.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 [aCoder encodeObject:_navigationItem->GetHttpRequestHeaders() 159 [aCoder encodeObject:_navigationItem->GetHttpRequestHeaders()
170 forKey:web::kSessionEntryHTTPRequestHeadersKey]; 160 forKey:web::kSessionEntryHTTPRequestHeadersKey];
171 } 161 }
172 162
173 // TODO(ios): Shall we overwrite EqualTo:? 163 // TODO(ios): Shall we overwrite EqualTo:?
174 164
175 - (instancetype)copyWithZone:(NSZone*)zone { 165 - (instancetype)copyWithZone:(NSZone*)zone {
176 CRWSessionEntry* copy = [[[self class] alloc] init]; 166 CRWSessionEntry* copy = [[[self class] alloc] init];
177 copy->_navigationItem.reset( 167 copy->_navigationItem.reset(
178 new web::NavigationItemImpl(*_navigationItem.get())); 168 new web::NavigationItemImpl(*_navigationItem.get()));
179 copy->_originalUrl = _originalUrl;
180 return copy; 169 return copy;
181 } 170 }
182 171
183 - (NSString*)description { 172 - (NSString*)description {
184 return [NSString 173 return [NSString
185 stringWithFormat: 174 stringWithFormat:
186 @"url:%@ originalurl:%@ title:%@ transition:%d displayState:%@ " 175 @"url:%@ originalurl:%@ title:%@ transition:%d displayState:%@ "
187 @"desktopUA:%d", 176 @"desktopUA:%d",
188 base::SysUTF8ToNSString(_navigationItem->GetURL().spec()), 177 base::SysUTF8ToNSString(_navigationItem->GetURL().spec()),
189 base::SysUTF8ToNSString(self.originalUrl.spec()), 178 base::SysUTF8ToNSString(
179 _navigationItem->GetOriginalRequestURL().spec()),
190 base::SysUTF16ToNSString(_navigationItem->GetTitle()), 180 base::SysUTF16ToNSString(_navigationItem->GetTitle()),
191 _navigationItem->GetTransitionType(), 181 _navigationItem->GetTransitionType(),
192 [[self class] descriptionForPageDisplayState: 182 [[self class]
193 _navigationItem->GetPageDisplayState()], 183 descriptionForPageDisplayState:_navigationItem
184 ->GetPageDisplayState()],
194 _navigationItem->IsOverridingUserAgent()]; 185 _navigationItem->IsOverridingUserAgent()];
195 } 186 }
196 187
197 - (web::NavigationItem*)navigationItem { 188 - (web::NavigationItem*)navigationItem {
198 return _navigationItem.get(); 189 return _navigationItem.get();
199 } 190 }
200 191
201 - (web::NavigationItemImpl*)navigationItemImpl { 192 - (web::NavigationItemImpl*)navigationItemImpl {
202 return _navigationItem.get(); 193 return _navigationItem.get();
203 } 194 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return 237 return
247 [NSString stringWithFormat:kPageScrollStateDescriptionFormat, 238 [NSString stringWithFormat:kPageScrollStateDescriptionFormat,
248 displayState.scroll_state().offset_x(), 239 displayState.scroll_state().offset_x(),
249 displayState.scroll_state().offset_y(), 240 displayState.scroll_state().offset_y(),
250 displayState.zoom_state().minimum_zoom_scale(), 241 displayState.zoom_state().minimum_zoom_scale(),
251 displayState.zoom_state().maximum_zoom_scale(), 242 displayState.zoom_state().maximum_zoom_scale(),
252 displayState.zoom_state().zoom_scale()]; 243 displayState.zoom_state().zoom_scale()];
253 } 244 }
254 245
255 @end 246 @end
OLDNEW
« no previous file with comments | « ios/web/navigation/crw_session_entry.h ('k') | ios/web/navigation/navigation_item_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698