Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "ios/chrome/browser/web//mailto_handler_gmail.h" | |
| 6 #include "base/strings/sys_string_conversions.h" | |
| 7 #include "url/gurl.h" | |
| 8 #include "url/url_constants.h" | |
| 9 | |
| 10 #import <UIKit/UIKit.h> | |
| 11 | |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 13 #error "This file requires ARC support." | |
| 14 #endif | |
| 15 | |
| 16 @implementation MailtoHandlerGmail | |
| 17 | |
| 18 - (instancetype)init { | |
| 19 // Gmail product name is not supposed to be localized. | |
| 20 self = [super initWithName:@"Gmail" appStoreID:@"422689480"]; | |
| 21 return self; | |
| 22 } | |
| 23 | |
| 24 - (BOOL)isAvailable { | |
| 25 // Checks if Gmail app is installed on this device. This assumes that | |
| 26 // "googlegmail" has been whitelisted in Chrome's Info.plist. | |
| 27 return [[UIApplication sharedApplication] | |
| 28 canOpenURL:[NSURL URLWithString:@"googlegmail://"]]; | |
| 29 } | |
| 30 | |
| 31 - (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
| |
| 32 if (!gURL.SchemeIs(url::kMailToScheme)) | |
| 33 return nil; | |
| 34 NSString* recipient = base::SysUTF8ToNSString(gURL.path()); | |
| 35 NSString* query = base::SysUTF8ToNSString(gURL.query()); | |
| 36 return | |
| 37 [NSString stringWithFormat:@"googlegmail:/co?to=%@&%@", recipient, query]; | |
| 38 } | |
| 39 | |
| 40 @end | |
| OLD | NEW |