| 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_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/imageburner/imageburner_ui.h" |
| 6 #include "chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h" | 6 #include "chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h" |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 if (state_machine_->state() == StateMachine::DOWNLOADING && !CheckNetwork()) { | 214 if (state_machine_->state() == StateMachine::DOWNLOADING && !CheckNetwork()) { |
| 215 ProcessError(IDS_IMAGEBURN_NETWORK_ERROR); | 215 ProcessError(IDS_IMAGEBURN_NETWORK_ERROR); |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 void WebUIHandler::OnDownloadUpdated(DownloadItem* download) { | 219 void WebUIHandler::OnDownloadUpdated(DownloadItem* download) { |
| 220 if (download->IsCancelled()) { | 220 if (download->IsCancelled()) { |
| 221 DownloadCompleted(false); | 221 DownloadCompleted(false); |
| 222 DCHECK(!active_download_item_); | 222 DCHECK(!active_download_item_); |
| 223 } else if (download->IsComplete()) { | 223 } else if (download->IsComplete()) { |
| 224 burn_manager_->set_final_zip_file_path(download->full_path()); | 224 burn_manager_->set_final_zip_file_path(download->GetFullPath()); |
| 225 DownloadCompleted(true); | 225 DownloadCompleted(true); |
| 226 DCHECK(!active_download_item_); | 226 DCHECK(!active_download_item_); |
| 227 } else if (download->IsPartialDownload() && | 227 } else if (download->IsPartialDownload() && |
| 228 state_machine_->state() == StateMachine::DOWNLOADING) { | 228 state_machine_->state() == StateMachine::DOWNLOADING) { |
| 229 base::TimeDelta remaining_time; | 229 base::TimeDelta remaining_time; |
| 230 download->TimeRemaining(&remaining_time); | 230 download->TimeRemaining(&remaining_time); |
| 231 SendProgressSignal(DOWNLOAD, download->received_bytes(), | 231 SendProgressSignal(DOWNLOAD, download->GetReceivedBytes(), |
| 232 download->total_bytes(), &remaining_time); | 232 download->GetTotalBytes(), &remaining_time); |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 void WebUIHandler::OnDownloadOpened(DownloadItem* download) { | 236 void WebUIHandler::OnDownloadOpened(DownloadItem* download) { |
| 237 if (download->safety_state() == DownloadItem::DANGEROUS) | 237 if (download->GetSafetyState() == DownloadItem::DANGEROUS) |
| 238 download->DangerousDownloadValidated(); | 238 download->DangerousDownloadValidated(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void WebUIHandler::ModelChanged() { | 241 void WebUIHandler::ModelChanged() { |
| 242 // Find our item and observe it. | 242 // Find our item and observe it. |
| 243 std::vector<DownloadItem*> downloads; | 243 std::vector<DownloadItem*> downloads; |
| 244 download_manager_->GetTemporaryDownloads( | 244 download_manager_->GetTemporaryDownloads( |
| 245 burn_manager_->GetImageDir(), &downloads); | 245 burn_manager_->GetImageDir(), &downloads); |
| 246 if (active_download_item_) | 246 if (active_download_item_) |
| 247 return; | 247 return; |
| 248 for (std::vector<DownloadItem*>::const_iterator it = downloads.begin(); | 248 for (std::vector<DownloadItem*>::const_iterator it = downloads.begin(); |
| 249 it != downloads.end(); | 249 it != downloads.end(); |
| 250 ++it) { | 250 ++it) { |
| 251 if ((*it)->original_url() == image_download_url_) { | 251 if ((*it)->GetOriginalUrl() == image_download_url_) { |
| 252 (*it)->AddObserver(this); | 252 (*it)->AddObserver(this); |
| 253 active_download_item_ = *it; | 253 active_download_item_ = *it; |
| 254 break; | 254 break; |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 | 258 |
| 259 void WebUIHandler::OnBurnDownloadStarted(bool success) { | 259 void WebUIHandler::OnBurnDownloadStarted(bool success) { |
| 260 if (success) | 260 if (success) |
| 261 state_machine_->OnDownloadStarted(); | 261 state_machine_->OnDownloadStarted(); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 //////////////////////////////////////////////////////////////////////////////// | 632 //////////////////////////////////////////////////////////////////////////////// |
| 633 | 633 |
| 634 ImageBurnUI::ImageBurnUI(TabContents* contents) : ChromeWebUI(contents) { | 634 ImageBurnUI::ImageBurnUI(TabContents* contents) : ChromeWebUI(contents) { |
| 635 imageburner::WebUIHandler* handler = new imageburner::WebUIHandler(contents); | 635 imageburner::WebUIHandler* handler = new imageburner::WebUIHandler(contents); |
| 636 AddMessageHandler((handler)->Attach(this)); | 636 AddMessageHandler((handler)->Attach(this)); |
| 637 | 637 |
| 638 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 638 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
| 639 profile->GetChromeURLDataManager()->AddDataSource( | 639 profile->GetChromeURLDataManager()->AddDataSource( |
| 640 CreateImageburnerUIHTMLSource()); | 640 CreateImageburnerUIHTMLSource()); |
| 641 } | 641 } |
| OLD | NEW |