| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/ui/webui/history/browsing_history_handler.h" | 5 #include "ios/chrome/browser/ui/webui/history/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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 default: | 125 default: |
| 126 *type = kDeviceTypeLaptop; | 126 *type = kDeviceTypeLaptop; |
| 127 } | 127 } |
| 128 return; | 128 return; |
| 129 } | 129 } |
| 130 | 130 |
| 131 *name = l10n_util::GetStringUTF8(IDS_HISTORY_UNKNOWN_DEVICE); | 131 *name = l10n_util::GetStringUTF8(IDS_HISTORY_UNKNOWN_DEVICE); |
| 132 *type = kDeviceTypeLaptop; | 132 *type = kDeviceTypeLaptop; |
| 133 } | 133 } |
| 134 | 134 |
| 135 void RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory(bool shown) { |
| 136 UMA_HISTOGRAM_BOOLEAN("History.ShownHeaderAboutOtherFormsOfBrowsingHistory", |
| 137 shown); |
| 138 } |
| 139 |
| 135 } // namespace | 140 } // namespace |
| 136 | 141 |
| 137 BrowsingHistoryHandler::HistoryEntry::HistoryEntry( | 142 BrowsingHistoryHandler::HistoryEntry::HistoryEntry( |
| 138 BrowsingHistoryHandler::HistoryEntry::EntryType entry_type, | 143 BrowsingHistoryHandler::HistoryEntry::EntryType entry_type, |
| 139 const GURL& url, | 144 const GURL& url, |
| 140 const base::string16& title, | 145 const base::string16& title, |
| 141 base::Time time, | 146 base::Time time, |
| 142 const std::string& client_id, | 147 const std::string& client_id, |
| 143 bool is_search_result, | 148 bool is_search_result, |
| 144 const base::string16& snippet, | 149 const base::string16& snippet, |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 browser_state); | 375 browser_state); |
| 371 // Test the existence of other forms of browsing history. | 376 // Test the existence of other forms of browsing history. |
| 372 browsing_data_ui::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( | 377 browsing_data_ui::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( |
| 373 sync_service, web_history, | 378 sync_service, web_history, |
| 374 base::Bind( | 379 base::Bind( |
| 375 &BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete, | 380 &BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete, |
| 376 weak_factory_.GetWeakPtr())); | 381 weak_factory_.GetWeakPtr())); |
| 377 | 382 |
| 378 // Set this to false until the results actually arrive. | 383 // Set this to false until the results actually arrive. |
| 379 results_info_value_.SetBoolean("hasSyncedResults", false); | 384 results_info_value_.SetBoolean("hasSyncedResults", false); |
| 385 } else { |
| 386 // The notice could not have been shown, because there is no web history. |
| 387 RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory(false); |
| 380 } | 388 } |
| 381 } | 389 } |
| 382 | 390 |
| 383 void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) { | 391 void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) { |
| 384 history::QueryOptions options; | 392 history::QueryOptions options; |
| 385 | 393 |
| 386 // Parse the arguments from JavaScript. There are five required arguments: | 394 // Parse the arguments from JavaScript. There are five required arguments: |
| 387 // - the text to search for (may be empty) | 395 // - the text to search for (may be empty) |
| 388 // - the offset from which the search should start (in multiples of week or | 396 // - the offset from which the search should start (in multiples of week or |
| 389 // month, set by the next argument). | 397 // month, set by the next argument). |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 } | 749 } |
| 742 has_synced_results_ = results_value != nullptr; | 750 has_synced_results_ = results_value != nullptr; |
| 743 results_info_value_.SetBoolean("hasSyncedResults", has_synced_results_); | 751 results_info_value_.SetBoolean("hasSyncedResults", has_synced_results_); |
| 744 if (!query_task_tracker_.HasTrackedTasks()) | 752 if (!query_task_tracker_.HasTrackedTasks()) |
| 745 ReturnResultsToFrontEnd(); | 753 ReturnResultsToFrontEnd(); |
| 746 } | 754 } |
| 747 | 755 |
| 748 void BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete( | 756 void BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete( |
| 749 bool found_other_forms_of_browsing_history) { | 757 bool found_other_forms_of_browsing_history) { |
| 750 has_other_forms_of_browsing_history_ = found_other_forms_of_browsing_history; | 758 has_other_forms_of_browsing_history_ = found_other_forms_of_browsing_history; |
| 759 RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory( |
| 760 has_other_forms_of_browsing_history_); |
| 751 web_ui()->CallJavascriptFunction( | 761 web_ui()->CallJavascriptFunction( |
| 752 "showNotification", base::FundamentalValue(has_synced_results_), | 762 "showNotification", base::FundamentalValue(has_synced_results_), |
| 753 base::FundamentalValue(has_other_forms_of_browsing_history_)); | 763 base::FundamentalValue(has_other_forms_of_browsing_history_)); |
| 754 } | 764 } |
| 755 | 765 |
| 756 void BrowsingHistoryHandler::RemoveComplete() { | 766 void BrowsingHistoryHandler::RemoveComplete() { |
| 757 urls_to_be_deleted_.clear(); | 767 urls_to_be_deleted_.clear(); |
| 758 | 768 |
| 759 // Notify the page that the deletion request is complete, but only if a web | 769 // Notify the page that the deletion request is complete, but only if a web |
| 760 // history delete request is not still pending. | 770 // history delete request is not still pending. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 | 839 |
| 830 void BrowsingHistoryHandler::OnURLsDeleted( | 840 void BrowsingHistoryHandler::OnURLsDeleted( |
| 831 history::HistoryService* history_service, | 841 history::HistoryService* history_service, |
| 832 bool all_history, | 842 bool all_history, |
| 833 bool expired, | 843 bool expired, |
| 834 const history::URLRows& deleted_rows, | 844 const history::URLRows& deleted_rows, |
| 835 const std::set<GURL>& favicon_urls) { | 845 const std::set<GURL>& favicon_urls) { |
| 836 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) | 846 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) |
| 837 web_ui()->CallJavascriptFunction("historyDeleted"); | 847 web_ui()->CallJavascriptFunction("historyDeleted"); |
| 838 } | 848 } |
| OLD | NEW |