Save the activity on the application instance to ensure we hold a reference. Activities that enable search need to persist.

This commit is contained in:
Charlie Hess 2016-05-03 14:57:16 -07:00
parent a5a2e20449
commit 42768bcc2b
3 changed files with 16 additions and 1 deletions

View file

@ -89,7 +89,7 @@ void Browser::SetAppUserModelID(const base::string16& name) {
void Browser::SetUserActivity(const std::string& type, const std::map<std::string, std::string>& user_info) {
NSString* type_ns = [NSString stringWithUTF8String:type.c_str()];
NSUserActivity *user_activity = [[NSUserActivity alloc] initWithActivityType:type_ns];
NSUserActivity* user_activity = [[NSUserActivity alloc] initWithActivityType:type_ns];
NSMutableArray* user_info_args = [[NSMutableArray alloc] init];
for (auto const &pair : user_info) {
@ -102,6 +102,8 @@ void Browser::SetUserActivity(const std::string& type, const std::map<std::strin
user_activity.userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:user_info_args, nil];
[user_activity becomeCurrent];
[[AtomApplication sharedApplication] setUserActivity:user_activity];
}
std::string Browser::GetExecutableFileVersion() const {

View file

@ -8,6 +8,7 @@
CrAppControlProtocol> {
@private
BOOL handlingSendEvent_;
NSUserActivity* currentActivity_;
}
+ (AtomApplication*)sharedApplication;
@ -18,4 +19,8 @@
// CrAppControlProtocol:
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
- (NSUserActivity*)getCurrentActivity;
- (void)setCurrentActivity:(NSUserActivity*)userActivity;
@end

View file

@ -28,6 +28,14 @@
handlingSendEvent_ = handlingSendEvent;
}
- (void)setCurrentActivity:(NSUserActivity*)userActivity {
currentActivity_ = userActivity;
}
- (NSUserActivity*)getCurrentActivity {
return currentActivity_;
}
- (void)awakeFromNib {
[[NSAppleEventManager sharedAppleEventManager]
setEventHandler:self