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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // - incognito mode (that is the point of this mode) | 74 // - incognito mode (that is the point of this mode) |
75 // - extensions (users don't think of extension installation as 'downloading') | 75 // - extensions (users don't think of extension installation as 'downloading') |
76 // - temporary download, like in drag-and-drop | 76 // - temporary download, like in drag-and-drop |
77 // - history service is not available (e.g. in tests) | 77 // - history service is not available (e.g. in tests) |
78 // We have to make sure that these handles don't collide with normal db | 78 // We have to make sure that these handles don't collide with normal db |
79 // handles, so we use a negative value. Eventually, they could overlap, but | 79 // handles, so we use a negative value. Eventually, they could overlap, but |
80 // you'd have to do enough downloading that your ISP would likely stab you in | 80 // you'd have to do enough downloading that your ISP would likely stab you in |
81 // the neck first. YMMV. | 81 // the neck first. YMMV. |
82 HistoryService* hs = | 82 HistoryService* hs = |
83 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 83 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
84 if (download_item->IsOtr() || | 84 if (download_crx_util::IsExtensionDownload(*download_item) || |
85 download_crx_util::IsExtensionDownload(*download_item) || | |
86 download_item->IsTemporary() || !hs) { | 85 download_item->IsTemporary() || !hs) { |
87 callback.Run(download_item->GetId(), GetNextFakeDbHandle()); | 86 callback.Run(download_item->GetId(), GetNextFakeDbHandle()); |
88 return; | 87 return; |
89 } | 88 } |
90 | 89 |
91 int32 id = download_item->GetId(); | 90 int32 id = download_item->GetId(); |
92 DownloadPersistentStoreInfo history_info = | 91 DownloadPersistentStoreInfo history_info = |
93 download_item->GetPersistentStoreInfo(); | 92 download_item->GetPersistentStoreInfo(); |
94 hs->CreateDownload(id, history_info, &history_consumer_, callback); | 93 hs->CreateDownload(id, history_info, &history_consumer_, callback); |
95 } | 94 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 int count, | 146 int count, |
148 base::Time first_visit) { | 147 base::Time first_visit) { |
149 VisitedBeforeRequestsMap::iterator request = | 148 VisitedBeforeRequestsMap::iterator request = |
150 visited_before_requests_.find(handle); | 149 visited_before_requests_.find(handle); |
151 DCHECK(request != visited_before_requests_.end()); | 150 DCHECK(request != visited_before_requests_.end()); |
152 VisitedBeforeDoneCallback callback = request->second; | 151 VisitedBeforeDoneCallback callback = request->second; |
153 visited_before_requests_.erase(request); | 152 visited_before_requests_.erase(request); |
154 callback.Run(found_visits && count && | 153 callback.Run(found_visits && count && |
155 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); | 154 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); |
156 } | 155 } |
OLD | NEW |