diff --git a/BrowserSimulator/BrowserSimulator.xcodeproj/project.pbxproj b/BrowserSimulator/BrowserSimulator.xcodeproj/project.pbxproj index 0e9a2e9..ad034f1 100644 --- a/BrowserSimulator/BrowserSimulator.xcodeproj/project.pbxproj +++ b/BrowserSimulator/BrowserSimulator.xcodeproj/project.pbxproj @@ -122,7 +122,6 @@ D132B941162766E100E4F30D /* NSURL+XCallbackURL.m */, D132B91C1627652F00E4F30D /* Supporting Files */, ); - name = BrowserSimulator; path = BrowserSimulator; sourceTree = ""; }; @@ -182,7 +181,7 @@ D132B9081627652F00E4F30D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0450; + LastUpgradeCheck = 0830; ORGANIZATIONNAME = "Google Inc."; }; buildConfigurationList = D132B90B1627652F00E4F30D /* Build configuration list for PBXProject "BrowserSimulator" */; @@ -284,22 +283,35 @@ ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -312,15 +324,27 @@ ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -334,7 +358,8 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "BrowserSimulator/BrowserSimulator-Prefix.pch"; INFOPLIST_FILE = "BrowserSimulator/BrowserSimulator-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = BrowserSimulator; WRAPPER_EXTENSION = app; }; @@ -346,7 +371,8 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "BrowserSimulator/BrowserSimulator-Prefix.pch"; INFOPLIST_FILE = "BrowserSimulator/BrowserSimulator-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = BrowserSimulator; WRAPPER_EXTENSION = app; }; diff --git a/BrowserSimulator/BrowserSimulator/BrowserSimulator-Info.plist b/BrowserSimulator/BrowserSimulator/BrowserSimulator-Info.plist index 8064fa7..7003b50 100644 --- a/BrowserSimulator/BrowserSimulator/BrowserSimulator-Info.plist +++ b/BrowserSimulator/BrowserSimulator/BrowserSimulator-Info.plist @@ -24,7 +24,7 @@ CFBundleIdentifier - com.google.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/BrowserSimulator/BrowserSimulator/BrowserSimulator-Prefix.pch b/BrowserSimulator/BrowserSimulator/BrowserSimulator-Prefix.pch index a8430ca..cbbf320 100644 --- a/BrowserSimulator/BrowserSimulator/BrowserSimulator-Prefix.pch +++ b/BrowserSimulator/BrowserSimulator/BrowserSimulator-Prefix.pch @@ -34,8 +34,8 @@ #import -#ifndef __IPHONE_4_0 -#warning "This project uses features only available in iOS SDK 4.0 and later." +#ifndef __IPHONE_7_0 +#warning "This project uses features only available in iOS SDK 7.0 and later." #endif #ifdef __OBJC__ diff --git a/BrowserSimulator/BrowserSimulator/FlipsideViewController.m b/BrowserSimulator/BrowserSimulator/FlipsideViewController.m index 07f60fd..3bf32a2 100644 --- a/BrowserSimulator/BrowserSimulator/FlipsideViewController.m +++ b/BrowserSimulator/BrowserSimulator/FlipsideViewController.m @@ -29,24 +29,11 @@ #import "FlipsideViewController.h" -@interface FlipsideViewController () - -@end - @implementation FlipsideViewController @synthesize textView = textView_; @synthesize delegate = delegate_; -- (id)initWithNibName:(NSString *)nibNameOrNil - bundle:(NSBundle *)nibBundleOrNil { - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - self.contentSizeForViewInPopover = CGSizeMake(320.0, 480.0); - } - return self; -} - - (void)dealloc { [textView_ release]; [super dealloc]; @@ -56,10 +43,14 @@ - (void)viewWillAppear:(BOOL)animated { self.textView.text = self.delegate.information; } +- (CGSize)preferredContentSize { + return CGSizeMake(320.0, 480.0); +} + #pragma mark - Actions - (IBAction)done:(id)sender { - [self.delegate flipsideViewControllerDidFinish:self]; + [self.delegate flipsideViewControllerDidFinish:self]; } @end diff --git a/BrowserSimulator/BrowserSimulator/MainViewController.m b/BrowserSimulator/BrowserSimulator/MainViewController.m index c7f6d99..246edf0 100644 --- a/BrowserSimulator/BrowserSimulator/MainViewController.m +++ b/BrowserSimulator/BrowserSimulator/MainViewController.m @@ -111,15 +111,15 @@ - (void)load:(NSURL *)url { [self.navigationBar setItems:[NSArray array] animated:NO]; UINavigationItem *item = - [[[UINavigationItem alloc] initWithTitle:nil] autorelease]; + [[[UINavigationItem alloc] initWithTitle:@""] autorelease]; item.title = self.sourceApp; [self.navigationBar pushNavigationItem:item animated:NO]; - item = [[[UINavigationItem alloc] initWithTitle:nil] autorelease]; + item = [[[UINavigationItem alloc] initWithTitle:@""] autorelease]; if (!self.sourceApp) { item.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"" - style:UIBarButtonItemStyleBordered + style:UIBarButtonItemStylePlain target:nil action:nil] autorelease]; } @@ -139,7 +139,7 @@ - (void)load:(NSURL *)url { UIBarButtonItem *infoButton = [[[UIBarButtonItem alloc] initWithTitle:@"Info" - style:UIBarButtonItemStyleBordered + style:UIBarButtonItemStylePlain target:self action:@selector(showInfo:)] autorelease]; diff --git a/OpenInChromeController.h b/OpenInChromeController.h index b6b6a13..218c051 100644 --- a/OpenInChromeController.h +++ b/OpenInChromeController.h @@ -34,20 +34,20 @@ @interface OpenInChromeController : NSObject // Returns a shared instance of the OpenInChromeController. -+ (OpenInChromeController *)sharedInstance; ++ (instancetype)sharedInstance; // Returns YES if Google Chrome is installed in the user's system. - (BOOL)isChromeInstalled; // Opens a URL in Google Chrome. -- (BOOL)openInChrome:(NSURL *)url; +- (BOOL)openInChrome:(NSURL *)URL; // iOS displays a "Back to app" link on the device's status line if app was // launched from another app. This makes the |callbackURL| parameter much less // useful. Chrome has stopped processing the callback URL and create new tab // options. // @warning DEPRECATED: Please use -openInChrome: directly. -- (BOOL)openInChrome:(NSURL *)url +- (BOOL)openInChrome:(NSURL *)URL withCallbackURL:(NSURL *)callbackURL createNewTab:(BOOL)createNewTab __attribute__((deprecated)); diff --git a/OpenInChromeController.m b/OpenInChromeController.m index b8cd374..d367273 100644 --- a/OpenInChromeController.m +++ b/OpenInChromeController.m @@ -35,12 +35,12 @@ #import "OpenInChromeController.h" -static NSString * const kGoogleChromeHTTPScheme = @"googlechrome:"; -static NSString * const kGoogleChromeHTTPSScheme = @"googlechromes:"; +static NSString * const kGoogleChromeHTTPScheme = @"googlechrome"; +static NSString * const kGoogleChromeHTTPSScheme = @"googlechromes"; @implementation OpenInChromeController -+ (OpenInChromeController *)sharedInstance { ++ (instancetype)sharedInstance { static OpenInChromeController *sharedInstance; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -50,41 +50,40 @@ + (OpenInChromeController *)sharedInstance { } - (BOOL)isChromeInstalled { - NSURL *simpleURL = [NSURL URLWithString:kGoogleChromeHTTPScheme]; - return [[UIApplication sharedApplication] canOpenURL:simpleURL]; + NSURLComponents *components = [[NSURLComponents alloc] init]; + components.scheme = kGoogleChromeHTTPScheme; + return [[UIApplication sharedApplication] canOpenURL:components.URL]; } -- (BOOL)openInChrome:(NSURL *)url { +- (BOOL)openInChrome:(NSURL *)URL { if ([self isChromeInstalled]) { - NSString *scheme = [url.scheme lowercaseString]; - // Replace the URL Scheme with the Chrome equivalent. + NSURLComponents *components = + [NSURLComponents componentsWithURL:URL resolvingAgainstBaseURL:YES]; + + NSString *scheme = components.scheme; + // Replace the URI Scheme with the Chrome equivalent. NSString *chromeScheme = nil; - if ([scheme isEqualToString:@"http"]) { + if ([scheme caseInsensitiveCompare:@"http"] == NSOrderedSame) { chromeScheme = kGoogleChromeHTTPScheme; - } else if ([scheme isEqualToString:@"https"]) { + } else if ([scheme caseInsensitiveCompare:@"https"] == NSOrderedSame) { chromeScheme = kGoogleChromeHTTPSScheme; } // Proceed only if a valid Google Chrome URI Scheme is available. if (chromeScheme) { - NSString *absoluteString = [url absoluteString]; - NSRange rangeForScheme = [absoluteString rangeOfString:@":"]; - NSString *urlNoScheme = - [absoluteString substringFromIndex:rangeForScheme.location + 1]; - NSString *chromeURLString = - [chromeScheme stringByAppendingString:urlNoScheme]; - NSURL *chromeURL = [NSURL URLWithString:chromeURLString]; + components.scheme = chromeScheme; // Open the URL with Google Chrome. - return [[UIApplication sharedApplication] openURL:chromeURL]; + return [[UIApplication sharedApplication] openURL:components.URL]; } } return NO; } -- (BOOL)openInChrome:(NSURL *)url +- (BOOL)openInChrome:(NSURL *)URL withCallbackURL:(NSURL *)callbackURL createNewTab:(BOOL)createNewTab { // This deprecated API simply calls the supported -openInChrome: API. - return [self openInChrome:url]; + return [self openInChrome:URL]; } + @end diff --git a/OpenInChromeSampleApp/OpenInChromeSampleApp.xcodeproj/project.pbxproj b/OpenInChromeSampleApp/OpenInChromeSampleApp.xcodeproj/project.pbxproj index 164c617..f18ed5f 100644 --- a/OpenInChromeSampleApp/OpenInChromeSampleApp.xcodeproj/project.pbxproj +++ b/OpenInChromeSampleApp/OpenInChromeSampleApp.xcodeproj/project.pbxproj @@ -141,7 +141,7 @@ D1C1042D162FF67B0074F0BA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0450; + LastUpgradeCheck = 0830; ORGANIZATIONNAME = "Google Inc."; }; buildConfigurationList = D1C10430162FF67B0074F0BA /* Build configuration list for PBXProject "OpenInChromeSampleApp" */; @@ -225,22 +225,35 @@ ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -253,15 +266,27 @@ ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -278,6 +303,7 @@ GCC_PREFIX_HEADER = "OpenInChromeSampleApp/OpenInChromeSampleApp-Prefix.pch"; INFOPLIST_FILE = "OpenInChromeSampleApp/OpenInChromeSampleApp-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.mycompany.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; @@ -293,6 +319,7 @@ GCC_PREFIX_HEADER = "OpenInChromeSampleApp/OpenInChromeSampleApp-Prefix.pch"; INFOPLIST_FILE = "OpenInChromeSampleApp/OpenInChromeSampleApp-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.mycompany.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; diff --git a/OpenInChromeSampleApp/OpenInChromeSampleApp/OpenInChromeSampleApp-Info.plist b/OpenInChromeSampleApp/OpenInChromeSampleApp/OpenInChromeSampleApp-Info.plist index 6d3d283..10b3680 100644 --- a/OpenInChromeSampleApp/OpenInChromeSampleApp/OpenInChromeSampleApp-Info.plist +++ b/OpenInChromeSampleApp/OpenInChromeSampleApp/OpenInChromeSampleApp-Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.mycompany.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/README.md b/README.md index bc429de..905afe9 100644 --- a/README.md +++ b/README.md @@ -51,16 +51,10 @@ if ([scheme isEqualToString:@"http"]) { // Proceed only if a valid Google Chrome URI Scheme is available. if (chromeScheme) { - NSString *absoluteString = [inputURL absoluteString]; - NSRange rangeForScheme = [absoluteString rangeOfString:@":"]; - NSString *urlNoScheme = - [absoluteString substringFromIndex:rangeForScheme.location]; - NSString *chromeURLString = - [chromeScheme stringByAppendingString:urlNoScheme]; - NSURL *chromeURL = [NSURL URLWithString:chromeURLString]; - - // Open the URL with Chrome. - [[UIApplication sharedApplication] openURL:chromeURL]; + components.scheme = chromeScheme; + + // Open the URL with Google Chrome. + return [[UIApplication sharedApplication] openURL:components.URL]; } ```