| 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 | 10 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 QueryHistory(search_text, options); | 488 QueryHistory(search_text, options); |
| 489 } | 489 } |
| 490 | 490 |
| 491 void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) { | 491 void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) { |
| 492 Profile* profile = Profile::FromWebUI(web_ui()); | 492 Profile* profile = Profile::FromWebUI(web_ui()); |
| 493 // TODO(davidben): history.js is not aware of this failure and will still | 493 // TODO(davidben): history.js is not aware of this failure and will still |
| 494 // override |deleteCompleteCallback_|. | 494 // override |deleteCompleteCallback_|. |
| 495 if (delete_task_tracker_.HasTrackedTasks() || | 495 if (delete_task_tracker_.HasTrackedTasks() || |
| 496 has_pending_delete_request_ || | 496 has_pending_delete_request_ || |
| 497 !profile->GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)) { | 497 !profile->GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)) { |
| 498 web_ui()->CallJavascriptFunction("deleteFailed"); | 498 web_ui()->CallJavascriptFunctionUnsafe("deleteFailed"); |
| 499 return; | 499 return; |
| 500 } | 500 } |
| 501 | 501 |
| 502 history::HistoryService* history_service = | 502 history::HistoryService* history_service = |
| 503 HistoryServiceFactory::GetForProfile(profile, | 503 HistoryServiceFactory::GetForProfile(profile, |
| 504 ServiceAccessType::EXPLICIT_ACCESS); | 504 ServiceAccessType::EXPLICIT_ACCESS); |
| 505 history::WebHistoryService* web_history = | 505 history::WebHistoryService* web_history = |
| 506 WebHistoryServiceFactory::GetForProfile(profile); | 506 WebHistoryServiceFactory::GetForProfile(profile); |
| 507 | 507 |
| 508 base::Time now = base::Time::Now(); | 508 base::Time now = base::Time::Now(); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 | 701 |
| 702 // Convert the result vector into a ListValue. | 702 // Convert the result vector into a ListValue. |
| 703 base::ListValue results_value; | 703 base::ListValue results_value; |
| 704 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it = | 704 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it = |
| 705 query_results_.begin(); it != query_results_.end(); ++it) { | 705 query_results_.begin(); it != query_results_.end(); ++it) { |
| 706 std::unique_ptr<base::Value> value( | 706 std::unique_ptr<base::Value> value( |
| 707 it->ToValue(bookmark_model, supervised_user_service, sync_service)); | 707 it->ToValue(bookmark_model, supervised_user_service, sync_service)); |
| 708 results_value.Append(value.release()); | 708 results_value.Append(value.release()); |
| 709 } | 709 } |
| 710 | 710 |
| 711 web_ui()->CallJavascriptFunction( | 711 web_ui()->CallJavascriptFunctionUnsafe("historyResult", results_info_value_, |
| 712 "historyResult", results_info_value_, results_value); | 712 results_value); |
| 713 web_ui()->CallJavascriptFunction( | 713 web_ui()->CallJavascriptFunctionUnsafe( |
| 714 "showNotification", | 714 "showNotification", base::FundamentalValue(has_synced_results_), |
| 715 base::FundamentalValue(has_synced_results_), | |
| 716 base::FundamentalValue(has_other_forms_of_browsing_history_)); | 715 base::FundamentalValue(has_other_forms_of_browsing_history_)); |
| 717 results_info_value_.Clear(); | 716 results_info_value_.Clear(); |
| 718 query_results_.clear(); | 717 query_results_.clear(); |
| 719 web_history_query_results_.clear(); | 718 web_history_query_results_.clear(); |
| 720 } | 719 } |
| 721 | 720 |
| 722 void BrowsingHistoryHandler::QueryComplete( | 721 void BrowsingHistoryHandler::QueryComplete( |
| 723 const base::string16& search_text, | 722 const base::string16& search_text, |
| 724 const history::QueryOptions& options, | 723 const history::QueryOptions& options, |
| 725 history::QueryResults* results) { | 724 history::QueryResults* results) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 ReturnResultsToFrontEnd(); | 854 ReturnResultsToFrontEnd(); |
| 856 } | 855 } |
| 857 | 856 |
| 858 void BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete( | 857 void BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete( |
| 859 bool found_other_forms_of_browsing_history) { | 858 bool found_other_forms_of_browsing_history) { |
| 860 has_other_forms_of_browsing_history_ = found_other_forms_of_browsing_history; | 859 has_other_forms_of_browsing_history_ = found_other_forms_of_browsing_history; |
| 861 | 860 |
| 862 RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory( | 861 RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory( |
| 863 has_other_forms_of_browsing_history_); | 862 has_other_forms_of_browsing_history_); |
| 864 | 863 |
| 865 web_ui()->CallJavascriptFunction( | 864 web_ui()->CallJavascriptFunctionUnsafe( |
| 866 "showNotification", | 865 "showNotification", base::FundamentalValue(has_synced_results_), |
| 867 base::FundamentalValue(has_synced_results_), | |
| 868 base::FundamentalValue(has_other_forms_of_browsing_history_)); | 866 base::FundamentalValue(has_other_forms_of_browsing_history_)); |
| 869 } | 867 } |
| 870 | 868 |
| 871 void BrowsingHistoryHandler::RemoveComplete() { | 869 void BrowsingHistoryHandler::RemoveComplete() { |
| 872 urls_to_be_deleted_.clear(); | 870 urls_to_be_deleted_.clear(); |
| 873 | 871 |
| 874 // Notify the page that the deletion request is complete, but only if a web | 872 // Notify the page that the deletion request is complete, but only if a web |
| 875 // history delete request is not still pending. | 873 // history delete request is not still pending. |
| 876 if (!has_pending_delete_request_) | 874 if (!has_pending_delete_request_) |
| 877 web_ui()->CallJavascriptFunction("deleteComplete"); | 875 web_ui()->CallJavascriptFunctionUnsafe("deleteComplete"); |
| 878 } | 876 } |
| 879 | 877 |
| 880 void BrowsingHistoryHandler::RemoveWebHistoryComplete(bool success) { | 878 void BrowsingHistoryHandler::RemoveWebHistoryComplete(bool success) { |
| 881 has_pending_delete_request_ = false; | 879 has_pending_delete_request_ = false; |
| 882 // TODO(dubroy): Should we handle failure somehow? Delete directives will | 880 // TODO(dubroy): Should we handle failure somehow? Delete directives will |
| 883 // ensure that the visits are eventually deleted, so maybe it's not necessary. | 881 // ensure that the visits are eventually deleted, so maybe it's not necessary. |
| 884 if (!delete_task_tracker_.HasTrackedTasks()) | 882 if (!delete_task_tracker_.HasTrackedTasks()) |
| 885 RemoveComplete(); | 883 RemoveComplete(); |
| 886 } | 884 } |
| 887 | 885 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 return false; | 940 return false; |
| 943 } | 941 } |
| 944 | 942 |
| 945 void BrowsingHistoryHandler::OnURLsDeleted( | 943 void BrowsingHistoryHandler::OnURLsDeleted( |
| 946 history::HistoryService* history_service, | 944 history::HistoryService* history_service, |
| 947 bool all_history, | 945 bool all_history, |
| 948 bool expired, | 946 bool expired, |
| 949 const history::URLRows& deleted_rows, | 947 const history::URLRows& deleted_rows, |
| 950 const std::set<GURL>& favicon_urls) { | 948 const std::set<GURL>& favicon_urls) { |
| 951 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) | 949 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) |
| 952 web_ui()->CallJavascriptFunction("historyDeleted"); | 950 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); |
| 953 } | 951 } |
| OLD | NEW |