OLD | NEW |
1 // Copyright (c) 2011 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/extensions/extension_history_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" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/task.h" | 13 #include "base/task.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/extensions/extension_event_router.h" | 15 #include "chrome/browser/extensions/extension_event_router.h" |
16 #include "chrome/browser/extensions/extension_history_api_constants.h" | |
17 #include "chrome/browser/history/history.h" | 16 #include "chrome/browser/history/history.h" |
18 #include "chrome/browser/history/history_types.h" | 17 #include "chrome/browser/history/history_types.h" |
19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
21 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
22 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
23 | 22 |
24 namespace keys = extension_history_api_constants; | 23 namespace { |
25 | 24 |
26 namespace { | 25 const char kAllHistoryKey[] = "allHistory"; |
| 26 const char kEndTimeKey[] = "endTime"; |
| 27 const char kFaviconUrlKey[] = "favIconUrl"; |
| 28 const char kIdKey[] = "id"; |
| 29 const char kLastVisitdKey[] = "lastVisitTime"; |
| 30 const char kMaxResultsKey[] = "maxResults"; |
| 31 const char kNewKey[] = "new"; |
| 32 const char kReferringVisitId[] = "referringVisitId"; |
| 33 const char kRemovedKey[] = "removed"; |
| 34 const char kStartTimeKey[] = "startTime"; |
| 35 const char kTextKey[] = "text"; |
| 36 const char kTitleKey[] = "title"; |
| 37 const char kTypedCountKey[] = "typedCount"; |
| 38 const char kVisitCountKey[] = "visitCount"; |
| 39 const char kTransition[] = "transition"; |
| 40 const char kUrlKey[] = "url"; |
| 41 const char kUrlsKey[] = "urls"; |
| 42 const char kVisitId[] = "visitId"; |
| 43 const char kVisitTime[] = "visitTime"; |
| 44 |
| 45 const char kOnVisited[] = "history.onVisited"; |
| 46 const char kOnVisitRemoved[] = "history.onVisitRemoved"; |
| 47 |
| 48 const char kInvalidIdError[] = "History item id is invalid."; |
| 49 const char kInvalidUrlError[] = "Url is invalid."; |
27 | 50 |
28 double MilliSecondsFromTime(const base::Time& time) { | 51 double MilliSecondsFromTime(const base::Time& time) { |
29 return 1000 * time.ToDoubleT(); | 52 return 1000 * time.ToDoubleT(); |
30 } | 53 } |
31 | 54 |
32 void GetHistoryItemDictionary(const history::URLRow& row, | 55 void GetHistoryItemDictionary(const history::URLRow& row, |
33 DictionaryValue* value) { | 56 DictionaryValue* value) { |
34 value->SetString(keys::kIdKey, base::Int64ToString(row.id())); | 57 value->SetString(kIdKey, base::Int64ToString(row.id())); |
35 value->SetString(keys::kUrlKey, row.url().spec()); | 58 value->SetString(kUrlKey, row.url().spec()); |
36 value->SetString(keys::kTitleKey, row.title()); | 59 value->SetString(kTitleKey, row.title()); |
37 value->SetDouble(keys::kLastVisitdKey, | 60 value->SetDouble(kLastVisitdKey, |
38 MilliSecondsFromTime(row.last_visit())); | 61 MilliSecondsFromTime(row.last_visit())); |
39 value->SetInteger(keys::kTypedCountKey, row.typed_count()); | 62 value->SetInteger(kTypedCountKey, row.typed_count()); |
40 value->SetInteger(keys::kVisitCountKey, row.visit_count()); | 63 value->SetInteger(kVisitCountKey, row.visit_count()); |
41 } | 64 } |
42 | 65 |
43 void AddHistoryNode(const history::URLRow& row, ListValue* list) { | 66 void AddHistoryNode(const history::URLRow& row, ListValue* list) { |
44 DictionaryValue* dict = new DictionaryValue(); | 67 DictionaryValue* dict = new DictionaryValue(); |
45 GetHistoryItemDictionary(row, dict); | 68 GetHistoryItemDictionary(row, dict); |
46 list->Append(dict); | 69 list->Append(dict); |
47 } | 70 } |
48 | 71 |
49 void GetVisitInfoDictionary(const history::VisitRow& row, | 72 void GetVisitInfoDictionary(const history::VisitRow& row, |
50 DictionaryValue* value) { | 73 DictionaryValue* value) { |
51 value->SetString(keys::kIdKey, base::Int64ToString(row.url_id)); | 74 value->SetString(kIdKey, base::Int64ToString(row.url_id)); |
52 value->SetString(keys::kVisitId, base::Int64ToString(row.visit_id)); | 75 value->SetString(kVisitId, base::Int64ToString(row.visit_id)); |
53 value->SetDouble(keys::kVisitTime, MilliSecondsFromTime(row.visit_time)); | 76 value->SetDouble(kVisitTime, MilliSecondsFromTime(row.visit_time)); |
54 value->SetString(keys::kReferringVisitId, | 77 value->SetString(kReferringVisitId, |
55 base::Int64ToString(row.referring_visit)); | 78 base::Int64ToString(row.referring_visit)); |
56 | 79 |
57 const char* trans = | 80 const char* trans = |
58 content::PageTransitionGetCoreTransitionString(row.transition); | 81 content::PageTransitionGetCoreTransitionString(row.transition); |
59 DCHECK(trans) << "Invalid transition."; | 82 DCHECK(trans) << "Invalid transition."; |
60 value->SetString(keys::kTransition, trans); | 83 value->SetString(kTransition, trans); |
61 } | 84 } |
62 | 85 |
63 void AddVisitNode(const history::VisitRow& row, ListValue* list) { | 86 void AddVisitNode(const history::VisitRow& row, ListValue* list) { |
64 DictionaryValue* dict = new DictionaryValue(); | 87 DictionaryValue* dict = new DictionaryValue(); |
65 GetVisitInfoDictionary(row, dict); | 88 GetVisitInfoDictionary(row, dict); |
66 list->Append(dict); | 89 list->Append(dict); |
67 } | 90 } |
68 | 91 |
69 } // namespace | 92 } // namespace |
70 | 93 |
71 ExtensionHistoryEventRouter::ExtensionHistoryEventRouter() {} | 94 HistoryExtensionEventRouter::HistoryExtensionEventRouter() {} |
72 | 95 |
73 ExtensionHistoryEventRouter::~ExtensionHistoryEventRouter() {} | 96 HistoryExtensionEventRouter::~HistoryExtensionEventRouter() {} |
74 | 97 |
75 void ExtensionHistoryEventRouter::ObserveProfile(Profile* profile) { | 98 void HistoryExtensionEventRouter::ObserveProfile(Profile* profile) { |
76 CHECK(registrar_.IsEmpty()); | 99 CHECK(registrar_.IsEmpty()); |
77 const content::Source<Profile> source = content::Source<Profile>(profile); | 100 const content::Source<Profile> source = content::Source<Profile>(profile); |
78 registrar_.Add(this, | 101 registrar_.Add(this, |
79 chrome::NOTIFICATION_HISTORY_URL_VISITED, | 102 chrome::NOTIFICATION_HISTORY_URL_VISITED, |
80 source); | 103 source); |
81 registrar_.Add(this, | 104 registrar_.Add(this, |
82 chrome::NOTIFICATION_HISTORY_URLS_DELETED, | 105 chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
83 source); | 106 source); |
84 } | 107 } |
85 | 108 |
86 void ExtensionHistoryEventRouter::Observe( | 109 void HistoryExtensionEventRouter::Observe( |
87 int type, | 110 int type, |
88 const content::NotificationSource& source, | 111 const content::NotificationSource& source, |
89 const content::NotificationDetails& details) { | 112 const content::NotificationDetails& details) { |
90 switch (type) { | 113 switch (type) { |
91 case chrome::NOTIFICATION_HISTORY_URL_VISITED: | 114 case chrome::NOTIFICATION_HISTORY_URL_VISITED: |
92 HistoryUrlVisited( | 115 HistoryUrlVisited( |
93 content::Source<Profile>(source).ptr(), | 116 content::Source<Profile>(source).ptr(), |
94 content::Details<const history::URLVisitedDetails>(details).ptr()); | 117 content::Details<const history::URLVisitedDetails>(details).ptr()); |
95 break; | 118 break; |
96 case chrome::NOTIFICATION_HISTORY_URLS_DELETED: | 119 case chrome::NOTIFICATION_HISTORY_URLS_DELETED: |
97 HistoryUrlsRemoved( | 120 HistoryUrlsRemoved( |
98 content::Source<Profile>(source).ptr(), | 121 content::Source<Profile>(source).ptr(), |
99 content::Details<const history::URLsDeletedDetails>(details).ptr()); | 122 content::Details<const history::URLsDeletedDetails>(details).ptr()); |
100 break; | 123 break; |
101 default: | 124 default: |
102 NOTREACHED(); | 125 NOTREACHED(); |
103 } | 126 } |
104 } | 127 } |
105 | 128 |
106 void ExtensionHistoryEventRouter::HistoryUrlVisited( | 129 void HistoryExtensionEventRouter::HistoryUrlVisited( |
107 Profile* profile, | 130 Profile* profile, |
108 const history::URLVisitedDetails* details) { | 131 const history::URLVisitedDetails* details) { |
109 ListValue args; | 132 ListValue args; |
110 DictionaryValue* dict = new DictionaryValue(); | 133 DictionaryValue* dict = new DictionaryValue(); |
111 GetHistoryItemDictionary(details->row, dict); | 134 GetHistoryItemDictionary(details->row, dict); |
112 args.Append(dict); | 135 args.Append(dict); |
113 | 136 |
114 std::string json_args; | 137 std::string json_args; |
115 base::JSONWriter::Write(&args, false, &json_args); | 138 base::JSONWriter::Write(&args, false, &json_args); |
116 DispatchEvent(profile, keys::kOnVisited, json_args); | 139 DispatchEvent(profile, kOnVisited, json_args); |
117 } | 140 } |
118 | 141 |
119 void ExtensionHistoryEventRouter::HistoryUrlsRemoved( | 142 void HistoryExtensionEventRouter::HistoryUrlsRemoved( |
120 Profile* profile, | 143 Profile* profile, |
121 const history::URLsDeletedDetails* details) { | 144 const history::URLsDeletedDetails* details) { |
122 ListValue args; | 145 ListValue args; |
123 DictionaryValue* dict = new DictionaryValue(); | 146 DictionaryValue* dict = new DictionaryValue(); |
124 dict->SetBoolean(keys::kAllHistoryKey, details->all_history); | 147 dict->SetBoolean(kAllHistoryKey, details->all_history); |
125 ListValue* urls = new ListValue(); | 148 ListValue* urls = new ListValue(); |
126 for (std::set<GURL>::const_iterator iterator = details->urls.begin(); | 149 for (std::set<GURL>::const_iterator iterator = details->urls.begin(); |
127 iterator != details->urls.end(); | 150 iterator != details->urls.end(); |
128 ++iterator) { | 151 ++iterator) { |
129 urls->Append(new StringValue(iterator->spec())); | 152 urls->Append(new StringValue(iterator->spec())); |
130 } | 153 } |
131 dict->Set(keys::kUrlsKey, urls); | 154 dict->Set(kUrlsKey, urls); |
132 args.Append(dict); | 155 args.Append(dict); |
133 | 156 |
134 std::string json_args; | 157 std::string json_args; |
135 base::JSONWriter::Write(&args, false, &json_args); | 158 base::JSONWriter::Write(&args, false, &json_args); |
136 DispatchEvent(profile, keys::kOnVisitRemoved, json_args); | 159 DispatchEvent(profile, kOnVisitRemoved, json_args); |
137 } | 160 } |
138 | 161 |
139 void ExtensionHistoryEventRouter::DispatchEvent(Profile* profile, | 162 void HistoryExtensionEventRouter::DispatchEvent(Profile* profile, |
140 const char* event_name, | 163 const char* event_name, |
141 const std::string& json_args) { | 164 const std::string& json_args) { |
142 if (profile && profile->GetExtensionEventRouter()) { | 165 if (profile && profile->GetExtensionEventRouter()) { |
143 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 166 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
144 event_name, json_args, profile, GURL()); | 167 event_name, json_args, profile, GURL()); |
145 } | 168 } |
146 } | 169 } |
147 | 170 |
148 void HistoryFunction::Run() { | 171 void HistoryFunction::Run() { |
149 if (!RunImpl()) { | 172 if (!RunImpl()) { |
150 SendResponse(false); | 173 SendResponse(false); |
151 } | 174 } |
152 } | 175 } |
153 | 176 |
154 bool HistoryFunction::GetUrlFromValue(Value* value, GURL* url) { | 177 bool HistoryFunction::GetUrlFromValue(Value* value, GURL* url) { |
155 std::string url_string; | 178 std::string url_string; |
156 if (!value->GetAsString(&url_string)) { | 179 if (!value->GetAsString(&url_string)) { |
157 bad_message_ = true; | 180 bad_message_ = true; |
158 return false; | 181 return false; |
159 } | 182 } |
160 | 183 |
161 GURL temp_url(url_string); | 184 GURL temp_url(url_string); |
162 if (!temp_url.is_valid()) { | 185 if (!temp_url.is_valid()) { |
163 error_ = keys::kInvalidUrlError; | 186 error_ = kInvalidUrlError; |
164 return false; | 187 return false; |
165 } | 188 } |
166 url->Swap(&temp_url); | 189 url->Swap(&temp_url); |
167 return true; | 190 return true; |
168 } | 191 } |
169 | 192 |
170 bool HistoryFunction::GetTimeFromValue(Value* value, base::Time* time) { | 193 bool HistoryFunction::GetTimeFromValue(Value* value, base::Time* time) { |
171 double ms_from_epoch = 0.0; | 194 double ms_from_epoch = 0.0; |
172 if (!value->GetAsDouble(&ms_from_epoch)) | 195 if (!value->GetAsDouble(&ms_from_epoch)) |
173 return false; | 196 return false; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 void HistoryFunctionWithCallback::SendResponseToCallback() { | 229 void HistoryFunctionWithCallback::SendResponseToCallback() { |
207 SendResponse(true); | 230 SendResponse(true); |
208 Release(); // Balanced in RunImpl(). | 231 Release(); // Balanced in RunImpl(). |
209 } | 232 } |
210 | 233 |
211 bool GetVisitsHistoryFunction::RunAsyncImpl() { | 234 bool GetVisitsHistoryFunction::RunAsyncImpl() { |
212 DictionaryValue* json; | 235 DictionaryValue* json; |
213 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); | 236 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); |
214 | 237 |
215 Value* value; | 238 Value* value; |
216 EXTENSION_FUNCTION_VALIDATE(json->Get(keys::kUrlKey, &value)); | 239 EXTENSION_FUNCTION_VALIDATE(json->Get(kUrlKey, &value)); |
217 | 240 |
218 GURL url; | 241 GURL url; |
219 if (!GetUrlFromValue(value, &url)) | 242 if (!GetUrlFromValue(value, &url)) |
220 return false; | 243 return false; |
221 | 244 |
222 HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); | 245 HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); |
223 hs->QueryURL(url, | 246 hs->QueryURL(url, |
224 true, // Retrieve full history of a URL. | 247 true, // Retrieve full history of a URL. |
225 &cancelable_consumer_, | 248 &cancelable_consumer_, |
226 base::Bind(&GetVisitsHistoryFunction::QueryComplete, | 249 base::Bind(&GetVisitsHistoryFunction::QueryComplete, |
(...skipping 18 matching lines...) Expand all Loading... |
245 result_.reset(list); | 268 result_.reset(list); |
246 SendAsyncResponse(); | 269 SendAsyncResponse(); |
247 } | 270 } |
248 | 271 |
249 bool SearchHistoryFunction::RunAsyncImpl() { | 272 bool SearchHistoryFunction::RunAsyncImpl() { |
250 DictionaryValue* json; | 273 DictionaryValue* json; |
251 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); | 274 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); |
252 | 275 |
253 // Initialize the HistoryQuery | 276 // Initialize the HistoryQuery |
254 string16 search_text; | 277 string16 search_text; |
255 EXTENSION_FUNCTION_VALIDATE(json->GetString(keys::kTextKey, &search_text)); | 278 EXTENSION_FUNCTION_VALIDATE(json->GetString(kTextKey, &search_text)); |
256 | 279 |
257 history::QueryOptions options; | 280 history::QueryOptions options; |
258 options.SetRecentDayRange(1); | 281 options.SetRecentDayRange(1); |
259 options.max_count = 100; | 282 options.max_count = 100; |
260 | 283 |
261 if (json->HasKey(keys::kStartTimeKey)) { // Optional. | 284 if (json->HasKey(kStartTimeKey)) { // Optional. |
262 Value* value; | 285 Value* value; |
263 EXTENSION_FUNCTION_VALIDATE(json->Get(keys::kStartTimeKey, &value)); | 286 EXTENSION_FUNCTION_VALIDATE(json->Get(kStartTimeKey, &value)); |
264 EXTENSION_FUNCTION_VALIDATE(GetTimeFromValue(value, &options.begin_time)); | 287 EXTENSION_FUNCTION_VALIDATE(GetTimeFromValue(value, &options.begin_time)); |
265 } | 288 } |
266 if (json->HasKey(keys::kEndTimeKey)) { // Optional. | 289 if (json->HasKey(kEndTimeKey)) { // Optional. |
267 Value* value; | 290 Value* value; |
268 EXTENSION_FUNCTION_VALIDATE(json->Get(keys::kEndTimeKey, &value)); | 291 EXTENSION_FUNCTION_VALIDATE(json->Get(kEndTimeKey, &value)); |
269 EXTENSION_FUNCTION_VALIDATE(GetTimeFromValue(value, &options.end_time)); | 292 EXTENSION_FUNCTION_VALIDATE(GetTimeFromValue(value, &options.end_time)); |
270 } | 293 } |
271 if (json->HasKey(keys::kMaxResultsKey)) { // Optional. | 294 if (json->HasKey(kMaxResultsKey)) { // Optional. |
272 EXTENSION_FUNCTION_VALIDATE(json->GetInteger(keys::kMaxResultsKey, | 295 EXTENSION_FUNCTION_VALIDATE(json->GetInteger(kMaxResultsKey, |
273 &options.max_count)); | 296 &options.max_count)); |
274 } | 297 } |
275 | 298 |
276 HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); | 299 HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); |
277 hs->QueryHistory(search_text, options, &cancelable_consumer_, | 300 hs->QueryHistory(search_text, options, &cancelable_consumer_, |
278 base::Bind(&SearchHistoryFunction::SearchComplete, | 301 base::Bind(&SearchHistoryFunction::SearchComplete, |
279 base::Unretained(this))); | 302 base::Unretained(this))); |
280 | 303 |
281 return true; | 304 return true; |
282 } | 305 } |
(...skipping 12 matching lines...) Expand all Loading... |
295 } | 318 } |
296 result_.reset(list); | 319 result_.reset(list); |
297 SendAsyncResponse(); | 320 SendAsyncResponse(); |
298 } | 321 } |
299 | 322 |
300 bool AddUrlHistoryFunction::RunImpl() { | 323 bool AddUrlHistoryFunction::RunImpl() { |
301 DictionaryValue* json; | 324 DictionaryValue* json; |
302 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); | 325 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); |
303 | 326 |
304 Value* value; | 327 Value* value; |
305 EXTENSION_FUNCTION_VALIDATE(json->Get(keys::kUrlKey, &value)); | 328 EXTENSION_FUNCTION_VALIDATE(json->Get(kUrlKey, &value)); |
306 | 329 |
307 GURL url; | 330 GURL url; |
308 if (!GetUrlFromValue(value, &url)) | 331 if (!GetUrlFromValue(value, &url)) |
309 return false; | 332 return false; |
310 | 333 |
311 HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); | 334 HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); |
312 hs->AddPage(url, history::SOURCE_EXTENSION); | 335 hs->AddPage(url, history::SOURCE_EXTENSION); |
313 | 336 |
314 SendResponse(true); | 337 SendResponse(true); |
315 return true; | 338 return true; |
316 } | 339 } |
317 | 340 |
318 bool DeleteUrlHistoryFunction::RunImpl() { | 341 bool DeleteUrlHistoryFunction::RunImpl() { |
319 DictionaryValue* json; | 342 DictionaryValue* json; |
320 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); | 343 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); |
321 | 344 |
322 Value* value; | 345 Value* value; |
323 EXTENSION_FUNCTION_VALIDATE(json->Get(keys::kUrlKey, &value)); | 346 EXTENSION_FUNCTION_VALIDATE(json->Get(kUrlKey, &value)); |
324 | 347 |
325 GURL url; | 348 GURL url; |
326 if (!GetUrlFromValue(value, &url)) | 349 if (!GetUrlFromValue(value, &url)) |
327 return false; | 350 return false; |
328 | 351 |
329 HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); | 352 HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); |
330 hs->DeleteURL(url); | 353 hs->DeleteURL(url); |
331 | 354 |
332 SendResponse(true); | 355 SendResponse(true); |
333 return true; | 356 return true; |
334 } | 357 } |
335 | 358 |
336 bool DeleteRangeHistoryFunction::RunAsyncImpl() { | 359 bool DeleteRangeHistoryFunction::RunAsyncImpl() { |
337 DictionaryValue* json; | 360 DictionaryValue* json; |
338 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); | 361 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &json)); |
339 | 362 |
340 Value* value = NULL; | 363 Value* value = NULL; |
341 EXTENSION_FUNCTION_VALIDATE(json->Get(keys::kStartTimeKey, &value)); | 364 EXTENSION_FUNCTION_VALIDATE(json->Get(kStartTimeKey, &value)); |
342 base::Time begin_time; | 365 base::Time begin_time; |
343 EXTENSION_FUNCTION_VALIDATE(GetTimeFromValue(value, &begin_time)); | 366 EXTENSION_FUNCTION_VALIDATE(GetTimeFromValue(value, &begin_time)); |
344 | 367 |
345 EXTENSION_FUNCTION_VALIDATE(json->Get(keys::kEndTimeKey, &value)); | 368 EXTENSION_FUNCTION_VALIDATE(json->Get(kEndTimeKey, &value)); |
346 base::Time end_time; | 369 base::Time end_time; |
347 EXTENSION_FUNCTION_VALIDATE(GetTimeFromValue(value, &end_time)); | 370 EXTENSION_FUNCTION_VALIDATE(GetTimeFromValue(value, &end_time)); |
348 | 371 |
349 std::set<GURL> restrict_urls; | 372 std::set<GURL> restrict_urls; |
350 HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); | 373 HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); |
351 hs->ExpireHistoryBetween( | 374 hs->ExpireHistoryBetween( |
352 restrict_urls, | 375 restrict_urls, |
353 begin_time, | 376 begin_time, |
354 end_time, | 377 end_time, |
355 &cancelable_consumer_, | 378 &cancelable_consumer_, |
(...skipping 17 matching lines...) Expand all Loading... |
373 &cancelable_consumer_, | 396 &cancelable_consumer_, |
374 base::Bind(&DeleteAllHistoryFunction::DeleteComplete, | 397 base::Bind(&DeleteAllHistoryFunction::DeleteComplete, |
375 base::Unretained(this))); | 398 base::Unretained(this))); |
376 | 399 |
377 return true; | 400 return true; |
378 } | 401 } |
379 | 402 |
380 void DeleteAllHistoryFunction::DeleteComplete() { | 403 void DeleteAllHistoryFunction::DeleteComplete() { |
381 SendAsyncResponse(); | 404 SendAsyncResponse(); |
382 } | 405 } |
OLD | NEW |