Index: ios/chrome/browser/open_url_util.mm |
diff --git a/ios/chrome/browser/open_url_util.mm b/ios/chrome/browser/open_url_util.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..288336a01bb911a7e4486686998ff548e989f04b |
--- /dev/null |
+++ b/ios/chrome/browser/open_url_util.mm |
@@ -0,0 +1,25 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#import "ios/chrome/browser/open_url_util.h" |
+ |
+#import <UIKit/UIKit.h> |
+ |
+#include "base/ios/ios_util.h" |
+ |
+void OpenUrlWithCompletionHandler(NSURL* url, |
+ void (^completion_handler)(BOOL success)) { |
+ if (base::ios::IsRunningOnIOS10OrLater()) { |
+ [[UIApplication sharedApplication] openURL:url |
+ options:@{} |
+ completionHandler:completion_handler]; |
+ } else { |
+ BOOL result = [[UIApplication sharedApplication] openURL:url]; |
+ if (!completion_handler) |
+ return; |
+ dispatch_async(dispatch_get_main_queue(), ^{ |
+ completion_handler(result); |
+ }); |
+ } |
+} |