| 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/ui/webui/downloads_dom_handler.h" | 5 #include "chrome/browser/ui/webui/downloads_dom_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "ui/gfx/image/image.h" | 38 #include "ui/gfx/image/image.h" |
| 39 | 39 |
| 40 #if !defined(OS_MACOSX) | 40 #if !defined(OS_MACOSX) |
| 41 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
| 45 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 45 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 using content::BrowserContext; |
| 48 using content::BrowserThread; | 49 using content::BrowserThread; |
| 49 using content::UserMetricsAction; | 50 using content::UserMetricsAction; |
| 50 | 51 |
| 51 namespace { | 52 namespace { |
| 52 | 53 |
| 53 // Maximum number of downloads to show. TODO(glen): Remove this and instead | 54 // Maximum number of downloads to show. TODO(glen): Remove this and instead |
| 54 // stuff the downloads down the pipe slowly. | 55 // stuff the downloads down the pipe slowly. |
| 55 static const int kMaxDownloads = 150; | 56 static const int kMaxDownloads = 150; |
| 56 | 57 |
| 57 // Sort DownloadItems into descending order by their start time. | 58 // Sort DownloadItems into descending order by their start time. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 original_profile_download_manager_(NULL), | 95 original_profile_download_manager_(NULL), |
| 95 initialized_(false), | 96 initialized_(false), |
| 96 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 97 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| 97 // Create our fileicon data source. | 98 // Create our fileicon data source. |
| 98 Profile* profile = Profile::FromBrowserContext(dlm->GetBrowserContext()); | 99 Profile* profile = Profile::FromBrowserContext(dlm->GetBrowserContext()); |
| 99 ChromeURLDataManager::AddDataSource(profile, new FileIconSource()); | 100 ChromeURLDataManager::AddDataSource(profile, new FileIconSource()); |
| 100 | 101 |
| 101 // Figure out our parent DownloadManager, if any. | 102 // Figure out our parent DownloadManager, if any. |
| 102 Profile* original_profile = profile->GetOriginalProfile(); | 103 Profile* original_profile = profile->GetOriginalProfile(); |
| 103 if (original_profile != profile) { | 104 if (original_profile != profile) { |
| 104 original_profile_download_manager_ = DownloadServiceFactory::GetForProfile( | 105 original_profile_download_manager_ = |
| 105 original_profile)->GetDownloadManager(); | 106 BrowserContext::GetDownloadManager(original_profile); |
| 106 } | 107 } |
| 107 } | 108 } |
| 108 | 109 |
| 109 DownloadsDOMHandler::~DownloadsDOMHandler() { | 110 DownloadsDOMHandler::~DownloadsDOMHandler() { |
| 110 ClearDownloadItems(); | 111 ClearDownloadItems(); |
| 111 download_manager_->RemoveObserver(this); | 112 download_manager_->RemoveObserver(this); |
| 112 if (original_profile_download_manager_) | 113 if (original_profile_download_manager_) |
| 113 original_profile_download_manager_->RemoveObserver(this); | 114 original_profile_download_manager_->RemoveObserver(this); |
| 114 } | 115 } |
| 115 | 116 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 } | 405 } |
| 405 | 406 |
| 406 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( | 407 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( |
| 407 const ListValue* args) { | 408 const ListValue* args) { |
| 408 int id; | 409 int id; |
| 409 if (ExtractIntegerValue(args, &id)) { | 410 if (ExtractIntegerValue(args, &id)) { |
| 410 return GetDownloadById(id); | 411 return GetDownloadById(id); |
| 411 } | 412 } |
| 412 return NULL; | 413 return NULL; |
| 413 } | 414 } |
| OLD | NEW |