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

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

Issue 2202623002: Converts parts of ios/web to ARC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 4 years, 4 months 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
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
11 #include "base/mac/objc_property_releaser.h"
12 #include "base/mac/scoped_nsobject.h" 11 #include "base/mac/scoped_nsobject.h"
13 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
14 #include "ios/web/navigation/navigation_item_impl.h" 13 #include "ios/web/navigation/navigation_item_impl.h"
15 #include "ios/web/navigation/nscoder_util.h" 14 #include "ios/web/navigation/nscoder_util.h"
16 #include "ios/web/public/navigation_item.h" 15 #include "ios/web/public/navigation_item.h"
17 #include "ios/web/public/web_state/page_display_state.h" 16 #include "ios/web/public/web_state/page_display_state.h"
18 #import "net/base/mac/url_conversions.h" 17 #import "net/base/mac/url_conversions.h"
19 18
20 namespace web { 19 namespace web {
21 // Keys used to serialize web::PageScrollState properties. 20 // Keys used to serialize web::PageScrollState properties.
(...skipping 21 matching lines...) Expand all
43 42
44 @interface CRWSessionEntry () { 43 @interface CRWSessionEntry () {
45 // The original URL of the page. In cases where a redirect occurred, |url_| 44 // The original URL of the page. In cases where a redirect occurred, |url_|
46 // will contain the final post-redirect URL, and |originalUrl_| will contain 45 // will contain the final post-redirect URL, and |originalUrl_| will contain
47 // the pre-redirect URL. This field is not persisted to disk. 46 // the pre-redirect URL. This field is not persisted to disk.
48 GURL _originalUrl; 47 GURL _originalUrl;
49 48
50 // The NavigationItemImpl corresponding to this CRWSessionEntry. 49 // The NavigationItemImpl corresponding to this CRWSessionEntry.
51 // TODO(stuartmorgan): Move ownership to NavigationManagerImpl. 50 // TODO(stuartmorgan): Move ownership to NavigationManagerImpl.
52 std::unique_ptr<web::NavigationItemImpl> _navigationItem; 51 std::unique_ptr<web::NavigationItemImpl> _navigationItem;
53
54 base::mac::ObjCPropertyReleaser _propertyReleaser_CRWSessionEntry;
55 } 52 }
56 // Redefine originalUrl to be read-write. 53 // Redefine originalUrl to be read-write.
57 @property(nonatomic, readwrite) const GURL& originalUrl; 54 @property(nonatomic, readwrite) const GURL& originalUrl;
58 55
59 // Converts a serialized NSDictionary to a web::PageDisplayState. 56 // Converts a serialized NSDictionary to a web::PageDisplayState.
60 + (web::PageDisplayState)pageDisplayStateFromDictionary: 57 + (web::PageDisplayState)pageDisplayStateFromDictionary:
61 (NSDictionary*)dictionary; 58 (NSDictionary*)dictionary;
62 // Serializes a web::PageDisplayState to an NSDictionary. 59 // Serializes a web::PageDisplayState to an NSDictionary.
63 + (NSDictionary*)dictionaryFromPageDisplayState: 60 + (NSDictionary*)dictionaryFromPageDisplayState:
64 (const web::PageDisplayState&)displayState; 61 (const web::PageDisplayState&)displayState;
65 // Returns a readable description of |displayState|. 62 // Returns a readable description of |displayState|.
66 + (NSString*)descriptionForPageDisplayState: 63 + (NSString*)descriptionForPageDisplayState:
67 (const web::PageDisplayState&)displayState; 64 (const web::PageDisplayState&)displayState;
68 @end 65 @end
69 66
70 @implementation CRWSessionEntry 67 @implementation CRWSessionEntry
71 68
72 @synthesize originalUrl = _originalUrl; 69 @synthesize originalUrl = _originalUrl;
73 70
74 - (instancetype)initWithNavigationItem: 71 - (instancetype)initWithNavigationItem:
75 (std::unique_ptr<web::NavigationItem>)item { 72 (std::unique_ptr<web::NavigationItem>)item {
76 self = [super init]; 73 self = [super init];
77 if (self) { 74 if (self) {
78 _propertyReleaser_CRWSessionEntry.Init(self, [CRWSessionEntry class]);
79 _navigationItem.reset( 75 _navigationItem.reset(
80 static_cast<web::NavigationItemImpl*>(item.release())); 76 static_cast<web::NavigationItemImpl*>(item.release()));
81 self.originalUrl = _navigationItem->GetURL(); 77 self.originalUrl = _navigationItem->GetURL();
82 } 78 }
83 return self; 79 return self;
84 } 80 }
85 81
86 - (instancetype)initWithCoder:(NSCoder*)aDecoder { 82 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
87 self = [super init]; 83 self = [super init];
88 if (self) { 84 if (self) {
89 _propertyReleaser_CRWSessionEntry.Init(self, [CRWSessionEntry class]);
90 _navigationItem.reset(new web::NavigationItemImpl()); 85 _navigationItem.reset(new web::NavigationItemImpl());
91 86
92 // Desktop chrome only persists virtualUrl_ and uses it to feed the url 87 // Desktop chrome only persists virtualUrl_ and uses it to feed the url
93 // when creating a NavigationEntry. 88 // when creating a NavigationEntry.
94 GURL url; 89 GURL url;
95 if ([aDecoder containsValueForKey:web::kSessionEntryURLKey]) { 90 if ([aDecoder containsValueForKey:web::kSessionEntryURLKey]) {
96 url = GURL( 91 url = GURL(
97 web::nscoder_util::DecodeString(aDecoder, web::kSessionEntryURLKey)); 92 web::nscoder_util::DecodeString(aDecoder, web::kSessionEntryURLKey));
98 } else { 93 } else {
99 // Backward compatibility. 94 // Backward compatibility.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 [aCoder encodeObject:_navigationItem->GetPostData() 163 [aCoder encodeObject:_navigationItem->GetPostData()
169 forKey:web::kSessionEntryPOSTDataKey]; 164 forKey:web::kSessionEntryPOSTDataKey];
170 [aCoder encodeObject:_navigationItem->GetHttpRequestHeaders() 165 [aCoder encodeObject:_navigationItem->GetHttpRequestHeaders()
171 forKey:web::kSessionEntryHTTPRequestHeadersKey]; 166 forKey:web::kSessionEntryHTTPRequestHeadersKey];
172 } 167 }
173 168
174 // TODO(ios): Shall we overwrite EqualTo:? 169 // TODO(ios): Shall we overwrite EqualTo:?
175 170
176 - (instancetype)copyWithZone:(NSZone*)zone { 171 - (instancetype)copyWithZone:(NSZone*)zone {
177 CRWSessionEntry* copy = [[[self class] alloc] init]; 172 CRWSessionEntry* copy = [[[self class] alloc] init];
178 copy->_propertyReleaser_CRWSessionEntry.Init(copy, [CRWSessionEntry class]);
179 copy->_navigationItem.reset( 173 copy->_navigationItem.reset(
180 new web::NavigationItemImpl(*_navigationItem.get())); 174 new web::NavigationItemImpl(*_navigationItem.get()));
181 copy->_originalUrl = _originalUrl; 175 copy->_originalUrl = _originalUrl;
182 return copy; 176 return copy;
183 } 177 }
184 178
185 - (NSString*)description { 179 - (NSString*)description {
186 return [NSString 180 return [NSString
187 stringWithFormat: 181 stringWithFormat:
188 @"url:%@ originalurl:%@ title:%@ transition:%d displayState:%@ " 182 @"url:%@ originalurl:%@ title:%@ transition:%d displayState:%@ "
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return 242 return
249 [NSString stringWithFormat:kPageScrollStateDescriptionFormat, 243 [NSString stringWithFormat:kPageScrollStateDescriptionFormat,
250 displayState.scroll_state().offset_x(), 244 displayState.scroll_state().offset_x(),
251 displayState.scroll_state().offset_y(), 245 displayState.scroll_state().offset_y(),
252 displayState.zoom_state().minimum_zoom_scale(), 246 displayState.zoom_state().minimum_zoom_scale(),
253 displayState.zoom_state().maximum_zoom_scale(), 247 displayState.zoom_state().maximum_zoom_scale(),
254 displayState.zoom_state().zoom_scale()]; 248 displayState.zoom_state().zoom_scale()];
255 } 249 }
256 250
257 @end 251 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698