| 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 "components/spellcheck/browser/spelling_service_client.h" | 5 #include "components/spellcheck/browser/spelling_service_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // "error": { | 189 // "error": { |
| 190 // "code": 400, | 190 // "code": 400, |
| 191 // "message": "Bad Request", | 191 // "message": "Bad Request", |
| 192 // "data": [...] | 192 // "data": [...] |
| 193 // } | 193 // } |
| 194 // } | 194 // } |
| 195 std::unique_ptr<base::DictionaryValue> value( | 195 std::unique_ptr<base::DictionaryValue> value( |
| 196 static_cast<base::DictionaryValue*>( | 196 static_cast<base::DictionaryValue*>( |
| 197 base::JSONReader::Read(data, base::JSON_ALLOW_TRAILING_COMMAS) | 197 base::JSONReader::Read(data, base::JSON_ALLOW_TRAILING_COMMAS) |
| 198 .release())); | 198 .release())); |
| 199 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) | 199 if (!value.get() || !value->IsType(base::Value::Type::DICTIONARY)) |
| 200 return false; | 200 return false; |
| 201 | 201 |
| 202 // Check for errors from spelling service. | 202 // Check for errors from spelling service. |
| 203 base::DictionaryValue* error = NULL; | 203 base::DictionaryValue* error = NULL; |
| 204 if (value->GetDictionary(kErrorPath, &error)) | 204 if (value->GetDictionary(kErrorPath, &error)) |
| 205 return false; | 205 return false; |
| 206 | 206 |
| 207 // Retrieve the array of Misspelling objects. When the input text does not | 207 // Retrieve the array of Misspelling objects. When the input text does not |
| 208 // have misspelled words, it returns an empty JSON. (In this case, its HTTP | 208 // have misspelled words, it returns an empty JSON. (In this case, its HTTP |
| 209 // status is 200.) We just return true for this case. | 209 // status is 200.) We just return true for this case. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 265 |
| 266 // The callback may release the last (transitive) dependency on |this|. It | 266 // The callback may release the last (transitive) dependency on |this|. It |
| 267 // MUST be the last function called. | 267 // MUST be the last function called. |
| 268 callback_data->callback.Run(success, callback_data->text, results); | 268 callback_data->callback.Run(success, callback_data->text, results); |
| 269 } | 269 } |
| 270 | 270 |
| 271 std::unique_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher( | 271 std::unique_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher( |
| 272 const GURL& url) { | 272 const GURL& url) { |
| 273 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); | 273 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); |
| 274 } | 274 } |
| OLD | NEW |