| 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/history/core/browser/web_history_service.h" | 5 #include "components/history/core/browser/web_history_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 const CompletionCallback& callback) { | 305 const CompletionCallback& callback) { |
| 306 return new RequestImpl(token_service_, signin_manager_, request_context_, url, | 306 return new RequestImpl(token_service_, signin_manager_, request_context_, url, |
| 307 callback); | 307 callback); |
| 308 } | 308 } |
| 309 | 309 |
| 310 // static | 310 // static |
| 311 scoped_ptr<base::DictionaryValue> WebHistoryService::ReadResponse( | 311 scoped_ptr<base::DictionaryValue> WebHistoryService::ReadResponse( |
| 312 WebHistoryService::Request* request) { | 312 WebHistoryService::Request* request) { |
| 313 scoped_ptr<base::DictionaryValue> result; | 313 scoped_ptr<base::DictionaryValue> result; |
| 314 if (request->GetResponseCode() == net::HTTP_OK) { | 314 if (request->GetResponseCode() == net::HTTP_OK) { |
| 315 base::Value* value = | 315 scoped_ptr<base::Value> value = |
| 316 base::JSONReader::DeprecatedRead(request->GetResponseBody()); | 316 base::JSONReader::Read(request->GetResponseBody()); |
| 317 if (value && value->IsType(base::Value::TYPE_DICTIONARY)) | 317 if (value.get() && value.get()->IsType(base::Value::TYPE_DICTIONARY)) |
| 318 result.reset(static_cast<base::DictionaryValue*>(value)); | 318 result.reset(static_cast<base::DictionaryValue*>(value.release())); |
| 319 else | 319 else |
| 320 DLOG(WARNING) << "Non-JSON response received from history server."; | 320 DLOG(WARNING) << "Non-JSON response received from history server."; |
| 321 } | 321 } |
| 322 return result.Pass(); | 322 return result.Pass(); |
| 323 } | 323 } |
| 324 | 324 |
| 325 scoped_ptr<WebHistoryService::Request> WebHistoryService::QueryHistory( | 325 scoped_ptr<WebHistoryService::Request> WebHistoryService::QueryHistory( |
| 326 const base::string16& text_query, | 326 const base::string16& text_query, |
| 327 const QueryOptions& options, | 327 const QueryOptions& options, |
| 328 const WebHistoryService::QueryWebHistoryCallback& callback) { | 328 const WebHistoryService::QueryWebHistoryCallback& callback) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 response_value->GetBoolean("history_recording_enabled", &enabled_value); | 479 response_value->GetBoolean("history_recording_enabled", &enabled_value); |
| 480 } | 480 } |
| 481 | 481 |
| 482 // If there is no response_value, then for our purposes, the request has | 482 // If there is no response_value, then for our purposes, the request has |
| 483 // failed, despite receiving a true |success| value. This can happen if | 483 // failed, despite receiving a true |success| value. This can happen if |
| 484 // the user is offline. | 484 // the user is offline. |
| 485 callback.Run(success && response_value, enabled_value); | 485 callback.Run(success && response_value, enabled_value); |
| 486 } | 486 } |
| 487 | 487 |
| 488 } // namespace history | 488 } // namespace history |
| OLD | NEW |