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 "content/browser/download/download_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 326 |
327 // We'll have nothing more to report to the observers after this point. | 327 // We'll have nothing more to report to the observers after this point. |
328 observers_.Clear(); | 328 observers_.Clear(); |
329 | 329 |
330 file_manager_ = NULL; | 330 file_manager_ = NULL; |
331 if (delegate_) | 331 if (delegate_) |
332 delegate_->Shutdown(); | 332 delegate_->Shutdown(); |
333 delegate_ = NULL; | 333 delegate_ = NULL; |
334 } | 334 } |
335 | 335 |
336 void DownloadManagerImpl::SearchDownloads(const string16& query, | |
337 DownloadVector* result) { | |
338 string16 query_lower(base::i18n::ToLower(query)); | |
339 | |
340 for (DownloadMap::iterator it = downloads_.begin(); | |
341 it != downloads_.end(); ++it) { | |
342 DownloadItemImpl* download_item = it->second; | |
343 // TODO(benjhayden): Don't check IsPersisted(). | |
344 if (!download_item->IsTemporary() && | |
345 download_item->IsPersisted() && | |
346 download_item->MatchesQuery(query_lower)) { | |
347 result->push_back(download_item); | |
348 } | |
349 } | |
350 } | |
351 | |
352 bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) { | 336 bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) { |
353 DCHECK(browser_context); | 337 DCHECK(browser_context); |
354 DCHECK(!shutdown_needed_) << "DownloadManager already initialized."; | 338 DCHECK(!shutdown_needed_) << "DownloadManager already initialized."; |
355 shutdown_needed_ = true; | 339 shutdown_needed_ = true; |
356 | 340 |
357 browser_context_ = browser_context; | 341 browser_context_ = browser_context; |
358 | 342 |
359 return true; | 343 return true; |
360 } | 344 } |
361 | 345 |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 void DownloadManagerImpl::DownloadRenamedToFinalName( | 1046 void DownloadManagerImpl::DownloadRenamedToFinalName( |
1063 DownloadItemImpl* download) { | 1047 DownloadItemImpl* download) { |
1064 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1048 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1065 // If the rename failed, we receive an OnDownloadInterrupted() call before we | 1049 // If the rename failed, we receive an OnDownloadInterrupted() call before we |
1066 // receive the DownloadRenamedToFinalName() call. | 1050 // receive the DownloadRenamedToFinalName() call. |
1067 if (delegate_) { | 1051 if (delegate_) { |
1068 delegate_->UpdatePathForItemInPersistentStore( | 1052 delegate_->UpdatePathForItemInPersistentStore( |
1069 download, download->GetFullPath()); | 1053 download, download->GetFullPath()); |
1070 } | 1054 } |
1071 } | 1055 } |
OLD | NEW |