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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/geolocation/omnibox_geolocation_config.mm
diff --git a/ios/chrome/browser/geolocation/omnibox_geolocation_config.mm b/ios/chrome/browser/geolocation/omnibox_geolocation_config.mm
index f411c1a74083ea4a4d39ab300c65be3d57705a42..687f6e3fda26afb62605d040998f09e6bb8bbd7d 100644
--- a/ios/chrome/browser/geolocation/omnibox_geolocation_config.mm
+++ b/ios/chrome/browser/geolocation/omnibox_geolocation_config.mm
@@ -67,6 +67,12 @@ NSString* const kEligibleDomainsKey = @"EligibleDomains";
ofType:@"plist"
inDirectory:@"gm-config/ANY"];
NSDictionary* configData = [NSDictionary dictionaryWithContentsOfFile:path];
+ if (!configData) {
+ // The plist is not packaged with Chromium builds. This is not an error, so
+ // simply return early, since no domains are eligible for geolocation.
+ return;
+ }
+
NSArray* eligibleDomains = base::mac::ObjCCastStrict<NSArray>(
[configData objectForKey:kEligibleDomainsKey]);
if (eligibleDomains) {
@@ -78,6 +84,7 @@ NSString* const kEligibleDomainsKey = @"EligibleDomains";
}
}
}
+ // Make sure that if a plist exists, it contains at least one eligible domain.
DCHECK(!_eligibleDomains.empty());
}
« 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