OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/webui/browsing_history_handler.h" | 5 #include "chrome/browser/ui/webui/browsing_history_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY; | 357 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY; |
358 browsing_history_service_->QueryHistory(search_text, options); | 358 browsing_history_service_->QueryHistory(search_text, options); |
359 } | 359 } |
360 | 360 |
361 void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) { | 361 void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) { |
362 std::vector<std::unique_ptr<BrowsingHistoryService::HistoryEntry>> | 362 std::vector<std::unique_ptr<BrowsingHistoryService::HistoryEntry>> |
363 items_to_remove; | 363 items_to_remove; |
364 items_to_remove.reserve(args->GetSize()); | 364 items_to_remove.reserve(args->GetSize()); |
365 for (base::ListValue::const_iterator it = args->begin(); | 365 for (base::ListValue::const_iterator it = args->begin(); |
366 it != args->end(); ++it) { | 366 it != args->end(); ++it) { |
367 const base::DictionaryValue* deletion = NULL; | 367 base::DictionaryValue* deletion = NULL; |
368 base::string16 url; | 368 base::string16 url; |
369 const base::ListValue* timestamps = NULL; | 369 base::ListValue* timestamps = NULL; |
370 | 370 |
371 // Each argument is a dictionary with properties "url" and "timestamps". | 371 // Each argument is a dictionary with properties "url" and "timestamps". |
372 if (!(it->GetAsDictionary(&deletion) && deletion->GetString("url", &url) && | 372 if (!((*it)->GetAsDictionary(&deletion) && |
373 deletion->GetList("timestamps", ×tamps))) { | 373 deletion->GetString("url", &url) && |
| 374 deletion->GetList("timestamps", ×tamps))) { |
374 NOTREACHED() << "Unable to extract arguments"; | 375 NOTREACHED() << "Unable to extract arguments"; |
375 return; | 376 return; |
376 } | 377 } |
377 DCHECK(timestamps->GetSize() > 0); | 378 DCHECK(timestamps->GetSize() > 0); |
378 std::unique_ptr<BrowsingHistoryService::HistoryEntry> entry( | 379 std::unique_ptr<BrowsingHistoryService::HistoryEntry> entry( |
379 new BrowsingHistoryService::HistoryEntry()); | 380 new BrowsingHistoryService::HistoryEntry()); |
380 | 381 |
381 entry->url = GURL(url); | 382 entry->url = GURL(url); |
382 | 383 |
383 double timestamp; | 384 double timestamp; |
384 for (base::ListValue::const_iterator ts_iterator = timestamps->begin(); | 385 for (base::ListValue::const_iterator ts_iterator = timestamps->begin(); |
385 ts_iterator != timestamps->end(); ++ts_iterator) { | 386 ts_iterator != timestamps->end(); ++ts_iterator) { |
386 if (!ts_iterator->GetAsDouble(×tamp)) { | 387 if (!(*ts_iterator)->GetAsDouble(×tamp)) { |
387 NOTREACHED() << "Unable to extract visit timestamp."; | 388 NOTREACHED() << "Unable to extract visit timestamp."; |
388 continue; | 389 continue; |
389 } | 390 } |
390 | 391 |
391 base::Time visit_time = base::Time::FromJsTime(timestamp); | 392 base::Time visit_time = base::Time::FromJsTime(timestamp); |
392 entry->all_timestamps.insert(visit_time.ToInternalValue()); | 393 entry->all_timestamps.insert(visit_time.ToInternalValue()); |
393 } | 394 } |
394 | 395 |
395 items_to_remove.push_back(std::move(entry)); | 396 items_to_remove.push_back(std::move(entry)); |
396 } | 397 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); | 552 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); |
552 } | 553 } |
553 | 554 |
554 void BrowsingHistoryHandler::HasOtherFormsOfBrowsingHistory( | 555 void BrowsingHistoryHandler::HasOtherFormsOfBrowsingHistory( |
555 bool has_other_forms, | 556 bool has_other_forms, |
556 bool has_synced_results) { | 557 bool has_synced_results) { |
557 web_ui()->CallJavascriptFunctionUnsafe("showNotification", | 558 web_ui()->CallJavascriptFunctionUnsafe("showNotification", |
558 base::Value(has_synced_results), | 559 base::Value(has_synced_results), |
559 base::Value(has_other_forms)); | 560 base::Value(has_other_forms)); |
560 } | 561 } |
OLD | NEW |