OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chrome_download_manager_delegate.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/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "content/public/browser/download_item.h" | 11 #include "content/public/browser/download_item.h" |
12 #include "content/public/browser/download_persistent_store_info.h" | 12 #include "content/public/browser/download_persistent_store_info.h" |
13 | 13 |
14 using content::DownloadItem; | 14 using content::DownloadItem; |
15 using content::DownloadPersistentStoreInfo; | 15 using content::DownloadPersistentStoreInfo; |
16 | 16 |
17 DownloadHistory::DownloadHistory(Profile* profile) | 17 DownloadHistory::DownloadHistory(Profile* profile) |
18 : profile_(profile), | 18 : profile_(profile), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // - incognito mode (that is the point of this mode) | 69 // - incognito mode (that is the point of this mode) |
70 // - extensions (users don't think of extension installation as 'downloading') | 70 // - extensions (users don't think of extension installation as 'downloading') |
71 // - temporary download, like in drag-and-drop | 71 // - temporary download, like in drag-and-drop |
72 // - history service is not available (e.g. in tests) | 72 // - history service is not available (e.g. in tests) |
73 // We have to make sure that these handles don't collide with normal db | 73 // We have to make sure that these handles don't collide with normal db |
74 // handles, so we use a negative value. Eventually, they could overlap, but | 74 // handles, so we use a negative value. Eventually, they could overlap, but |
75 // you'd have to do enough downloading that your ISP would likely stab you in | 75 // you'd have to do enough downloading that your ISP would likely stab you in |
76 // the neck first. YMMV. | 76 // the neck first. YMMV. |
77 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); | 77 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
78 if (download_item->IsOtr() || | 78 if (download_item->IsOtr() || |
79 ChromeDownloadManagerDelegate::IsExtensionDownload(download_item) || | 79 download_crx_util::IsExtensionDownload(*download_item) || |
80 download_item->IsTemporary() || !hs) { | 80 download_item->IsTemporary() || !hs) { |
81 callback.Run(download_item->GetId(), GetNextFakeDbHandle()); | 81 callback.Run(download_item->GetId(), GetNextFakeDbHandle()); |
82 return; | 82 return; |
83 } | 83 } |
84 | 84 |
85 int32 id = download_item->GetId(); | 85 int32 id = download_item->GetId(); |
86 DownloadPersistentStoreInfo history_info = | 86 DownloadPersistentStoreInfo history_info = |
87 download_item->GetPersistentStoreInfo(); | 87 download_item->GetPersistentStoreInfo(); |
88 hs->CreateDownload(id, history_info, &history_consumer_, callback); | 88 hs->CreateDownload(id, history_info, &history_consumer_, callback); |
89 } | 89 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 base::Time first_visit) { | 138 base::Time first_visit) { |
139 VisitedBeforeRequestsMap::iterator request = | 139 VisitedBeforeRequestsMap::iterator request = |
140 visited_before_requests_.find(handle); | 140 visited_before_requests_.find(handle); |
141 DCHECK(request != visited_before_requests_.end()); | 141 DCHECK(request != visited_before_requests_.end()); |
142 int32 download_id = request->second.first; | 142 int32 download_id = request->second.first; |
143 VisitedBeforeDoneCallback callback = request->second.second; | 143 VisitedBeforeDoneCallback callback = request->second.second; |
144 visited_before_requests_.erase(request); | 144 visited_before_requests_.erase(request); |
145 callback.Run(download_id, found_visits && count && | 145 callback.Run(download_id, found_visits && count && |
146 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); | 146 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); |
147 } | 147 } |
OLD | NEW |