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