aboutsummaryrefslogtreecommitdiff
path: root/src/client/mac
diff options
context:
space:
mode:
authorRoman Margold <rmargold@chromium.org>2017-02-04 16:45:51 -0800
committerRoman Margold <rmargold@chromium.org>2017-03-10 18:30:14 +0000
commitdac2223398fc46611523bcfa0b8e26d576b1cd9e (patch)
tree46d860f8f9529e5603d2dd4d66ee7bc3e2a79b27 /src/client/mac
parentUse NSURLSession if the min version we support is iOS 7+. (diff)
downloadbreakpad-dac2223398fc46611523bcfa0b8e26d576b1cd9e.tar.xz
iOS client identifies itself via URL params
For iOS apps, product and version information is now automatically provided as part of the crash report upload URL to allow for early rejections. Change-Id: Ia19c490c38023f9e23ec8a537f7a203ff1e642d7 Reviewed-on: https://chromium-review.googlesource.com/436164 Reviewed-by: Roman Margold <rmargold@chromium.org> Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Diffstat (limited to 'src/client/mac')
-rw-r--r--src/client/mac/sender/uploader.mm44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/client/mac/sender/uploader.mm b/src/client/mac/sender/uploader.mm
index 42a43bfc..c74c0583 100644
--- a/src/client/mac/sender/uploader.mm
+++ b/src/client/mac/sender/uploader.mm
@@ -168,6 +168,12 @@ NSDictionary *readConfigurationData(const char *configFile) {
// Records the uploaded crash ID to the log file.
- (void)logUploadWithID:(const char *)uploadID;
+
+// Builds an URL parameter for a given dictionary key. Uses Uploader's
+// parameters to provide its value. Returns nil if no item is stored for the
+// given key.
+- (NSURLQueryItem *)queryItemWithName:(NSString *)queryItemName
+ forParamKey:(NSString *)key;
@end
@implementation Uploader
@@ -532,8 +538,46 @@ NSDictionary *readConfigurationData(const char *configFile) {
}
//=============================================================================
+- (NSURLQueryItem *)queryItemWithName:(NSString *)queryItemName
+ forParamKey:(NSString *)key {
+ NSString *value = [parameters_ objectForKey:key];
+ NSString *escapedValue =
+ [value stringByAddingPercentEncodingWithAllowedCharacters:
+ [NSCharacterSet URLQueryAllowedCharacterSet]];
+ return [NSURLQueryItem queryItemWithName:queryItemName value:escapedValue];
+}
+
+//=============================================================================
- (void)report {
NSURL *url = [NSURL URLWithString:[parameters_ objectForKey:@BREAKPAD_URL]];
+
+ NSString *serverType = [parameters_ objectForKey:@BREAKPAD_SERVER_TYPE];
+ if ([serverType length] == 0 ||
+ [serverType isEqualToString:kGoogleServerType]) {
+ // when communicating to Google's crash collecting service, add URL params
+ // which identify the product
+ NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:url
+ resolvingAgainstBaseURL:false];
+ NSMutableArray *queryItemsToAdd = [urlComponents.queryItems mutableCopy];
+ if (queryItemsToAdd == nil) {
+ queryItemsToAdd = [[NSMutableArray alloc] init];
+ }
+
+ NSURLQueryItem *queryItemProduct =
+ [self queryItemWithName:@"product" forParamKey:@BREAKPAD_PRODUCT];
+ NSURLQueryItem *queryItemVersion =
+ [self queryItemWithName:@"version" forParamKey:@BREAKPAD_VERSION];
+ NSURLQueryItem *queryItemGuid =
+ [self queryItemWithName:@"guid" forParamKey:@"guid"];
+
+ if (queryItemProduct != nil) [queryItemsToAdd addObject:queryItemProduct];
+ if (queryItemVersion != nil) [queryItemsToAdd addObject:queryItemVersion];
+ if (queryItemGuid != nil) [queryItemsToAdd addObject:queryItemGuid];
+
+ urlComponents.queryItems = queryItemsToAdd;
+ url = [urlComponents URL];
+ }
+
HTTPMultipartUpload *upload = [[HTTPMultipartUpload alloc] initWithURL:url];
NSMutableDictionary *uploadParameters = [NSMutableDictionary dictionary];