Skip to content

Commit

Permalink
[Siri Shortcuts] Correctly check for searchPhrase existence
Browse files Browse the repository at this point in the history
The previous way of checking whether the searchPhrase property existed
on the SearchInChrome intent object was respondsToSelector:, which
didn't work.

This fix uses valueForKey: instead, which appears to be a safe way to
check whether searchPhrase exists on the intent object.

Bug: 1133825
Change-Id: I82242e2398359f1955fd93b06ecdc4648fcaf5df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2459566
Commit-Queue: Guillaume Jenkins <gujen@google.com>
Reviewed-by: Mark Cogan <marq@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815703}
  • Loading branch information
guillaumejenkins authored and Commit Bot committed Oct 9, 2020
1 parent c1b7eba commit fa5125e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ios/chrome/app/application_delegate/user_activity_handler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,15 @@ + (BOOL)continueUserActivity:(NSUserActivity*)userActivity
base::mac::ObjCCastStrict<SearchInChromeIntent>(
userActivity.interaction.intent);

if (intent &&
[intent respondsToSelector:NSSelectorFromString(@"searchPhrase")] &&
intent.searchPhrase && [intent.searchPhrase length]) {
startupParams.textQuery = intent.searchPhrase;
if (!intent) {
return NO;
}

id searchPhrase = [intent valueForKey:@"searchPhrase"];

if ([searchPhrase isKindOfClass:[NSString class]] &&
[searchPhrase length]) {
startupParams.textQuery = searchPhrase;
} else {
startupParams.postOpeningAction = FOCUS_OMNIBOX;
}
Expand Down

0 comments on commit fa5125e

Please sign in to comment.