Skip to content

Commit

Permalink
[iOS][omnibox] Parse App Store links as URLs in AutocompleteInput.
Browse files Browse the repository at this point in the history
* Expands IsHandledProtocol() to include App Store links.
* Moves the app store scheme detector from one util file to another.

Fixed: 1421474
Change-Id: Ief4c10f85beff6cde54fb88c8681f43d335e9e2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4324679
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: Mark Cogan <marq@chromium.org>
Auto-Submit: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1115599}
  • Loading branch information
Stepan Khapugin authored and Chromium LUCI CQ committed Mar 10, 2023
1 parent ad9570b commit 0a9136a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 53 deletions.
2 changes: 0 additions & 2 deletions ios/chrome/browser/app_launcher/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ source_set("app_launcher") {
"app_launcher_tab_helper.h",
"app_launcher_tab_helper.mm",
"app_launcher_tab_helper_delegate.h",
"app_launcher_util.h",
"app_launcher_util.mm",
"app_launching_state.h",
"app_launching_state.mm",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#import "base/functional/bind.h"
#import "base/metrics/histogram_macros.h"
#import "ios/chrome/browser/app_launcher/app_launcher_tab_helper.h"
#import "ios/chrome/browser/app_launcher/app_launcher_util.h"
#import "ios/chrome/browser/mailto_handler/mailto_handler_service.h"
#import "ios/chrome/browser/mailto_handler/mailto_handler_service_factory.h"
#import "ios/chrome/browser/main/browser.h"
Expand All @@ -17,6 +16,7 @@
#import "ios/chrome/browser/overlays/public/overlay_request_queue.h"
#import "ios/chrome/browser/overlays/public/overlay_response.h"
#import "ios/chrome/browser/overlays/public/web_content_area/app_launcher_overlay.h"
#import "ios/chrome/browser/url/url_util.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
#import "ios/chrome/browser/web_state_list/web_state_opener.h"
#import "ios/web/public/navigation/navigation_manager.h"
Expand Down
18 changes: 0 additions & 18 deletions ios/chrome/browser/app_launcher/app_launcher_util.h

This file was deleted.

31 changes: 0 additions & 31 deletions ios/chrome/browser/app_launcher/app_launcher_util.mm

This file was deleted.

9 changes: 9 additions & 0 deletions ios/chrome/browser/url/url_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ bool ShouldLoadUrlInDesktopMode(const GURL& url,
// Method to set the scheme to callback Chrome iOS for testing.
- (void)setCallbackSchemeForTesting:(NSString*)callbackScheme;

// Returns a set of NSStrings that are URL schemes for iTunes Stores.
NSSet<NSString*>* GetItmsSchemes();

// Returns whether `url` has an app store scheme.
bool UrlHasAppStoreScheme(const GURL& url);

// Returns whether `scheme` is an app store scheme.
bool SchemeIsAppStoreScheme(const std::string& scheme);

@end

#endif // IOS_CHROME_BROWSER_URL_URL_UTIL_H_
24 changes: 23 additions & 1 deletion ios/chrome/browser/url/url_util.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bool IsHandledProtocol(const std::string& scheme) {
DCHECK_EQ(scheme, base::ToLowerASCII(scheme));
return (scheme == url::kHttpScheme || scheme == url::kHttpsScheme ||
scheme == url::kAboutScheme || scheme == url::kDataScheme ||
scheme == kChromeUIScheme);
scheme == kChromeUIScheme || SchemeIsAppStoreScheme(scheme));
}

bool ShouldLoadUrlInDesktopMode(const GURL& url,
Expand Down Expand Up @@ -104,4 +104,26 @@ - (void)setCallbackSchemeForTesting:(NSString*)scheme {
_callbackScheme = [scheme copy];
}

NSSet<NSString*>* GetItmsSchemes() {
static NSSet<NSString*>* schemes;
static dispatch_once_t once;
dispatch_once(&once, ^{
schemes = [NSSet<NSString*>
setWithObjects:@"itms", @"itmss", @"itms-apps", @"itms-appss",
// There's no evidence that itms-bookss is actually
// supported, but over-inclusion costs less than
// under-inclusion.
@"itms-books", @"itms-bookss", nil];
});
return schemes;
}

bool UrlHasAppStoreScheme(const GURL& url) {
return SchemeIsAppStoreScheme(url.scheme());
}

bool SchemeIsAppStoreScheme(const std::string& scheme) {
return [GetItmsSchemes() containsObject:base::SysUTF8ToNSString(scheme)];
}

@end

0 comments on commit 0a9136a

Please sign in to comment.