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 "chrome/browser/history/history_extension_api.h" | 5 #include "chrome/browser/history/history_extension_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 const history::URLRow* url_row, | 258 const history::URLRow* url_row, |
259 history::VisitVector* visits) { | 259 history::VisitVector* visits) { |
260 ListValue* list = new ListValue(); | 260 ListValue* list = new ListValue(); |
261 if (visits && !visits->empty()) { | 261 if (visits && !visits->empty()) { |
262 for (history::VisitVector::iterator iterator = visits->begin(); | 262 for (history::VisitVector::iterator iterator = visits->begin(); |
263 iterator != visits->end(); | 263 iterator != visits->end(); |
264 ++iterator) { | 264 ++iterator) { |
265 AddVisitNode(*iterator, list); | 265 AddVisitNode(*iterator, list); |
266 } | 266 } |
267 } | 267 } |
268 result_.reset(list); | 268 SetResult(list); |
269 SendAsyncResponse(); | 269 SendAsyncResponse(); |
270 } | 270 } |
271 | 271 |
272 bool SearchHistoryFunction::RunAsyncImpl() { | 272 bool SearchHistoryFunction::RunAsyncImpl() { |
273 DictionaryValue* json; | 273 DictionaryValue* json; |
274 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); | 274 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); |
275 | 275 |
276 // Initialize the HistoryQuery | 276 // Initialize the HistoryQuery |
277 string16 search_text; | 277 string16 search_text; |
278 EXTENSION_FUNCTION_VALIDATE(json->GetString(kTextKey, &search_text)); | 278 EXTENSION_FUNCTION_VALIDATE(json->GetString(kTextKey, &search_text)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 history::QueryResults* results) { | 311 history::QueryResults* results) { |
312 ListValue* list = new ListValue(); | 312 ListValue* list = new ListValue(); |
313 if (results && !results->empty()) { | 313 if (results && !results->empty()) { |
314 for (history::QueryResults::URLResultVector::const_iterator iterator = | 314 for (history::QueryResults::URLResultVector::const_iterator iterator = |
315 results->begin(); | 315 results->begin(); |
316 iterator != results->end(); | 316 iterator != results->end(); |
317 ++iterator) { | 317 ++iterator) { |
318 AddHistoryNode(**iterator, list); | 318 AddHistoryNode(**iterator, list); |
319 } | 319 } |
320 } | 320 } |
321 result_.reset(list); | 321 SetResult(list); |
322 SendAsyncResponse(); | 322 SendAsyncResponse(); |
323 } | 323 } |
324 | 324 |
325 bool AddUrlHistoryFunction::RunImpl() { | 325 bool AddUrlHistoryFunction::RunImpl() { |
326 DictionaryValue* json; | 326 DictionaryValue* json; |
327 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); | 327 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); |
328 | 328 |
329 Value* value; | 329 Value* value; |
330 EXTENSION_FUNCTION_VALIDATE(json->Get(kUrlKey, &value)); | 330 EXTENSION_FUNCTION_VALIDATE(json->Get(kUrlKey, &value)); |
331 | 331 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 &cancelable_consumer_, | 406 &cancelable_consumer_, |
407 base::Bind(&DeleteAllHistoryFunction::DeleteComplete, | 407 base::Bind(&DeleteAllHistoryFunction::DeleteComplete, |
408 base::Unretained(this))); | 408 base::Unretained(this))); |
409 | 409 |
410 return true; | 410 return true; |
411 } | 411 } |
412 | 412 |
413 void DeleteAllHistoryFunction::DeleteComplete() { | 413 void DeleteAllHistoryFunction::DeleteComplete() { |
414 SendAsyncResponse(); | 414 SendAsyncResponse(); |
415 } | 415 } |
OLD | NEW |