OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 #ifndef IOS_CHROME_APP_CHROME_APP_STARTUP_PARAMETERS_H_ |
| 6 #define IOS_CHROME_APP_CHROME_APP_STARTUP_PARAMETERS_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 #import "ios/chrome/browser/app_startup_parameters.h" |
| 11 #import "ios/chrome/browser/first_run/first_run_metrics.h" |
| 12 |
| 13 // Values of the UMA Startup.MobileSessionCallerApp histogram. |
| 14 enum MobileSessionCallerApp { |
| 15 CALLER_APP_GOOGLE_SEARCH = 0, |
| 16 CALLER_APP_GOOGLE_GMAIL, |
| 17 CALLER_APP_GOOGLE_PLUS, |
| 18 CALLER_APP_GOOGLE_DRIVE, |
| 19 CALLER_APP_GOOGLE_EARTH, |
| 20 CALLER_APP_GOOGLE_OTHER, |
| 21 CALLER_APP_OTHER, |
| 22 CALLER_APP_APPLE_MOBILESAFARI, |
| 23 CALLER_APP_APPLE_OTHER, |
| 24 CALLER_APP_GOOGLE_YOUTUBE, |
| 25 CALLER_APP_GOOGLE_MAPS, |
| 26 CALLER_APP_NOT_AVAILABLE, // Includes being launched from Smart App Banner. |
| 27 CALLER_APP_GOOGLE_CHROME_TODAY_EXTENSION, |
| 28 MOBILE_SESSION_CALLER_APP_COUNT, |
| 29 }; |
| 30 |
| 31 @interface ChromeAppStartupParameters : AppStartupParameters |
| 32 |
| 33 - (instancetype)initWithExternalURL:(const GURL&)externalURL |
| 34 xCallbackParameters:(XCallbackParameters*)xCallbackParameters |
| 35 NS_UNAVAILABLE; |
| 36 |
| 37 - (instancetype)initWithExternalURL:(const GURL&)externalURL |
| 38 xCallbackParameters:(XCallbackParameters*)xCallbackParameters |
| 39 declaredSourceApp:(NSString*)declaredSourceApp |
| 40 secureSourceApp:(NSString*)secureSourceApp |
| 41 completeURL:(NSURL*)completeURL |
| 42 NS_DESIGNATED_INITIALIZER; |
| 43 |
| 44 // Returns a ChromeAppStartupParameters instance containing the URL to |
| 45 // open (|externalURL|). In case the URL is conforming to the x-callback-url |
| 46 // specification, additional information are stored in the returned value. |
| 47 // |
| 48 // The forms of the URLs we expect are: |
| 49 // |
| 50 // - protocol0://url/goes/here |
| 51 // Here protocol0s opens the app. The string for the |
| 52 // parsed URL is "url/goes/here" with protocol |
| 53 // "http", that is, the string for the parsed URL is |
| 54 // "http://url/goes/here" |
| 55 // |
| 56 // - protocol0s://url/goes/here |
| 57 // Here protocol0s opens the app. The string for the |
| 58 // parsed URL is "url/goes/here" with protocol |
| 59 // "https", that is, the string for the parsed URL is |
| 60 // "https://url/goes/here" |
| 61 // |
| 62 // - url/goes/here |
| 63 // No protocol is given. The string for the parsed URL is |
| 64 // "url/goes/here", with protocol defaulting to "http", |
| 65 // that is, the string for the parsed URL is |
| 66 // "http://url/goes/here" |
| 67 // |
| 68 // - file://url/goes/here |
| 69 // Here the received URL is a file. This is used in cases where the app |
| 70 // receives a file from another app. The string for the parser URL is |
| 71 // "chrome://external-file/url/goes/here" |
| 72 // |
| 73 // - x-<protocol>://x-callback-url/<action>?url=<url/goes/here> |
| 74 // This forms is compliant with x-callback-url (x-callback-url.com). |
| 75 // Currently the only action supported for external application is "open" and |
| 76 // the only required parameter is |url| containing the url to open inclusive |
| 77 // of protocol. |
| 78 // For application members of the Chrome Application Group, |
| 79 // "app-group-command" command can be used. In that case, the paramaters are |
| 80 // sent via the shared NSUserDefault dictionary. |
| 81 // |
| 82 // Note the protocol isn't hardcoded so we accept anything. Moreover, in iOS 6 |
| 83 // SmartAppBanners can send any URL to the app without even needing the app |
| 84 // to be registered for that protocol. |
| 85 // If the string for the parsed URL is malformed (according to RFC 2396), |
| 86 // returns nil. |
| 87 + (instancetype)newChromeAppStartupParametersWithURL:(NSURL*)url |
| 88 fromSourceApplication:(NSString*)appId; |
| 89 |
| 90 // Returns the MobileSessionCallerApp for the given bundle ID. |
| 91 - (MobileSessionCallerApp)callerApp; |
| 92 |
| 93 // Checks the parsed url and heuristically determine if it implies that the |
| 94 // current openURL: delegate call is the result of a user click on Smart App |
| 95 // Banner. |
| 96 - (first_run::ExternalLaunch)launchSource; |
| 97 |
| 98 @end |
| 99 |
| 100 @interface ChromeAppStartupParameters (Testing) |
| 101 |
| 102 + (instancetype)newAppStartupParametersForCommand:(NSString*)command |
| 103 withParameter:(id)parameter |
| 104 withURL:(NSURL*)url |
| 105 fromSourceApplication:(NSString*)appId |
| 106 fromSecureSourceApplication:(NSString*)secureSourceApp; |
| 107 |
| 108 @end |
| 109 |
| 110 #endif // IOS_CHROME_APP_CHROME_APP_STARTUP_PARAMETERS_H_ |
OLD | NEW |