Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Unified Diff: ios/chrome/browser/chrome_url_util.mm

Issue 2364373002: Removed some URL Utility functions & improved unit tests (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/chrome_url_util.h ('k') | ios/chrome/browser/chrome_url_util_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/chrome_url_util.mm
diff --git a/ios/chrome/browser/chrome_url_util.mm b/ios/chrome/browser/chrome_url_util.mm
index 40dff897e48377b68299b85709a2514339cdf6d5..1ba6a4e36f1ff1aaaebf9cdea94ae49a2ac0ecde 100644
--- a/ios/chrome/browser/chrome_url_util.mm
+++ b/ios/chrome/browser/chrome_url_util.mm
@@ -7,6 +7,7 @@
#import <UIKit/UIKit.h>
#include "base/logging.h"
+#include "base/mac/foundation_util.h"
#include "base/mac/scoped_block.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/string_util.h"
@@ -22,19 +23,6 @@ bool UrlIsExternalFileReference(const GURL& url) {
base::LowerCaseEqualsASCII(url.host(), kChromeUIExternalFileHost);
}
-NSURL* UrlToLaunchChrome() {
- // Determines the target URL scheme that will launch Chrome.
- NSString* scheme = [[ChromeAppConstants sharedInstance] getBundleURLScheme];
- return [NSURL URLWithString:[NSString stringWithFormat:@"%@://", scheme]];
-}
-
-NSURL* UrlOfChromeAppIcon(int width, int height) {
- NSString* url =
- [[ChromeAppConstants sharedInstance] getChromeAppIconURLOfWidth:width
- height:height];
- return [NSURL URLWithString:url];
-}
-
bool UrlHasChromeScheme(const GURL& url) {
return url.SchemeIs(kChromeUIScheme);
}
@@ -56,7 +44,6 @@ bool IsHandledProtocol(const std::string& scheme) {
@implementation ChromeAppConstants {
base::scoped_nsobject<NSString> _callbackScheme;
- base::mac::ScopedBlock<AppIconURLProvider> _appIconURLProvider;
}
+ (ChromeAppConstants*)sharedInstance {
@@ -67,15 +54,14 @@ bool IsHandledProtocol(const std::string& scheme) {
- (NSString*)getBundleURLScheme {
if (!_callbackScheme) {
NSSet* allowableSchemes =
- [NSSet setWithObjects:@"googlechrome", @"chromium", nil];
+ [NSSet setWithObjects:@"googlechrome", @"chromium",
+ @"ios-chrome-unittests.http", nil];
NSDictionary* info = [[NSBundle mainBundle] infoDictionary];
NSArray* urlTypes = [info objectForKey:@"CFBundleURLTypes"];
for (NSDictionary* urlType in urlTypes) {
DCHECK([urlType isKindOfClass:[NSDictionary class]]);
- NSArray* schemes = [urlType objectForKey:@"CFBundleURLSchemes"];
- if (!schemes)
- continue;
- DCHECK([schemes isKindOfClass:[NSArray class]]);
+ NSArray* schemes =
+ base::mac::ObjCCastStrict<NSArray>(urlType[@"CFBundleURLSchemes"]);
for (NSString* scheme in schemes) {
if ([allowableSchemes containsObject:scheme])
_callbackScheme.reset([scheme copy]);
@@ -86,27 +72,8 @@ bool IsHandledProtocol(const std::string& scheme) {
return _callbackScheme;
}
-- (NSString*)getChromeAppIconURLOfWidth:(int)width height:(int)height {
- if (!_appIconURLProvider) {
- // TODO(ios): iOS code should default to "Chromium" branding.
- // http://crbug.com/489270
- _appIconURLProvider.reset(^(int width, int height) {
- return [NSString
- stringWithFormat:@"https://%@/Icon-%dx%d-%dx.png",
- @"ssl.gstatic.com/ios-apps/com.google.chrome.ios",
- width, height,
- [[UIScreen mainScreen] scale] == 1.0 ? 1 : 2];
- }, base::scoped_policy::RETAIN);
- }
- return _appIconURLProvider.get()(width, height);
-}
-
- (void)setCallbackSchemeForTesting:(NSString*)scheme {
_callbackScheme.reset([scheme copy]);
}
-- (void)setAppIconURLProviderForTesting:(AppIconURLProvider)block {
- _appIconURLProvider.reset(block, base::scoped_policy::RETAIN);
-}
-
@end
« no previous file with comments | « ios/chrome/browser/chrome_url_util.h ('k') | ios/chrome/browser/chrome_url_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698