Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/history_ui.h" | 5 #include "chrome/browser/ui/webui/history_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 | 379 |
| 380 return result.Pass(); | 380 return result.Pass(); |
| 381 } | 381 } |
| 382 | 382 |
| 383 bool BrowsingHistoryHandler::HistoryEntry::SortByTimeDescending( | 383 bool BrowsingHistoryHandler::HistoryEntry::SortByTimeDescending( |
| 384 const BrowsingHistoryHandler::HistoryEntry& entry1, | 384 const BrowsingHistoryHandler::HistoryEntry& entry1, |
| 385 const BrowsingHistoryHandler::HistoryEntry& entry2) { | 385 const BrowsingHistoryHandler::HistoryEntry& entry2) { |
| 386 return entry1.time > entry2.time; | 386 return entry1.time > entry2.time; |
| 387 } | 387 } |
| 388 | 388 |
| 389 BrowsingHistoryHandler::BrowsingHistoryHandler() {} | 389 BrowsingHistoryHandler::BrowsingHistoryHandler() |
| 390 : pending_delete_requests_(0), weak_factory_(this) { | |
|
sky
2014/02/19 23:20:10
nit: one param per line (when you wrap).
davidben
2014/02/19 23:21:21
Done.
| |
| 391 } | |
| 390 | 392 |
| 391 BrowsingHistoryHandler::~BrowsingHistoryHandler() { | 393 BrowsingHistoryHandler::~BrowsingHistoryHandler() { |
| 392 history_request_consumer_.CancelAllRequests(); | 394 history_request_consumer_.CancelAllRequests(); |
| 393 web_history_request_.reset(); | 395 web_history_request_.reset(); |
| 394 } | 396 } |
| 395 | 397 |
| 396 void BrowsingHistoryHandler::RegisterMessages() { | 398 void BrowsingHistoryHandler::RegisterMessages() { |
| 397 // Create our favicon data source. | 399 // Create our favicon data source. |
| 398 Profile* profile = Profile::FromWebUI(web_ui()); | 400 Profile* profile = Profile::FromWebUI(web_ui()); |
| 399 content::URLDataSource::Add( | 401 content::URLDataSource::Add( |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 history_service->ProcessLocalDeleteDirective(delete_directive); | 607 history_service->ProcessLocalDeleteDirective(delete_directive); |
| 606 } | 608 } |
| 607 | 609 |
| 608 history_service->ExpireHistory( | 610 history_service->ExpireHistory( |
| 609 expire_list, | 611 expire_list, |
| 610 base::Bind(&BrowsingHistoryHandler::RemoveComplete, | 612 base::Bind(&BrowsingHistoryHandler::RemoveComplete, |
| 611 base::Unretained(this)), | 613 base::Unretained(this)), |
| 612 &delete_task_tracker_); | 614 &delete_task_tracker_); |
| 613 | 615 |
| 614 if (web_history) { | 616 if (web_history) { |
| 615 web_history_delete_request_ = web_history->ExpireHistory( | 617 pending_delete_requests_++; |
| 618 web_history->ExpireHistory( | |
| 616 expire_list, | 619 expire_list, |
| 617 base::Bind(&BrowsingHistoryHandler::RemoveWebHistoryComplete, | 620 base::Bind(&BrowsingHistoryHandler::RemoveWebHistoryComplete, |
| 618 base::Unretained(this))); | 621 weak_factory_.GetWeakPtr())); |
| 619 } | 622 } |
| 620 | 623 |
| 621 #if defined(ENABLE_EXTENSIONS) | 624 #if defined(ENABLE_EXTENSIONS) |
| 622 // If the profile has activity logging enabled also clean up any URLs from | 625 // If the profile has activity logging enabled also clean up any URLs from |
| 623 // the extension activity log. The extension activity log contains URLS | 626 // the extension activity log. The extension activity log contains URLS |
| 624 // which websites an extension has activity on so it will indirectly | 627 // which websites an extension has activity on so it will indirectly |
| 625 // contain websites that a user has visited. | 628 // contain websites that a user has visited. |
| 626 extensions::ActivityLog* activity_log = | 629 extensions::ActivityLog* activity_log = |
| 627 extensions::ActivityLog::GetInstance(profile); | 630 extensions::ActivityLog::GetInstance(profile); |
| 628 for (std::vector<history::ExpireHistoryArgs>::const_iterator it = | 631 for (std::vector<history::ExpireHistoryArgs>::const_iterator it = |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 results_info_value_.SetBoolean("hasSyncedResults", results_value != NULL); | 882 results_info_value_.SetBoolean("hasSyncedResults", results_value != NULL); |
| 880 if (!history_request_consumer_.HasPendingRequests()) | 883 if (!history_request_consumer_.HasPendingRequests()) |
| 881 ReturnResultsToFrontEnd(); | 884 ReturnResultsToFrontEnd(); |
| 882 } | 885 } |
| 883 | 886 |
| 884 void BrowsingHistoryHandler::RemoveComplete() { | 887 void BrowsingHistoryHandler::RemoveComplete() { |
| 885 urls_to_be_deleted_.clear(); | 888 urls_to_be_deleted_.clear(); |
| 886 | 889 |
| 887 // Notify the page that the deletion request is complete, but only if a web | 890 // Notify the page that the deletion request is complete, but only if a web |
| 888 // history delete request is not still pending. | 891 // history delete request is not still pending. |
| 889 if (!(web_history_delete_request_.get() && | 892 if (pending_delete_requests_ == 0) { |
| 890 web_history_delete_request_->is_pending())) { | |
| 891 web_ui()->CallJavascriptFunction("deleteComplete"); | 893 web_ui()->CallJavascriptFunction("deleteComplete"); |
| 892 } | 894 } |
| 893 } | 895 } |
| 894 | 896 |
| 895 void BrowsingHistoryHandler::RemoveWebHistoryComplete( | 897 void BrowsingHistoryHandler::RemoveWebHistoryComplete(bool success) { |
| 896 history::WebHistoryService::Request* request, bool success) { | 898 pending_delete_requests_--; |
| 897 // TODO(dubroy): Should we handle failure somehow? Delete directives will | 899 // TODO(dubroy): Should we handle failure somehow? Delete directives will |
| 898 // ensure that the visits are eventually deleted, so maybe it's not necessary. | 900 // ensure that the visits are eventually deleted, so maybe it's not necessary. |
| 899 if (!delete_task_tracker_.HasTrackedTasks()) | 901 if (!delete_task_tracker_.HasTrackedTasks()) |
| 900 RemoveComplete(); | 902 RemoveComplete(); |
| 901 } | 903 } |
| 902 | 904 |
| 903 void BrowsingHistoryHandler::SetQueryTimeInWeeks( | 905 void BrowsingHistoryHandler::SetQueryTimeInWeeks( |
| 904 int offset, history::QueryOptions* options) { | 906 int offset, history::QueryOptions* options) { |
| 905 // LocalMidnight returns the beginning of the current day so get the | 907 // LocalMidnight returns the beginning of the current day so get the |
| 906 // beginning of the next one. | 908 // beginning of the next one. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1006 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 1008 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
| 1007 net::EscapeQueryParamValue(base::UTF16ToUTF8(text), true)); | 1009 net::EscapeQueryParamValue(base::UTF16ToUTF8(text), true)); |
| 1008 } | 1010 } |
| 1009 | 1011 |
| 1010 // static | 1012 // static |
| 1011 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 1013 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
| 1012 ui::ScaleFactor scale_factor) { | 1014 ui::ScaleFactor scale_factor) { |
| 1013 return ResourceBundle::GetSharedInstance(). | 1015 return ResourceBundle::GetSharedInstance(). |
| 1014 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); | 1016 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); |
| 1015 } | 1017 } |
| OLD | NEW |