OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/sessions/session_ios.h" |
| 6 |
| 7 #import "base/mac/foundation_util.h" |
| 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." |
| 11 #endif |
| 12 |
| 13 namespace { |
| 14 // Serialization keys |
| 15 NSString* const kSessionWindowsKey = @"sessionWindows"; |
| 16 } // namespace |
| 17 |
| 18 @implementation SessionIOS |
| 19 |
| 20 @synthesize sessionWindows = _sessionWindows; |
| 21 |
| 22 #pragma mark - Public interface. |
| 23 |
| 24 - (instancetype)initWithWindows:(NSArray<SessionWindowIOS*>*)sessionWindows { |
| 25 DCHECK(sessionWindows); |
| 26 if ((self = [super init])) { |
| 27 _sessionWindows = sessionWindows; |
| 28 } |
| 29 return self; |
| 30 } |
| 31 |
| 32 #pragma mark - NSObject |
| 33 |
| 34 - (instancetype)init { |
| 35 return [self initWithWindows:@[]]; |
| 36 } |
| 37 |
| 38 #pragma mark - NSCoding |
| 39 |
| 40 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
| 41 NSArray<SessionWindowIOS*>* sessionWindows = |
| 42 base::mac::ObjCCast<NSArray<SessionWindowIOS*>>( |
| 43 [aDecoder decodeObjectForKey:kSessionWindowsKey]); |
| 44 |
| 45 return [self initWithWindows:(sessionWindows ? sessionWindows : @[])]; |
| 46 } |
| 47 |
| 48 - (void)encodeWithCoder:(NSCoder*)aCoder { |
| 49 [aCoder encodeObject:_sessionWindows forKey:kSessionWindowsKey]; |
| 50 } |
| 51 |
| 52 @end |
OLD | NEW |