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

Side by Side Diff: ios/chrome/browser/geolocation/omnibox_geolocation_config.mm

Issue 2551423002: [ios] Safely handle non-existent plists in OmniboxGeolocationConfig. (Closed)
Patch Set: Add comments. Created 4 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #import "ios/chrome/browser/geolocation/omnibox_geolocation_config.h" 5 #import "ios/chrome/browser/geolocation/omnibox_geolocation_config.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return NO; 60 return NO;
61 } 61 }
62 62
63 #pragma mark - Private 63 #pragma mark - Private
64 64
65 - (void)loadConfigFile:(NSString*)plistFileName { 65 - (void)loadConfigFile:(NSString*)plistFileName {
66 NSString* path = [[NSBundle mainBundle] pathForResource:plistFileName 66 NSString* path = [[NSBundle mainBundle] pathForResource:plistFileName
67 ofType:@"plist" 67 ofType:@"plist"
68 inDirectory:@"gm-config/ANY"]; 68 inDirectory:@"gm-config/ANY"];
69 NSDictionary* configData = [NSDictionary dictionaryWithContentsOfFile:path]; 69 NSDictionary* configData = [NSDictionary dictionaryWithContentsOfFile:path];
70 if (!configData) {
71 // The plist is not packaged with Chromium builds. This is not an error, so
72 // simply return early, since no domains are eligible for geolocation.
73 return;
74 }
75
70 NSArray* eligibleDomains = base::mac::ObjCCastStrict<NSArray>( 76 NSArray* eligibleDomains = base::mac::ObjCCastStrict<NSArray>(
71 [configData objectForKey:kEligibleDomainsKey]); 77 [configData objectForKey:kEligibleDomainsKey]);
72 if (eligibleDomains) { 78 if (eligibleDomains) {
73 for (id item in eligibleDomains) { 79 for (id item in eligibleDomains) {
74 NSString* domain = base::mac::ObjCCastStrict<NSString>(item); 80 NSString* domain = base::mac::ObjCCastStrict<NSString>(item);
75 if ([domain length]) { 81 if ([domain length]) {
76 _eligibleDomains.insert( 82 _eligibleDomains.insert(
77 base::SysNSStringToUTF8([domain lowercaseString])); 83 base::SysNSStringToUTF8([domain lowercaseString]));
78 } 84 }
79 } 85 }
80 } 86 }
87 // Make sure that if a plist exists, it contains at least one eligible domain.
81 DCHECK(!_eligibleDomains.empty()); 88 DCHECK(!_eligibleDomains.empty());
82 } 89 }
83 90
84 @end 91 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698