Chromium Code Reviews| 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 () { | 15 @interface XCallbackParameters () { |
| 14 base::scoped_nsobject<NSString> _sourceAppId; | 16 NSString* _sourceAppId; |
|
sdefresne
2016/12/12 19:37:01
This can probably be synthesized too.
stkhapugin
2016/12/13 13:31:11
Done.
| |
| 15 } | 17 } |
| 16 @end | 18 @end |
| 17 | 19 |
| 18 @implementation XCallbackParameters | 20 @implementation XCallbackParameters |
| 19 | 21 |
| 20 - (instancetype)initWithSourceAppId:(NSString*)sourceAppId { | 22 - (instancetype)initWithSourceAppId:(NSString*)sourceAppId { |
| 21 self = [super init]; | 23 self = [super init]; |
| 22 if (self) { | 24 if (self) { |
| 23 _sourceAppId.reset([sourceAppId copy]); | 25 _sourceAppId = [sourceAppId copy]; |
| 24 } | 26 } |
| 25 return self; | 27 return self; |
| 26 } | 28 } |
| 27 | 29 |
| 28 - (NSString*)description { | 30 - (NSString*)description { |
| 29 return [NSString stringWithFormat:@"SourceApp: %@\n", _sourceAppId.get()]; | 31 return [NSString stringWithFormat:@"SourceApp: %@\n", _sourceAppId]; |
| 30 } | 32 } |
| 31 | 33 |
| 32 - (NSString*)sourceAppId { | 34 - (NSString*)sourceAppId { |
| 33 return _sourceAppId.get(); | 35 return _sourceAppId; |
| 34 } | 36 } |
| 35 | 37 |
| 36 #pragma mark - NSCoding Methods | 38 #pragma mark - NSCoding Methods |
| 37 | 39 |
| 38 - (instancetype)initWithCoder:(NSCoder*)aDecoder { | 40 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
| 39 return | 41 return |
| 40 [self initWithSourceAppId:[aDecoder decodeObjectForKey:kSourceAppIdKey]]; | 42 [self initWithSourceAppId:[aDecoder decodeObjectForKey:kSourceAppIdKey]]; |
| 41 } | 43 } |
| 42 | 44 |
| 43 - (void)encodeWithCoder:(NSCoder*)aCoder { | 45 - (void)encodeWithCoder:(NSCoder*)aCoder { |
| 44 [aCoder encodeObject:_sourceAppId forKey:kSourceAppIdKey]; | 46 [aCoder encodeObject:_sourceAppId forKey:kSourceAppIdKey]; |
| 45 } | 47 } |
| 46 | 48 |
| 47 #pragma mark - NSCopying Methods | 49 #pragma mark - NSCopying Methods |
| 48 | 50 |
| 49 - (instancetype)copyWithZone:(NSZone*)zone { | 51 - (instancetype)copyWithZone:(NSZone*)zone { |
| 50 return [[[self class] allocWithZone:zone] initWithSourceAppId:_sourceAppId]; | 52 return [[[self class] allocWithZone:zone] initWithSourceAppId:_sourceAppId]; |
| 51 } | 53 } |
| 52 | 54 |
| 53 @end | 55 @end |
| OLD | NEW |