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 base::DictionaryValue* deletion = NULL; | 367 const base::DictionaryValue* deletion = NULL; |
368 base::string16 url; | 368 base::string16 url; |
369 base::ListValue* timestamps = NULL; | 369 const 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) && | 372 if (!(it->GetAsDictionary(&deletion) && deletion->GetString("url", &url) && |
373 deletion->GetString("url", &url) && | 373 deletion->GetList("timestamps", ×tamps))) { |
374 deletion->GetList("timestamps", ×tamps))) { | |
375 NOTREACHED() << "Unable to extract arguments"; | 374 NOTREACHED() << "Unable to extract arguments"; |
376 return; | 375 return; |
377 } | 376 } |
378 DCHECK(timestamps->GetSize() > 0); | 377 DCHECK(timestamps->GetSize() > 0); |
379 std::unique_ptr<BrowsingHistoryService::HistoryEntry> entry( | 378 std::unique_ptr<BrowsingHistoryService::HistoryEntry> entry( |
380 new BrowsingHistoryService::HistoryEntry()); | 379 new BrowsingHistoryService::HistoryEntry()); |
381 | 380 |
382 entry->url = GURL(url); | 381 entry->url = GURL(url); |
383 | 382 |
384 double timestamp; | 383 double timestamp; |
385 for (base::ListValue::const_iterator ts_iterator = timestamps->begin(); | 384 for (base::ListValue::const_iterator ts_iterator = timestamps->begin(); |
386 ts_iterator != timestamps->end(); ++ts_iterator) { | 385 ts_iterator != timestamps->end(); ++ts_iterator) { |
387 if (!(*ts_iterator)->GetAsDouble(×tamp)) { | 386 if (!ts_iterator->GetAsDouble(×tamp)) { |
388 NOTREACHED() << "Unable to extract visit timestamp."; | 387 NOTREACHED() << "Unable to extract visit timestamp."; |
389 continue; | 388 continue; |
390 } | 389 } |
391 | 390 |
392 base::Time visit_time = base::Time::FromJsTime(timestamp); | 391 base::Time visit_time = base::Time::FromJsTime(timestamp); |
393 entry->all_timestamps.insert(visit_time.ToInternalValue()); | 392 entry->all_timestamps.insert(visit_time.ToInternalValue()); |
394 } | 393 } |
395 | 394 |
396 items_to_remove.push_back(std::move(entry)); | 395 items_to_remove.push_back(std::move(entry)); |
397 } | 396 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); | 548 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); |
550 } | 549 } |
551 | 550 |
552 void BrowsingHistoryHandler::HasOtherFormsOfBrowsingHistory( | 551 void BrowsingHistoryHandler::HasOtherFormsOfBrowsingHistory( |
553 bool has_other_forms, | 552 bool has_other_forms, |
554 bool has_synced_results) { | 553 bool has_synced_results) { |
555 web_ui()->CallJavascriptFunctionUnsafe("showNotification", | 554 web_ui()->CallJavascriptFunctionUnsafe("showNotification", |
556 base::Value(has_synced_results), | 555 base::Value(has_synced_results), |
557 base::Value(has_other_forms)); | 556 base::Value(has_other_forms)); |
558 } | 557 } |
OLD | NEW |