NSString* type_ns = [NSString stringWithUTF8String:type.c_str()];
NSUserActivity* user_activity = [[NSUserActivity alloc] initWithActivityType:type_ns];
- NSMutableDictionary* user_info_args = [[NSMutableDictionary alloc] init];
+ base::scoped_nsobject<NSMutableDictionary> user_info_args([[NSMutableDictionary alloc] init]);
for (auto const &pair : user_info) {
NSString* value_ns = [NSString stringWithUTF8String:pair.second.c_str()];
NSString* key_ns = [NSString stringWithUTF8String:pair.first.c_str()];
- [user_info_args setObject:value_ns
- forKey:key_ns];
+ [user_info_args.get() setObject:value_ns
+ forKey:key_ns];
}
- user_activity.userInfo = user_info_args;
+ user_activity.userInfo = user_info_args.get();
[user_activity becomeCurrent];
[[AtomApplication sharedApplication] setCurrentActivity:user_activity];
// found in the LICENSE file.
#import "base/mac/scoped_sending_event.h"
+#import "base/mac/scoped_nsobject.h"
@interface AtomApplication : NSApplication<CrAppProtocol,
CrAppControlProtocol> {
@private
BOOL handlingSendEvent_;
- NSUserActivity* currentActivity_;
+ base::scoped_nsobject<NSUserActivity> currentActivity_;
}
+ (AtomApplication*)sharedApplication;
}
- (void)setCurrentActivity:(NSUserActivity*)userActivity {
- currentActivity_ = userActivity;
+ currentActivity_ = base::scoped_nsobject<NSUserActivity>(userActivity);
}
- (NSUserActivity*)getCurrentActivity {
- return currentActivity_;
+ return currentActivity_.get();
}
- (void)awakeFromNib {
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
std::map<std::string, std::string> user_info;
+ base::scoped_nsobject<NSArray> keys([userActivity.userInfo allKeys]);
- NSArray* keys = [userActivity.userInfo allKeys];
- for (NSString* key in keys) {
+ for (NSString* key in keys.get()) {
NSString* value = [userActivity.userInfo objectForKey:key];
std::string key_str(base::SysNSStringToUTF8(key));
std::string value_str(base::SysNSStringToUTF8(value));