OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/geolocation/network_location_request.h" | 5 #include "content/browser/geolocation/network_location_request.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 // If the network provider was unable to provide a position fix, it should | 402 // If the network provider was unable to provide a position fix, it should |
403 // return a HTTP 200, with "location" : null. Otherwise it's an error. | 403 // return a HTTP 200, with "location" : null. Otherwise it's an error. |
404 return false; | 404 return false; |
405 } | 405 } |
406 return true; // Successfully parsed response containing no fix. | 406 return true; // Successfully parsed response containing no fix. |
407 } | 407 } |
408 const base::DictionaryValue* location_object = | 408 const base::DictionaryValue* location_object = |
409 static_cast<const base::DictionaryValue*>(location_value); | 409 static_cast<const base::DictionaryValue*>(location_value); |
410 | 410 |
411 // latitude and longitude fields are always required. | 411 // latitude and longitude fields are always required. |
412 double latitude, longitude; | 412 double latitude = 0; |
| 413 double longitude = 0; |
413 if (!GetAsDouble(*location_object, kLatitudeString, &latitude) || | 414 if (!GetAsDouble(*location_object, kLatitudeString, &latitude) || |
414 !GetAsDouble(*location_object, kLongitudeString, &longitude)) { | 415 !GetAsDouble(*location_object, kLongitudeString, &longitude)) { |
415 VLOG(1) << "ParseServerResponse() : location lacks lat and/or long."; | 416 VLOG(1) << "ParseServerResponse() : location lacks lat and/or long."; |
416 return false; | 417 return false; |
417 } | 418 } |
418 // All error paths covered: now start actually modifying postion. | 419 // All error paths covered: now start actually modifying postion. |
419 position->latitude = latitude; | 420 position->latitude = latitude; |
420 position->longitude = longitude; | 421 position->longitude = longitude; |
421 position->timestamp = timestamp; | 422 position->timestamp = timestamp; |
422 | 423 |
423 // Other fields are optional. | 424 // Other fields are optional. |
424 GetAsDouble(*response_object, kAccuracyString, &position->accuracy); | 425 GetAsDouble(*response_object, kAccuracyString, &position->accuracy); |
425 | 426 |
426 return true; | 427 return true; |
427 } | 428 } |
428 | 429 |
429 } // namespace | 430 } // namespace |
430 | 431 |
431 } // namespace content | 432 } // namespace content |
OLD | NEW |