OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/geolocation/network_location_request.h" | 5 #include "chrome/browser/geolocation/network_location_request.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 url_fetcher_->set_upload_data(kMimeApplicationJson, post_body); | 109 url_fetcher_->set_upload_data(kMimeApplicationJson, post_body); |
110 url_fetcher_->set_request_context(url_context_); | 110 url_fetcher_->set_request_context(url_context_); |
111 url_fetcher_->set_load_flags( | 111 url_fetcher_->set_load_flags( |
112 net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | | 112 net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | |
113 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES | | 113 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES | |
114 net::LOAD_DO_NOT_SEND_AUTH_DATA); | 114 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
115 url_fetcher_->Start(); | 115 url_fetcher_->Start(); |
116 return true; | 116 return true; |
117 } | 117 } |
118 | 118 |
119 void NetworkLocationRequest::OnURLFetchComplete(const URLFetcher* source, | 119 void NetworkLocationRequest::OnURLFetchComplete( |
120 const GURL& url, | 120 const URLFetcher* source, |
121 const URLRequestStatus& status, | 121 const GURL& url, |
122 int response_code, | 122 const net::URLRequestStatus& status, |
123 const ResponseCookies& cookies, | 123 int response_code, |
124 const std::string& data) { | 124 const ResponseCookies& cookies, |
| 125 const std::string& data) { |
125 DCHECK_EQ(url_fetcher_.get(), source); | 126 DCHECK_EQ(url_fetcher_.get(), source); |
126 DCHECK(url_.possibly_invalid_spec() == url.possibly_invalid_spec()); | 127 DCHECK(url_.possibly_invalid_spec() == url.possibly_invalid_spec()); |
127 | 128 |
128 Geoposition position; | 129 Geoposition position; |
129 string16 access_token; | 130 string16 access_token; |
130 GetLocationFromResponse(status.is_success(), response_code, data, | 131 GetLocationFromResponse(status.is_success(), response_code, data, |
131 timestamp_, url, &position, &access_token); | 132 timestamp_, url, &position, &access_token); |
132 const bool server_error = | 133 const bool server_error = |
133 !status.is_success() || (response_code >= 500 && response_code < 600); | 134 !status.is_success() || (response_code >= 500 && response_code < 600); |
134 url_fetcher_.reset(); | 135 url_fetcher_.reset(); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 gateway_data.router_data.begin(); | 443 gateway_data.router_data.begin(); |
443 iter != gateway_data.router_data.end(); | 444 iter != gateway_data.router_data.end(); |
444 iter++) { | 445 iter++) { |
445 DictionaryValue* gateway = new DictionaryValue; | 446 DictionaryValue* gateway = new DictionaryValue; |
446 AddString("mac_address", iter->mac_address, gateway); | 447 AddString("mac_address", iter->mac_address, gateway); |
447 gateways->Append(gateway); | 448 gateways->Append(gateway); |
448 } | 449 } |
449 body_object->Set("gateways", gateways); | 450 body_object->Set("gateways", gateways); |
450 } | 451 } |
451 } // namespace | 452 } // namespace |
OLD | NEW |