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

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: Removed extra release 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
19 #if !defined(__has_feature) || !__has_feature(objc_arc)
20 #error "This file requires ARC support."
21 #endif
22
20 namespace web { 23 namespace web {
21 // Keys used to serialize web::PageScrollState properties. 24 // Keys used to serialize web::PageScrollState properties.
22 NSString* const kSessionEntryPageScrollStateKey = @"state"; 25 NSString* const kSessionEntryPageScrollStateKey = @"state";
23 NSString* const kSessionEntryScrollOffsetXKey = @"scrollX"; 26 NSString* const kSessionEntryScrollOffsetXKey = @"scrollX";
24 NSString* const kSessionEntryScrollOffsetYKey = @"scrollY"; 27 NSString* const kSessionEntryScrollOffsetYKey = @"scrollY";
25 NSString* const kSessionEntryMinimumZoomScaleKey = @"minZoom"; 28 NSString* const kSessionEntryMinimumZoomScaleKey = @"minZoom";
26 NSString* const kSessionEntryMaximumZoomScaleKey = @"maxZoom"; 29 NSString* const kSessionEntryMaximumZoomScaleKey = @"maxZoom";
27 NSString* const kSessionEntryZoomScaleKey = @"zoom"; 30 NSString* const kSessionEntryZoomScaleKey = @"zoom";
28 31
29 // Keys used to serialize navigation properties. 32 // Keys used to serialize navigation properties.
(...skipping 13 matching lines...) Expand all
43 46
44 @interface CRWSessionEntry () { 47 @interface CRWSessionEntry () {
45 // The original URL of the page. In cases where a redirect occurred, |url_| 48 // 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 49 // will contain the final post-redirect URL, and |originalUrl_| will contain
47 // the pre-redirect URL. This field is not persisted to disk. 50 // the pre-redirect URL. This field is not persisted to disk.
48 GURL _originalUrl; 51 GURL _originalUrl;
49 52
50 // The NavigationItemImpl corresponding to this CRWSessionEntry. 53 // The NavigationItemImpl corresponding to this CRWSessionEntry.
51 // TODO(stuartmorgan): Move ownership to NavigationManagerImpl. 54 // TODO(stuartmorgan): Move ownership to NavigationManagerImpl.
52 std::unique_ptr<web::NavigationItemImpl> _navigationItem; 55 std::unique_ptr<web::NavigationItemImpl> _navigationItem;
53
54 base::mac::ObjCPropertyReleaser _propertyReleaser_CRWSessionEntry;
55 } 56 }
56 // Redefine originalUrl to be read-write. 57 // Redefine originalUrl to be read-write.
57 @property(nonatomic, readwrite) const GURL& originalUrl; 58 @property(nonatomic, readwrite) const GURL& originalUrl;
58 59
59 // Converts a serialized NSDictionary to a web::PageDisplayState. 60 // Converts a serialized NSDictionary to a web::PageDisplayState.
60 + (web::PageDisplayState)pageDisplayStateFromDictionary: 61 + (web::PageDisplayState)pageDisplayStateFromDictionary:
61 (NSDictionary*)dictionary; 62 (NSDictionary*)dictionary;
62 // Serializes a web::PageDisplayState to an NSDictionary. 63 // Serializes a web::PageDisplayState to an NSDictionary.
63 + (NSDictionary*)dictionaryFromPageDisplayState: 64 + (NSDictionary*)dictionaryFromPageDisplayState:
64 (const web::PageDisplayState&)displayState; 65 (const web::PageDisplayState&)displayState;
65 // Returns a readable description of |displayState|. 66 // Returns a readable description of |displayState|.
66 + (NSString*)descriptionForPageDisplayState: 67 + (NSString*)descriptionForPageDisplayState:
67 (const web::PageDisplayState&)displayState; 68 (const web::PageDisplayState&)displayState;
68 @end 69 @end
69 70
70 @implementation CRWSessionEntry 71 @implementation CRWSessionEntry
71 72
72 @synthesize originalUrl = _originalUrl; 73 @synthesize originalUrl = _originalUrl;
73 74
74 - (instancetype)initWithNavigationItem: 75 - (instancetype)initWithNavigationItem:
75 (std::unique_ptr<web::NavigationItem>)item { 76 (std::unique_ptr<web::NavigationItem>)item {
76 self = [super init]; 77 self = [super init];
77 if (self) { 78 if (self) {
78 _propertyReleaser_CRWSessionEntry.Init(self, [CRWSessionEntry class]);
79 _navigationItem.reset( 79 _navigationItem.reset(
80 static_cast<web::NavigationItemImpl*>(item.release())); 80 static_cast<web::NavigationItemImpl*>(item.release()));
81 self.originalUrl = _navigationItem->GetURL(); 81 self.originalUrl = _navigationItem->GetURL();
82 } 82 }
83 return self; 83 return self;
84 } 84 }
85 85
86 - (instancetype)initWithCoder:(NSCoder*)aDecoder { 86 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
87 self = [super init]; 87 self = [super init];
88 if (self) { 88 if (self) {
89 _propertyReleaser_CRWSessionEntry.Init(self, [CRWSessionEntry class]);
90 _navigationItem.reset(new web::NavigationItemImpl()); 89 _navigationItem.reset(new web::NavigationItemImpl());
91 90
92 // Desktop chrome only persists virtualUrl_ and uses it to feed the url 91 // Desktop chrome only persists virtualUrl_ and uses it to feed the url
93 // when creating a NavigationEntry. 92 // when creating a NavigationEntry.
94 GURL url; 93 GURL url;
95 if ([aDecoder containsValueForKey:web::kSessionEntryURLKey]) { 94 if ([aDecoder containsValueForKey:web::kSessionEntryURLKey]) {
96 url = GURL( 95 url = GURL(
97 web::nscoder_util::DecodeString(aDecoder, web::kSessionEntryURLKey)); 96 web::nscoder_util::DecodeString(aDecoder, web::kSessionEntryURLKey));
98 } else { 97 } else {
99 // Backward compatibility. 98 // Backward compatibility.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 [aCoder encodeObject:_navigationItem->GetPostData() 167 [aCoder encodeObject:_navigationItem->GetPostData()
169 forKey:web::kSessionEntryPOSTDataKey]; 168 forKey:web::kSessionEntryPOSTDataKey];
170 [aCoder encodeObject:_navigationItem->GetHttpRequestHeaders() 169 [aCoder encodeObject:_navigationItem->GetHttpRequestHeaders()
171 forKey:web::kSessionEntryHTTPRequestHeadersKey]; 170 forKey:web::kSessionEntryHTTPRequestHeadersKey];
172 } 171 }
173 172
174 // TODO(ios): Shall we overwrite EqualTo:? 173 // TODO(ios): Shall we overwrite EqualTo:?
175 174
176 - (instancetype)copyWithZone:(NSZone*)zone { 175 - (instancetype)copyWithZone:(NSZone*)zone {
177 CRWSessionEntry* copy = [[[self class] alloc] init]; 176 CRWSessionEntry* copy = [[[self class] alloc] init];
178 copy->_propertyReleaser_CRWSessionEntry.Init(copy, [CRWSessionEntry class]);
179 copy->_navigationItem.reset( 177 copy->_navigationItem.reset(
180 new web::NavigationItemImpl(*_navigationItem.get())); 178 new web::NavigationItemImpl(*_navigationItem.get()));
181 copy->_originalUrl = _originalUrl; 179 copy->_originalUrl = _originalUrl;
182 return copy; 180 return copy;
183 } 181 }
184 182
185 - (NSString*)description { 183 - (NSString*)description {
186 return [NSString 184 return [NSString
187 stringWithFormat: 185 stringWithFormat:
188 @"url:%@ originalurl:%@ title:%@ transition:%d displayState:%@ " 186 @"url:%@ originalurl:%@ title:%@ transition:%d displayState:%@ "
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return 246 return
249 [NSString stringWithFormat:kPageScrollStateDescriptionFormat, 247 [NSString stringWithFormat:kPageScrollStateDescriptionFormat,
250 displayState.scroll_state().offset_x(), 248 displayState.scroll_state().offset_x(),
251 displayState.scroll_state().offset_y(), 249 displayState.scroll_state().offset_y(),
252 displayState.zoom_state().minimum_zoom_scale(), 250 displayState.zoom_state().minimum_zoom_scale(),
253 displayState.zoom_state().maximum_zoom_scale(), 251 displayState.zoom_state().maximum_zoom_scale(),
254 displayState.zoom_state().zoom_scale()]; 252 displayState.zoom_state().zoom_scale()];
255 } 253 }
256 254
257 @end 255 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698