| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 default: | 150 default: |
| 151 *type = kDeviceTypeLaptop; | 151 *type = kDeviceTypeLaptop; |
| 152 } | 152 } |
| 153 return; | 153 return; |
| 154 } | 154 } |
| 155 | 155 |
| 156 *name = l10n_util::GetStringUTF8(IDS_HISTORY_UNKNOWN_DEVICE); | 156 *name = l10n_util::GetStringUTF8(IDS_HISTORY_UNKNOWN_DEVICE); |
| 157 *type = kDeviceTypeLaptop; | 157 *type = kDeviceTypeLaptop; |
| 158 } | 158 } |
| 159 | 159 |
| 160 void RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory(bool shown) { |
| 161 UMA_HISTOGRAM_BOOLEAN( |
| 162 "History.ShownHeaderAboutOtherFormsOfBrowsingHistory", |
| 163 shown); |
| 164 } |
| 165 |
| 160 } // namespace | 166 } // namespace |
| 161 | 167 |
| 162 BrowsingHistoryHandler::HistoryEntry::HistoryEntry( | 168 BrowsingHistoryHandler::HistoryEntry::HistoryEntry( |
| 163 BrowsingHistoryHandler::HistoryEntry::EntryType entry_type, | 169 BrowsingHistoryHandler::HistoryEntry::EntryType entry_type, |
| 164 const GURL& url, const base::string16& title, base::Time time, | 170 const GURL& url, const base::string16& title, base::Time time, |
| 165 const std::string& client_id, bool is_search_result, | 171 const std::string& client_id, bool is_search_result, |
| 166 const base::string16& snippet, bool blocked_visit) { | 172 const base::string16& snippet, bool blocked_visit) { |
| 167 this->entry_type = entry_type; | 173 this->entry_type = entry_type; |
| 168 this->url = url; | 174 this->url = url; |
| 169 this->title = title; | 175 this->title = title; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 FROM_HERE, base::TimeDelta::FromSeconds(kWebHistoryTimeoutSeconds), | 428 FROM_HERE, base::TimeDelta::FromSeconds(kWebHistoryTimeoutSeconds), |
| 423 this, &BrowsingHistoryHandler::WebHistoryTimeout); | 429 this, &BrowsingHistoryHandler::WebHistoryTimeout); |
| 424 | 430 |
| 425 // Test the existence of other forms of browsing history. | 431 // Test the existence of other forms of browsing history. |
| 426 browsing_data_ui::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( | 432 browsing_data_ui::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( |
| 427 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile), | 433 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile), |
| 428 web_history, | 434 web_history, |
| 429 base::Bind( | 435 base::Bind( |
| 430 &BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete, | 436 &BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete, |
| 431 weak_factory_.GetWeakPtr())); | 437 weak_factory_.GetWeakPtr())); |
| 438 } else { |
| 439 // The notice could not have been shown, because there is no web history. |
| 440 RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory(false); |
| 432 } | 441 } |
| 433 } | 442 } |
| 434 | 443 |
| 435 void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) { | 444 void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) { |
| 436 history::QueryOptions options; | 445 history::QueryOptions options; |
| 437 | 446 |
| 438 // Parse the arguments from JavaScript. There are five required arguments: | 447 // Parse the arguments from JavaScript. There are five required arguments: |
| 439 // - the text to search for (may be empty) | 448 // - the text to search for (may be empty) |
| 440 // - the offset from which the search should start (in multiples of week or | 449 // - the offset from which the search should start (in multiples of week or |
| 441 // month, set by the next argument). | 450 // month, set by the next argument). |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 } | 851 } |
| 843 has_synced_results_ = results_value != nullptr; | 852 has_synced_results_ = results_value != nullptr; |
| 844 results_info_value_.SetBoolean("hasSyncedResults", has_synced_results_); | 853 results_info_value_.SetBoolean("hasSyncedResults", has_synced_results_); |
| 845 if (!query_task_tracker_.HasTrackedTasks()) | 854 if (!query_task_tracker_.HasTrackedTasks()) |
| 846 ReturnResultsToFrontEnd(); | 855 ReturnResultsToFrontEnd(); |
| 847 } | 856 } |
| 848 | 857 |
| 849 void BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete( | 858 void BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete( |
| 850 bool found_other_forms_of_browsing_history) { | 859 bool found_other_forms_of_browsing_history) { |
| 851 has_other_forms_of_browsing_history_ = found_other_forms_of_browsing_history; | 860 has_other_forms_of_browsing_history_ = found_other_forms_of_browsing_history; |
| 861 |
| 862 RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory( |
| 863 has_other_forms_of_browsing_history_); |
| 864 |
| 852 web_ui()->CallJavascriptFunction( | 865 web_ui()->CallJavascriptFunction( |
| 853 "showNotification", | 866 "showNotification", |
| 854 base::FundamentalValue(has_synced_results_), | 867 base::FundamentalValue(has_synced_results_), |
| 855 base::FundamentalValue(has_other_forms_of_browsing_history_)); | 868 base::FundamentalValue(has_other_forms_of_browsing_history_)); |
| 856 } | 869 } |
| 857 | 870 |
| 858 void BrowsingHistoryHandler::RemoveComplete() { | 871 void BrowsingHistoryHandler::RemoveComplete() { |
| 859 urls_to_be_deleted_.clear(); | 872 urls_to_be_deleted_.clear(); |
| 860 | 873 |
| 861 // Notify the page that the deletion request is complete, but only if a web | 874 // Notify the page that the deletion request is complete, but only if a web |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 | 944 |
| 932 void BrowsingHistoryHandler::OnURLsDeleted( | 945 void BrowsingHistoryHandler::OnURLsDeleted( |
| 933 history::HistoryService* history_service, | 946 history::HistoryService* history_service, |
| 934 bool all_history, | 947 bool all_history, |
| 935 bool expired, | 948 bool expired, |
| 936 const history::URLRows& deleted_rows, | 949 const history::URLRows& deleted_rows, |
| 937 const std::set<GURL>& favicon_urls) { | 950 const std::set<GURL>& favicon_urls) { |
| 938 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) | 951 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) |
| 939 web_ui()->CallJavascriptFunction("historyDeleted"); | 952 web_ui()->CallJavascriptFunction("historyDeleted"); |
| 940 } | 953 } |
| OLD | NEW |