| 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/chromeos/imageburner/imageburner_utils.h" | 5 #include "chrome/browser/ui/webui/chromeos/imageburner/imageburner_utils.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 438 |
| 439 if (created_file_stream) { | 439 if (created_file_stream) { |
| 440 DownloadManager* download_manager = | 440 DownloadManager* download_manager = |
| 441 tab_contents->GetBrowserContext()->GetDownloadManager(); | 441 tab_contents->GetBrowserContext()->GetDownloadManager(); |
| 442 DownloadSaveInfo save_info; | 442 DownloadSaveInfo save_info; |
| 443 save_info.file_path = file_path; | 443 save_info.file_path = file_path; |
| 444 save_info.file_stream = linked_ptr<net::FileStream>(created_file_stream); | 444 save_info.file_stream = linked_ptr<net::FileStream>(created_file_stream); |
| 445 DownloadStarted(true, url); | 445 DownloadStarted(true, url); |
| 446 download_manager->DownloadUrlToFile(url, | 446 download_manager->DownloadUrlToFile(url, |
| 447 tab_contents->GetURL(), | 447 tab_contents->GetURL(), |
| 448 tab_contents->encoding(), | 448 tab_contents->GetEncoding(), |
| 449 save_info, | 449 save_info, |
| 450 tab_contents); | 450 tab_contents); |
| 451 } else { | 451 } else { |
| 452 DownloadStarted(false, url); | 452 DownloadStarted(false, url); |
| 453 } | 453 } |
| 454 } | 454 } |
| 455 | 455 |
| 456 void Downloader::AddListener(Listener* listener, const GURL& url) { | 456 void Downloader::AddListener(Listener* listener, const GURL& url) { |
| 457 listeners_.insert(std::make_pair(url, listener->AsWeakPtr())); | 457 listeners_.insert(std::make_pair(url, listener->AsWeakPtr())); |
| 458 } | 458 } |
| 459 | 459 |
| 460 void Downloader::DownloadStarted(bool success, const GURL& url) { | 460 void Downloader::DownloadStarted(bool success, const GURL& url) { |
| 461 std::pair<ListenerMap::iterator, ListenerMap::iterator> listener_range = | 461 std::pair<ListenerMap::iterator, ListenerMap::iterator> listener_range = |
| 462 listeners_.equal_range(url); | 462 listeners_.equal_range(url); |
| 463 for (ListenerMap::iterator current_listener = listener_range.first; | 463 for (ListenerMap::iterator current_listener = listener_range.first; |
| 464 current_listener != listener_range.second; | 464 current_listener != listener_range.second; |
| 465 ++current_listener) { | 465 ++current_listener) { |
| 466 if (current_listener->second) | 466 if (current_listener->second) |
| 467 current_listener->second->OnBurnDownloadStarted(success); | 467 current_listener->second->OnBurnDownloadStarted(success); |
| 468 } | 468 } |
| 469 listeners_.erase(listener_range.first, listener_range.second); | 469 listeners_.erase(listener_range.first, listener_range.second); |
| 470 } | 470 } |
| 471 | 471 |
| 472 } // namespace imageburner. | 472 } // namespace imageburner. |
| 473 | 473 |
| OLD | NEW |