OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/dom_ui/imageburner_ui.h" | 5 #include "chrome/browser/chromeos/dom_ui/imageburner_ui.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 download_item_observer_added_(false), | 98 download_item_observer_added_(false), |
99 active_download_item_(NULL), | 99 active_download_item_(NULL), |
100 burn_resource_manager_(NULL) { | 100 burn_resource_manager_(NULL) { |
101 chromeos::MountLibrary* mount_lib = | 101 chromeos::MountLibrary* mount_lib = |
102 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 102 chromeos::CrosLibrary::Get()->GetMountLibrary(); |
103 mount_lib->AddObserver(this); | 103 mount_lib->AddObserver(this); |
104 chromeos::BurnLibrary* burn_lib = | 104 chromeos::BurnLibrary* burn_lib = |
105 chromeos::CrosLibrary::Get()->GetBurnLibrary(); | 105 chromeos::CrosLibrary::Get()->GetBurnLibrary(); |
106 burn_lib->AddObserver(this); | 106 burn_lib->AddObserver(this); |
107 local_image_file_path_.clear(); | 107 local_image_file_path_.clear(); |
108 burn_resource_manager_ = Singleton<ImageBurnResourceManager>::get(); | 108 burn_resource_manager_ = ImageBurnResourceManager::GetInstance(); |
109 } | 109 } |
110 | 110 |
111 ImageBurnHandler::~ImageBurnHandler() { | 111 ImageBurnHandler::~ImageBurnHandler() { |
112 chromeos::MountLibrary* mount_lib = | 112 chromeos::MountLibrary* mount_lib = |
113 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 113 chromeos::CrosLibrary::Get()->GetMountLibrary(); |
114 mount_lib->RemoveObserver(this); | 114 mount_lib->RemoveObserver(this); |
115 chromeos::BurnLibrary* burn_lib = | 115 chromeos::BurnLibrary* burn_lib = |
116 chromeos::CrosLibrary::Get()->GetBurnLibrary(); | 116 chromeos::CrosLibrary::Get()->GetBurnLibrary(); |
117 burn_lib->RemoveObserver(this); | 117 burn_lib->RemoveObserver(this); |
118 if (active_download_item_) { | 118 if (active_download_item_) { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 } | 391 } |
392 | 392 |
393 //////////////////////////////////////////////////////////////////////////////// | 393 //////////////////////////////////////////////////////////////////////////////// |
394 // | 394 // |
395 // ImageBurnTaskProxy | 395 // ImageBurnTaskProxy |
396 // | 396 // |
397 //////////////////////////////////////////////////////////////////////////////// | 397 //////////////////////////////////////////////////////////////////////////////// |
398 ImageBurnTaskProxy::ImageBurnTaskProxy( | 398 ImageBurnTaskProxy::ImageBurnTaskProxy( |
399 const base::WeakPtr<ImageBurnHandler>& handler) | 399 const base::WeakPtr<ImageBurnHandler>& handler) |
400 : handler_(handler) { | 400 : handler_(handler) { |
401 resource_manager_ = Singleton<ImageBurnResourceManager>::get(); | 401 resource_manager_ = ImageBurnResourceManager::GetInstance(); |
402 } | 402 } |
403 | 403 |
404 bool ImageBurnTaskProxy::ReportDownloadInitialized() { | 404 bool ImageBurnTaskProxy::ReportDownloadInitialized() { |
405 bool initialized = resource_manager_-> CheckImageDownloadStarted(); | 405 bool initialized = resource_manager_-> CheckImageDownloadStarted(); |
406 if (!initialized) | 406 if (!initialized) |
407 resource_manager_-> ReportImageDownloadStarted(); | 407 resource_manager_-> ReportImageDownloadStarted(); |
408 return initialized; | 408 return initialized; |
409 } | 409 } |
410 | 410 |
411 bool ImageBurnTaskProxy::CheckDownloadFinished() { | 411 bool ImageBurnTaskProxy::CheckDownloadFinished() { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 if (!local_image_dir_file_path_.empty()) { | 457 if (!local_image_dir_file_path_.empty()) { |
458 file_util::Delete(local_image_dir_file_path_, true); | 458 file_util::Delete(local_image_dir_file_path_, true); |
459 } | 459 } |
460 if (active_download_item_) { | 460 if (active_download_item_) { |
461 active_download_item_->RemoveObserver(this); | 461 active_download_item_->RemoveObserver(this); |
462 } | 462 } |
463 if (download_manager_) | 463 if (download_manager_) |
464 download_manager_->RemoveObserver(this); | 464 download_manager_->RemoveObserver(this); |
465 } | 465 } |
466 | 466 |
| 467 // static |
| 468 ImageBurnResourceManager* ImageBurnResourceManager::GetInstance() { |
| 469 return Singleton<ImageBurnResourceManager>::get(); |
| 470 } |
| 471 |
467 void ImageBurnResourceManager::OnDownloadUpdated(DownloadItem* download) { | 472 void ImageBurnResourceManager::OnDownloadUpdated(DownloadItem* download) { |
468 if (download->state() == DownloadItem::CANCELLED) { | 473 if (download->state() == DownloadItem::CANCELLED) { |
469 image_url_.reset(); | 474 image_url_.reset(); |
470 ImageUrlFetched(false); | 475 ImageUrlFetched(false); |
471 } | 476 } |
472 } | 477 } |
473 | 478 |
474 void ImageBurnResourceManager::OnDownloadFileCompleted(DownloadItem* download) { | 479 void ImageBurnResourceManager::OnDownloadFileCompleted(DownloadItem* download) { |
475 DCHECK(download->state() == DownloadItem::COMPLETE); | 480 DCHECK(download->state() == DownloadItem::COMPLETE); |
476 std::string image_url; | 481 std::string image_url; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 ImageBurnHandler* handler = new ImageBurnHandler(contents); | 612 ImageBurnHandler* handler = new ImageBurnHandler(contents); |
608 AddMessageHandler((handler)->Attach(this)); | 613 AddMessageHandler((handler)->Attach(this)); |
609 ImageBurnUIHTMLSource* html_source = new ImageBurnUIHTMLSource(); | 614 ImageBurnUIHTMLSource* html_source = new ImageBurnUIHTMLSource(); |
610 BrowserThread::PostTask( | 615 BrowserThread::PostTask( |
611 BrowserThread::IO, FROM_HERE, | 616 BrowserThread::IO, FROM_HERE, |
612 NewRunnableMethod( | 617 NewRunnableMethod( |
613 ChromeURLDataManager::GetInstance(), | 618 ChromeURLDataManager::GetInstance(), |
614 &ChromeURLDataManager::AddDataSource, | 619 &ChromeURLDataManager::AddDataSource, |
615 make_scoped_refptr(html_source))); | 620 make_scoped_refptr(html_source))); |
616 } | 621 } |
OLD | NEW |