| 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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "base/i18n/time_formatting.h" | 15 #include "base/i18n/time_formatting.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/ptr_util.h" | |
| 18 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 19 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/time/default_clock.h" | 20 #include "base/time/default_clock.h" |
| 22 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 23 #include "base/values.h" | 22 #include "base/values.h" |
| 24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 25 #include "chrome/browser/favicon/fallback_icon_service_factory.h" | 24 #include "chrome/browser/favicon/fallback_icon_service_factory.h" |
| 26 #include "chrome/browser/favicon/large_icon_service_factory.h" | 25 #include "chrome/browser/favicon/large_icon_service_factory.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 515 |
| 517 // Add the specific dates that were searched to display them. | 516 // Add the specific dates that were searched to display them. |
| 518 // TODO(sergiu): Put today if the start is in the future. | 517 // TODO(sergiu): Put today if the start is in the future. |
| 519 results_info.SetString( | 518 results_info.SetString( |
| 520 "queryStartTime", | 519 "queryStartTime", |
| 521 GetRelativeDateLocalized(clock_.get(), query_results_info->start_time)); | 520 GetRelativeDateLocalized(clock_.get(), query_results_info->start_time)); |
| 522 results_info.SetString( | 521 results_info.SetString( |
| 523 "queryEndTime", | 522 "queryEndTime", |
| 524 GetRelativeDateLocalized(clock_.get(), query_results_info->end_time)); | 523 GetRelativeDateLocalized(clock_.get(), query_results_info->end_time)); |
| 525 | 524 |
| 525 results_info.SetString( |
| 526 "queryStartMonth", |
| 527 base::TimeFormatMonthAndYear(query_results_info->start_time)); |
| 528 results_info.SetString( |
| 529 "queryInterval", |
| 530 base::DateIntervalFormat(query_results_info->start_time, |
| 531 query_results_info->end_time, |
| 532 base::DATE_FORMAT_MONTH_WEEKDAY_DAY)); |
| 533 |
| 526 web_ui()->CallJavascriptFunctionUnsafe("historyResult", results_info, | 534 web_ui()->CallJavascriptFunctionUnsafe("historyResult", results_info, |
| 527 results_value); | 535 results_value); |
| 528 } | 536 } |
| 529 | 537 |
| 530 void BrowsingHistoryHandler::OnRemoveVisitsComplete() { | 538 void BrowsingHistoryHandler::OnRemoveVisitsComplete() { |
| 531 web_ui()->CallJavascriptFunctionUnsafe("deleteComplete"); | 539 web_ui()->CallJavascriptFunctionUnsafe("deleteComplete"); |
| 532 } | 540 } |
| 533 | 541 |
| 534 void BrowsingHistoryHandler::OnRemoveVisitsFailed() { | 542 void BrowsingHistoryHandler::OnRemoveVisitsFailed() { |
| 535 web_ui()->CallJavascriptFunctionUnsafe("deleteFailed"); | 543 web_ui()->CallJavascriptFunctionUnsafe("deleteFailed"); |
| 536 } | 544 } |
| 537 | 545 |
| 538 void BrowsingHistoryHandler::HistoryDeleted() { | 546 void BrowsingHistoryHandler::HistoryDeleted() { |
| 539 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); | 547 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); |
| 540 } | 548 } |
| 541 | 549 |
| 542 void BrowsingHistoryHandler::HasOtherFormsOfBrowsingHistory( | 550 void BrowsingHistoryHandler::HasOtherFormsOfBrowsingHistory( |
| 543 bool has_other_forms, | 551 bool has_other_forms, |
| 544 bool has_synced_results) { | 552 bool has_synced_results) { |
| 545 web_ui()->CallJavascriptFunctionUnsafe( | 553 web_ui()->CallJavascriptFunctionUnsafe( |
| 546 "showNotification", base::FundamentalValue(has_synced_results), | 554 "showNotification", base::FundamentalValue(has_synced_results), |
| 547 base::FundamentalValue(has_other_forms)); | 555 base::FundamentalValue(has_other_forms)); |
| 548 } | 556 } |
| OLD | NEW |