OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions/extension_history_api.h" | 5 #include "chrome/browser/extensions/extension_history_api.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace { | 23 namespace { |
24 | 24 |
25 double MilliSecondsFromTime(const base::Time& time) { | 25 double MilliSecondsFromTime(const base::Time& time) { |
26 return 1000 * time.ToDoubleT(); | 26 return 1000 * time.ToDoubleT(); |
27 } | 27 } |
28 | 28 |
29 void GetHistoryItemDictionary(const history::URLRow& row, | 29 void GetHistoryItemDictionary(const history::URLRow& row, |
30 DictionaryValue* value) { | 30 DictionaryValue* value) { |
31 value->SetString(keys::kIdKey, base::Int64ToString(row.id())); | 31 value->SetString(keys::kIdKey, base::Int64ToString(row.id())); |
32 value->SetString(keys::kUrlKey, row.url().spec()); | 32 value->SetString(keys::kUrlKey, row.url().spec()); |
33 value->SetStringFromUTF16(keys::kTitleKey, row.title()); | 33 value->SetString(keys::kTitleKey, row.title()); |
34 value->SetReal(keys::kLastVisitdKey, MilliSecondsFromTime(row.last_visit())); | 34 value->SetReal(keys::kLastVisitdKey, MilliSecondsFromTime(row.last_visit())); |
35 value->SetInteger(keys::kTypedCountKey, row.typed_count()); | 35 value->SetInteger(keys::kTypedCountKey, row.typed_count()); |
36 value->SetInteger(keys::kVisitCountKey, row.visit_count()); | 36 value->SetInteger(keys::kVisitCountKey, row.visit_count()); |
37 } | 37 } |
38 | 38 |
39 void AddHistoryNode(const history::URLRow& row, ListValue* list) { | 39 void AddHistoryNode(const history::URLRow& row, ListValue* list) { |
40 DictionaryValue* dict = new DictionaryValue(); | 40 DictionaryValue* dict = new DictionaryValue(); |
41 GetHistoryItemDictionary(row, dict); | 41 GetHistoryItemDictionary(row, dict); |
42 list->Append(dict); | 42 list->Append(dict); |
43 } | 43 } |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 base::Time::Now(), // To the current time. | 367 base::Time::Now(), // To the current time. |
368 &cancelable_consumer_, | 368 &cancelable_consumer_, |
369 NewCallback(this, &DeleteAllHistoryFunction::DeleteComplete)); | 369 NewCallback(this, &DeleteAllHistoryFunction::DeleteComplete)); |
370 | 370 |
371 return true; | 371 return true; |
372 } | 372 } |
373 | 373 |
374 void DeleteAllHistoryFunction::DeleteComplete() { | 374 void DeleteAllHistoryFunction::DeleteComplete() { |
375 SendAsyncResponse(); | 375 SendAsyncResponse(); |
376 } | 376 } |
OLD | NEW |