Chromium Code Reviews| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 const base::string16& search_text, | 431 const base::string16& search_text, |
| 432 const history::QueryOptions& options) { | 432 const history::QueryOptions& options) { |
| 433 Profile* profile = Profile::FromWebUI(web_ui()); | 433 Profile* profile = Profile::FromWebUI(web_ui()); |
| 434 | 434 |
| 435 // Anything in-flight is invalid. | 435 // Anything in-flight is invalid. |
| 436 query_task_tracker_.TryCancelAll(); | 436 query_task_tracker_.TryCancelAll(); |
| 437 web_history_request_.reset(); | 437 web_history_request_.reset(); |
| 438 | 438 |
| 439 query_results_.clear(); | 439 query_results_.clear(); |
| 440 results_info_value_.Clear(); | 440 results_info_value_.Clear(); |
| 441 has_synced_results_ = false; | |
| 442 has_other_forms_of_browsing_history_ = false; | |
| 443 | 441 |
| 444 history::HistoryService* hs = HistoryServiceFactory::GetForProfile( | 442 history::HistoryService* hs = HistoryServiceFactory::GetForProfile( |
| 445 profile, ServiceAccessType::EXPLICIT_ACCESS); | 443 profile, ServiceAccessType::EXPLICIT_ACCESS); |
| 446 hs->QueryHistory(search_text, | 444 hs->QueryHistory(search_text, |
| 447 options, | 445 options, |
| 448 base::Bind(&BrowsingHistoryHandler::QueryComplete, | 446 base::Bind(&BrowsingHistoryHandler::QueryComplete, |
| 449 base::Unretained(this), | 447 base::Unretained(this), |
| 450 search_text, | 448 search_text, |
| 451 options), | 449 options), |
| 452 &query_task_tracker_); | 450 &query_task_tracker_); |
| 453 | 451 |
| 454 history::WebHistoryService* web_history = | 452 history::WebHistoryService* web_history = |
| 455 WebHistoryServiceFactory::GetForProfile(profile); | 453 WebHistoryServiceFactory::GetForProfile(profile); |
| 456 | 454 |
| 457 // Set this to false until the results actually arrive. | 455 // Set this to false until the results actually arrive. |
| 458 results_info_value_.SetBoolean("hasSyncedResults", false); | 456 results_info_value_.SetBoolean("hasSyncedResults", false); |
| 459 | 457 |
| 460 if (web_history) { | 458 if (web_history) { |
| 461 web_history_query_results_.clear(); | 459 web_history_query_results_.clear(); |
| 462 web_history_request_ = web_history->QueryHistory( | 460 web_history_request_ = web_history->QueryHistory( |
| 463 search_text, | 461 search_text, |
| 464 options, | 462 options, |
| 465 base::Bind(&BrowsingHistoryHandler::WebHistoryQueryComplete, | 463 base::Bind(&BrowsingHistoryHandler::WebHistoryQueryComplete, |
| 466 base::Unretained(this), | 464 base::Unretained(this), |
| 467 search_text, options, | 465 search_text, options, |
| 468 base::TimeTicks::Now())); | 466 base::TimeTicks::Now())); |
| 469 // Start a timer so we know when to give up. | 467 // Start a timer so we know when to give up. |
| 470 web_history_timer_.Start( | 468 web_history_timer_.Start( |
| 471 FROM_HERE, base::TimeDelta::FromSeconds(kWebHistoryTimeoutSeconds), | 469 FROM_HERE, base::TimeDelta::FromSeconds(kWebHistoryTimeoutSeconds), |
| 472 this, &BrowsingHistoryHandler::WebHistoryTimeout); | 470 this, &BrowsingHistoryHandler::WebHistoryTimeout); |
|
msramek
2016/09/21 08:54:38
WebHistoryTimeout() is kind of equivalent to WebHi
tsergeant
2016/09/22 00:19:59
Good point, done.
| |
| 473 | 471 |
| 474 // Test the existence of other forms of browsing history. | 472 // Test the existence of other forms of browsing history. |
| 475 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( | 473 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( |
| 476 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile), | 474 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile), |
| 477 web_history, | 475 web_history, |
| 478 base::Bind( | 476 base::Bind( |
| 479 &BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete, | 477 &BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete, |
| 480 weak_factory_.GetWeakPtr())); | 478 weak_factory_.GetWeakPtr())); |
| 481 } else { | 479 } else { |
| 482 // The notice could not have been shown, because there is no web history. | 480 // The notice could not have been shown, because there is no web history. |
| 483 RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory(false); | 481 RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory(false); |
| 482 has_synced_results_ = false; | |
| 483 has_other_forms_of_browsing_history_ = false; | |
| 484 } | 484 } |
| 485 } | 485 } |
| 486 | 486 |
| 487 void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) { | 487 void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) { |
| 488 history::QueryOptions options; | 488 history::QueryOptions options; |
| 489 | 489 |
| 490 // Parse the arguments from JavaScript. There are five required arguments: | 490 // Parse the arguments from JavaScript. There are five required arguments: |
| 491 // - the text to search for (may be empty) | 491 // - the text to search for (may be empty) |
| 492 // - the offset from which the search should start (in multiples of week or | 492 // - the offset from which the search should start (in multiples of week or |
| 493 // month, set by the next argument). | 493 // month, set by the next argument). |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1004 bool expired, | 1004 bool expired, |
| 1005 const history::URLRows& deleted_rows, | 1005 const history::URLRows& deleted_rows, |
| 1006 const std::set<GURL>& favicon_urls) { | 1006 const std::set<GURL>& favicon_urls) { |
| 1007 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) | 1007 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) |
| 1008 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); | 1008 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 void BrowsingHistoryHandler::OnWebHistoryDeleted() { | 1011 void BrowsingHistoryHandler::OnWebHistoryDeleted() { |
| 1012 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); | 1012 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); |
| 1013 } | 1013 } |
| OLD | NEW |