| 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/download/download_history.h" | 5 #include "chrome/browser/download/download_history.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/download/download_crx_util.h" | 8 #include "chrome/browser/download/download_crx_util.h" |
| 9 #include "chrome/browser/history/history_marshaling.h" | 9 #include "chrome/browser/history/history_marshaling.h" |
| 10 #include "chrome/browser/history/history_service_factory.h" | 10 #include "chrome/browser/history/history_service_factory.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle) | 98 if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle) |
| 99 return; | 99 return; |
| 100 | 100 |
| 101 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( | 101 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 102 profile_, Profile::EXPLICIT_ACCESS); | 102 profile_, Profile::EXPLICIT_ACCESS); |
| 103 if (!hs) | 103 if (!hs) |
| 104 return; | 104 return; |
| 105 hs->UpdateDownload(download_item->GetPersistentStoreInfo()); | 105 hs->UpdateDownload(download_item->GetPersistentStoreInfo()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void DownloadHistory::UpdateDownloadPath(DownloadItem* download_item, | 108 void DownloadHistory::UpdateDownloadPath( |
| 109 const FilePath& new_path) { | 109 DownloadItem* download_item, |
| 110 const FilePath& target_path, |
| 111 const FilePath& current_path) { |
| 110 // No update necessary if the download was initiated while in incognito mode. | 112 // No update necessary if the download was initiated while in incognito mode. |
| 111 if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle) | 113 if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle) |
| 112 return; | 114 return; |
| 113 | 115 |
| 114 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( | 116 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 115 profile_, Profile::EXPLICIT_ACCESS); | 117 profile_, Profile::EXPLICIT_ACCESS); |
| 116 if (hs) | 118 if (hs) |
| 117 hs->UpdateDownloadPath(new_path, download_item->GetDbHandle()); | 119 hs->UpdateDownloadPath(target_path, current_path, |
| 120 download_item->GetDbHandle()); |
| 118 } | 121 } |
| 119 | 122 |
| 120 void DownloadHistory::RemoveEntry(DownloadItem* download_item) { | 123 void DownloadHistory::RemoveEntry(DownloadItem* download_item) { |
| 121 // No update necessary if the download was initiated while in incognito mode. | 124 // No update necessary if the download was initiated while in incognito mode. |
| 122 if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle) | 125 if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle) |
| 123 return; | 126 return; |
| 124 | 127 |
| 125 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( | 128 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 126 profile_, Profile::EXPLICIT_ACCESS); | 129 profile_, Profile::EXPLICIT_ACCESS); |
| 127 if (hs) | 130 if (hs) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 145 int count, | 148 int count, |
| 146 base::Time first_visit) { | 149 base::Time first_visit) { |
| 147 VisitedBeforeRequestsMap::iterator request = | 150 VisitedBeforeRequestsMap::iterator request = |
| 148 visited_before_requests_.find(handle); | 151 visited_before_requests_.find(handle); |
| 149 DCHECK(request != visited_before_requests_.end()); | 152 DCHECK(request != visited_before_requests_.end()); |
| 150 VisitedBeforeDoneCallback callback = request->second; | 153 VisitedBeforeDoneCallback callback = request->second; |
| 151 visited_before_requests_.erase(request); | 154 visited_before_requests_.erase(request); |
| 152 callback.Run(found_visits && count && | 155 callback.Run(found_visits && count && |
| 153 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); | 156 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); |
| 154 } | 157 } |
| OLD | NEW |