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