Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 #if !defined(__has_feature) || !__has_feature(objc_arc) | 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 6 #error "This file requires ARC support." | 6 #error "This file requires ARC support." |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #import "remoting/client/ios/host_preferences.h" | 9 #import "remoting/client/ios/host_preferences.h" |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 | 37 |
| 38 - (void)saveToKeychain { | 38 - (void)saveToKeychain { |
| 39 NSMutableDictionary* hosts = [HostPreferences loadHosts]; | 39 NSMutableDictionary* hosts = [HostPreferences loadHosts]; |
| 40 [hosts setObject:self forKey:_hostId]; | 40 [hosts setObject:self forKey:_hostId]; |
| 41 | 41 |
| 42 NSData* writeData = [NSKeyedArchiver archivedDataWithRootObject:hosts]; | 42 NSData* writeData = [NSKeyedArchiver archivedDataWithRootObject:hosts]; |
| 43 | 43 |
| 44 NSError* keychainError = | 44 NSError* keychainError = |
| 45 remoting::ios::WriteHostPreferencesToKeychain(writeData); | 45 remoting::ios::WriteHostPreferencesToKeychain(writeData); |
| 46 | 46 |
| 47 DLOG_IF(ERROR, !keychainError) << "Could not write to keychain."; | 47 LOG_IF(ERROR, !keychainError) << "Could not write to keychain."; |
|
sdefresne
2017/04/12 15:26:28
Can't you use the "ignore_result" macro instead?
| |
| 48 } | 48 } |
| 49 | 49 |
| 50 + (HostPreferences*)hostForId:(NSString*)hostId { | 50 + (HostPreferences*)hostForId:(NSString*)hostId { |
| 51 NSMutableDictionary* hosts = [HostPreferences loadHosts]; | 51 NSMutableDictionary* hosts = [HostPreferences loadHosts]; |
| 52 HostPreferences* host = hosts[hostId]; | 52 HostPreferences* host = hosts[hostId]; |
| 53 if (!host) { | 53 if (!host) { |
| 54 host = [[HostPreferences alloc] init]; | 54 host = [[HostPreferences alloc] init]; |
| 55 host.hostId = hostId; | 55 host.hostId = hostId; |
| 56 host.pairId = @""; | 56 host.pairId = @""; |
| 57 host.pairSecret = @""; | 57 host.pairSecret = @""; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 83 return self; | 83 return self; |
| 84 } | 84 } |
| 85 | 85 |
| 86 - (void)encodeWithCoder:(NSCoder*)coder { | 86 - (void)encodeWithCoder:(NSCoder*)coder { |
| 87 [coder encodeObject:_hostId forKey:kHostPreferencesHostIdKey]; | 87 [coder encodeObject:_hostId forKey:kHostPreferencesHostIdKey]; |
| 88 [coder encodeObject:_pairId forKey:kHostPreferencesPairIdKey]; | 88 [coder encodeObject:_pairId forKey:kHostPreferencesPairIdKey]; |
| 89 [coder encodeObject:_pairSecret forKey:kHostPreferencesPairSecretKey]; | 89 [coder encodeObject:_pairSecret forKey:kHostPreferencesPairSecretKey]; |
| 90 } | 90 } |
| 91 | 91 |
| 92 @end | 92 @end |
| OLD | NEW |