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/ui/webui/active_downloads_ui.h" | 5 #include "chrome/browser/ui/webui/active_downloads_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/string_piece.h" | 19 #include "base/string_piece.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
21 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
22 #include "base/time.h" | 22 #include "base/time.h" |
23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
24 #include "base/values.h" | 24 #include "base/values.h" |
25 #include "chrome/browser/chromeos/cros/cros_library.h" | 25 #include "chrome/browser/chromeos/cros/cros_library.h" |
26 #include "chrome/browser/chromeos/login/user_manager.h" | 26 #include "chrome/browser/chromeos/login/user_manager.h" |
27 #include "chrome/browser/chromeos/media/media_player.h" | 27 #include "chrome/browser/chromeos/media/media_player.h" |
| 28 #include "chrome/browser/download/download_service.h" |
| 29 #include "chrome/browser/download/download_service_factory.h" |
28 #include "chrome/browser/download/download_util.h" | 30 #include "chrome/browser/download/download_util.h" |
29 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/tabs/tab_strip_model.h" | 32 #include "chrome/browser/tabs/tab_strip_model.h" |
31 #include "chrome/browser/ui/browser.h" | 33 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_list.h" | 34 #include "chrome/browser/ui/browser_list.h" |
33 #include "chrome/browser/ui/browser_window.h" | 35 #include "chrome/browser/ui/browser_window.h" |
34 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 36 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
35 #include "chrome/browser/ui/webui/fileicon_source_chromeos.h" | 37 #include "chrome/browser/ui/webui/fileicon_source_chromeos.h" |
36 #include "chrome/common/chrome_paths.h" | 38 #include "chrome/common/chrome_paths.h" |
37 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 212 } |
211 | 213 |
212 WebUIMessageHandler* ActiveDownloadsHandler::Attach(WebUI* web_ui) { | 214 WebUIMessageHandler* ActiveDownloadsHandler::Attach(WebUI* web_ui) { |
213 profile_ = Profile::FromWebUI(web_ui); | 215 profile_ = Profile::FromWebUI(web_ui); |
214 profile_->GetChromeURLDataManager()->AddDataSource(new FileIconSourceCros()); | 216 profile_->GetChromeURLDataManager()->AddDataSource(new FileIconSourceCros()); |
215 tab_contents_ = web_ui->tab_contents(); | 217 tab_contents_ = web_ui->tab_contents(); |
216 return WebUIMessageHandler::Attach(web_ui); | 218 return WebUIMessageHandler::Attach(web_ui); |
217 } | 219 } |
218 | 220 |
219 void ActiveDownloadsHandler::Init() { | 221 void ActiveDownloadsHandler::Init() { |
220 download_manager_ = profile_->GetDownloadManager(); | 222 download_manager_ = |
| 223 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); |
221 download_manager_->AddObserver(this); | 224 download_manager_->AddObserver(this); |
222 } | 225 } |
223 | 226 |
224 void ActiveDownloadsHandler::RegisterMessages() { | 227 void ActiveDownloadsHandler::RegisterMessages() { |
225 web_ui_->RegisterMessageCallback("getDownloads", | 228 web_ui_->RegisterMessageCallback("getDownloads", |
226 base::Bind(&ActiveDownloadsHandler::HandleGetDownloads, | 229 base::Bind(&ActiveDownloadsHandler::HandleGetDownloads, |
227 base::Unretained(this))); | 230 base::Unretained(this))); |
228 web_ui_->RegisterMessageCallback("pauseToggleDownload", | 231 web_ui_->RegisterMessageCallback("pauseToggleDownload", |
229 base::Bind(&ActiveDownloadsHandler::HandlePauseToggleDownload, | 232 base::Bind(&ActiveDownloadsHandler::HandlePauseToggleDownload, |
230 base::Unretained(this))); | 233 base::Unretained(this))); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 } | 467 } |
465 } | 468 } |
466 } | 469 } |
467 return NULL; | 470 return NULL; |
468 } | 471 } |
469 #endif // defined(TOUCH_UI) | 472 #endif // defined(TOUCH_UI) |
470 | 473 |
471 const ActiveDownloadsUI::DownloadList& ActiveDownloadsUI::GetDownloads() const { | 474 const ActiveDownloadsUI::DownloadList& ActiveDownloadsUI::GetDownloads() const { |
472 return handler_->downloads(); | 475 return handler_->downloads(); |
473 } | 476 } |
OLD | NEW |