| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef IOS_CHROME_BROWSER_WEB_MAILTO_URL_REWRITER_H_ | 5 #ifndef IOS_CHROME_BROWSER_WEB_MAILTO_URL_REWRITER_H_ |
| 6 #define IOS_CHROME_BROWSER_WEB_MAILTO_URL_REWRITER_H_ | 6 #define IOS_CHROME_BROWSER_WEB_MAILTO_URL_REWRITER_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 @class MailtoHandler; | 10 @class MailtoHandler; |
| 11 @class MailtoURLRewriter; | 11 @class MailtoURLRewriter; |
| 12 class GURL; | 12 class GURL; |
| 13 | 13 |
| 14 // Protocol that must be implemented by observers of MailtoURLRewriter object. | 14 // Protocol that must be implemented by observers of MailtoURLRewriter object. |
| 15 @protocol MailtoURLRewriterObserver<NSObject> | 15 @protocol MailtoURLRewriterObserver<NSObject> |
| 16 // The default mailto: handler has been changed. | 16 // The default mailto: handler has been changed. |
| 17 - (void)rewriterDidChange:(MailtoURLRewriter*)rewriter; | 17 - (void)rewriterDidChange:(MailtoURLRewriter*)rewriter; |
| 18 @end | 18 @end |
| 19 | 19 |
| 20 // An object that manages the available Mail client apps. The currently selected | 20 // An object that manages the available Mail client apps. The currently selected |
| 21 // Mail client to handle mailto: URL is stored in a key in NSUserDefaults. | 21 // Mail client to handle mailto: URL is stored in a key in NSUserDefaults. |
| 22 // If the key in NSUserDefaults is not set, the system-provided Mail client app | 22 // If the key in NSUserDefaults is not set or the corresponding app is no longer |
| 23 // will be used. | 23 // installed, the system-provided Mail client app will be used. |
| 24 @interface MailtoURLRewriter : NSObject | 24 @interface MailtoURLRewriter : NSObject |
| 25 | 25 |
| 26 // The unique ID of the Mail client app was set to handle mailto: URL scheme. | 26 // The unique ID of the Mail client app that handles mailto: URL scheme. |
| 27 @property(nonatomic, copy) NSString* defaultHandlerID; | 27 @property(nonatomic, copy) NSString* defaultHandlerID; |
| 28 | 28 |
| 29 // Observer object that will be called when |defaultHandlerID| is changed. | 29 // Observer object that will be called when |defaultHandlerID| is changed. |
| 30 @property(nonatomic, weak) id<MailtoURLRewriterObserver> observer; | 30 @property(nonatomic, weak) id<MailtoURLRewriterObserver> observer; |
| 31 | 31 |
| 32 // Returns the ID as a string for the system-provided Mail client app. | 32 // Returns the ID as a string for the system-provided Mail client app. |
| 33 + (NSString*)systemMailApp; | 33 + (NSString*)systemMailApp; |
| 34 | 34 |
| 35 // An initializer returning an instance that has the standard set of | 35 // An initializer returning an instance that has the standard set of |
| 36 // MailtoHandlers initialized. Unit tests can use -init and then set up the | 36 // MailtoHandlers initialized. Unit tests can use -init and then set up the |
| 37 // different handlers. | 37 // different handlers. |
| 38 - (instancetype)initWithStandardHandlers; | 38 - (instancetype)initWithStandardHandlers; |
| 39 | 39 |
| 40 // Returns a sorted array of all the currently supported Mail client apps that | 40 // Returns a sorted array of all the currently supported Mail client apps that |
| 41 // claim to handle mailto: URL scheme through their own custom defined URL | 41 // claim to handle mailto: URL scheme through their own custom defined URL |
| 42 // schemes. | 42 // schemes. |
| 43 - (NSArray<MailtoHandler*>*)defaultHandlers; | 43 - (NSArray<MailtoHandler*>*)defaultHandlers; |
| 44 | 44 |
| 45 // Returns the name of the application that handles mailto: URLs. | 45 // Returns the name of the application that handles mailto: URLs. |
| 46 - (NSString*)defaultHandlerName; | 46 - (NSString*)defaultHandlerName; |
| 47 | 47 |
| 48 // Rewrites |gURL| into a new URL that can be "opened" to launch the Mail | 48 // Rewrites |gURL| into a new URL that can be "opened" to launch the Mail |
| 49 // client app. May return nil if |gURL| is not a mailto: URL or there are no | 49 // client app. May return nil if |gURL| is not a mailto: URL or there are no |
| 50 // Mail client app available. | 50 // Mail client app available. |
| 51 - (NSString*)rewriteMailtoURL:(const GURL&)gURL; | 51 - (NSString*)rewriteMailtoURL:(const GURL&)gURL; |
| 52 | 52 |
| 53 @end | 53 @end |
| 54 | 54 |
| 55 #endif // IOS_CHROME_BROWSER_WEB_MAILTO_URL_REWRITER_H_ | 55 #endif // IOS_CHROME_BROWSER_WEB_MAILTO_URL_REWRITER_H_ |
| OLD | NEW |