| OLD | NEW |
| 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/chrome/browser/xcallback_parameters.h" | 5 #import "ios/chrome/browser/xcallback_parameters.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 8 #error "This file requires ARC support." |
| 9 #endif |
| 8 | 10 |
| 9 namespace { | 11 namespace { |
| 10 NSString* const kSourceAppIdKey = @"sourceAppId"; | 12 NSString* const kSourceAppIdKey = @"sourceAppId"; |
| 11 } | 13 } |
| 12 | 14 |
| 13 @interface XCallbackParameters () { | |
| 14 base::scoped_nsobject<NSString> _sourceAppId; | |
| 15 } | |
| 16 @end | |
| 17 | |
| 18 @implementation XCallbackParameters | 15 @implementation XCallbackParameters |
| 16 @synthesize sourceAppId = _sourceAppId; |
| 19 | 17 |
| 20 - (instancetype)initWithSourceAppId:(NSString*)sourceAppId { | 18 - (instancetype)initWithSourceAppId:(NSString*)sourceAppId { |
| 21 self = [super init]; | 19 self = [super init]; |
| 22 if (self) { | 20 if (self) { |
| 23 _sourceAppId.reset([sourceAppId copy]); | 21 _sourceAppId = [sourceAppId copy]; |
| 24 } | 22 } |
| 25 return self; | 23 return self; |
| 26 } | 24 } |
| 27 | 25 |
| 28 - (NSString*)description { | 26 - (NSString*)description { |
| 29 return [NSString stringWithFormat:@"SourceApp: %@\n", _sourceAppId.get()]; | 27 return [NSString stringWithFormat:@"SourceApp: %@\n", _sourceAppId]; |
| 30 } | |
| 31 | |
| 32 - (NSString*)sourceAppId { | |
| 33 return _sourceAppId.get(); | |
| 34 } | 28 } |
| 35 | 29 |
| 36 #pragma mark - NSCoding Methods | 30 #pragma mark - NSCoding Methods |
| 37 | 31 |
| 38 - (instancetype)initWithCoder:(NSCoder*)aDecoder { | 32 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
| 39 return | 33 return |
| 40 [self initWithSourceAppId:[aDecoder decodeObjectForKey:kSourceAppIdKey]]; | 34 [self initWithSourceAppId:[aDecoder decodeObjectForKey:kSourceAppIdKey]]; |
| 41 } | 35 } |
| 42 | 36 |
| 43 - (void)encodeWithCoder:(NSCoder*)aCoder { | 37 - (void)encodeWithCoder:(NSCoder*)aCoder { |
| 44 [aCoder encodeObject:_sourceAppId forKey:kSourceAppIdKey]; | 38 [aCoder encodeObject:_sourceAppId forKey:kSourceAppIdKey]; |
| 45 } | 39 } |
| 46 | 40 |
| 47 #pragma mark - NSCopying Methods | 41 #pragma mark - NSCopying Methods |
| 48 | 42 |
| 49 - (instancetype)copyWithZone:(NSZone*)zone { | 43 - (instancetype)copyWithZone:(NSZone*)zone { |
| 50 return [[[self class] allocWithZone:zone] initWithSourceAppId:_sourceAppId]; | 44 return [[[self class] allocWithZone:zone] initWithSourceAppId:_sourceAppId]; |
| 51 } | 45 } |
| 52 | 46 |
| 53 @end | 47 @end |
| OLD | NEW |