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

Unified Diff: ios/chrome/browser/web/mailto_handler_gmail.mm

Issue 2852003002: Adds mailto: URL support to app launching. (Closed)
Patch Set: .grd message update Created 3 years, 8 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
Index: ios/chrome/browser/web/mailto_handler_gmail.mm
diff --git a/ios/chrome/browser/web/mailto_handler_gmail.mm b/ios/chrome/browser/web/mailto_handler_gmail.mm
new file mode 100644
index 0000000000000000000000000000000000000000..8833693fad61a0f5b6e694ce318f6fb43a855658
--- /dev/null
+++ b/ios/chrome/browser/web/mailto_handler_gmail.mm
@@ -0,0 +1,40 @@
+// Copyright 2017 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/web//mailto_handler_gmail.h"
+#include "base/strings/sys_string_conversions.h"
+#include "url/gurl.h"
+#include "url/url_constants.h"
+
+#import <UIKit/UIKit.h>
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@implementation MailtoHandlerGmail
+
+- (instancetype)init {
+ // Gmail product name is not supposed to be localized.
+ self = [super initWithName:@"Gmail" appStoreID:@"422689480"];
+ return self;
+}
+
+- (BOOL)isAvailable {
+ // Checks if Gmail app is installed on this device. This assumes that
+ // "googlegmail" has been whitelisted in Chrome's Info.plist.
+ return [[UIApplication sharedApplication]
+ canOpenURL:[NSURL URLWithString:@"googlegmail://"]];
+}
+
+- (NSString*)rewriteMailtoURL:(const GURL&)gURL {
jif 2017/05/03 13:01:35 Consider creating a function in the same vein as h
pkl (ping after 24h if needed) 2017/05/03 22:17:18 Instead, I moved this up to the base class so subc
+ if (!gURL.SchemeIs(url::kMailToScheme))
+ return nil;
+ NSString* recipient = base::SysUTF8ToNSString(gURL.path());
+ NSString* query = base::SysUTF8ToNSString(gURL.query());
+ return
+ [NSString stringWithFormat:@"googlegmail:/co?to=%@&%@", recipient, query];
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698