Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/singleton.h" | 14 #include "base/singleton.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/task.h" | 16 #include "base/task.h" |
| 17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/browser/browser_thread.h" | 19 #include "chrome/browser/browser_thread.h" |
| 20 #include "chrome/browser/download/download_types.h" | 20 #include "chrome/browser/download/download_types.h" |
| 21 #include "chrome/browser/download/download_util.h" | 21 #include "chrome/browser/download/download_util.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/tab_contents/tab_contents.h" | 23 #include "chrome/browser/tab_contents/tab_contents.h" |
| 24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/jstemplate_builder.h" | 25 #include "chrome/common/jstemplate_builder.h" |
| 26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 27 #include "grit/browser_resources.h" | 27 #include "grit/browser_resources.h" |
| 28 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 29 #include "grit/locale_settings.h" | 29 #include "grit/locale_settings.h" |
| 30 #include "third_party/zlib/contrib/minizip/unzip.h" | |
| 30 | 31 |
| 31 | 32 |
| 32 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
| 33 // | 34 // |
| 34 // ImageBurnUIHTMLSource | 35 // ImageBurnUIHTMLSource |
| 35 // | 36 // |
| 36 //////////////////////////////////////////////////////////////////////////////// | 37 //////////////////////////////////////////////////////////////////////////////// |
| 37 | 38 |
| 38 ImageBurnUIHTMLSource::ImageBurnUIHTMLSource() | 39 class ImageBurnUIHTMLSource : public ChromeURLDataManager::DataSource { |
| 39 : DataSource(chrome::kChromeUIImageBurnerHost, MessageLoop::current()) { | 40 public: |
| 40 } | 41 ImageBurnUIHTMLSource() |
| 42 : DataSource(chrome::kChromeUIImageBurnerHost, MessageLoop::current()) { | |
|
xiyuan
2011/01/25 17:28:30
nit: indent 4 more spaces
achuithb
2011/01/25 22:21:45
Done.
| |
| 43 } | |
| 41 | 44 |
| 42 void ImageBurnUIHTMLSource::StartDataRequest(const std::string& path, | 45 // Called when the network layer has requested a resource underneath |
| 43 bool is_off_the_record, | 46 // the path we registered. |
| 44 int request_id) { | 47 virtual void StartDataRequest(const std::string& path, |
| 45 DictionaryValue localized_strings; | 48 bool is_off_the_record, |
| 46 localized_strings.SetString("burnConfirmText1", | 49 int request_id) { |
| 47 l10n_util::GetStringUTF16(IDS_IMAGEBURN_CONFIM_BURN1)); | 50 DictionaryValue localized_strings; |
| 48 localized_strings.SetString("burnConfirmText2", | 51 localized_strings.SetString("burnConfirmText1", |
| 49 l10n_util::GetStringUTF16(IDS_IMAGEBURN_CONFIM_BURN2)); | 52 l10n_util::GetStringUTF16(IDS_IMAGEBURN_CONFIM_BURN1)); |
| 50 localized_strings.SetString("burnUnsuccessfulMessage", | 53 localized_strings.SetString("burnConfirmText2", |
| 51 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_UNSUCCESSFUL)); | 54 l10n_util::GetStringUTF16(IDS_IMAGEBURN_CONFIM_BURN2)); |
| 52 localized_strings.SetString("burnSuccessfulMessage", | 55 localized_strings.SetString("burnUnsuccessfulMessage", |
| 53 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_SUCCESSFUL)); | 56 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_UNSUCCESSFUL)); |
| 54 localized_strings.SetString("downloadAbortedMessage", | 57 localized_strings.SetString("burnSuccessfulMessage", |
| 55 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_UNSUCCESSFUL)); | 58 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_SUCCESSFUL)); |
| 56 localized_strings.SetString("title", | 59 localized_strings.SetString("downloadAbortedMessage", |
| 57 l10n_util::GetStringUTF16(IDS_IMAGEBURN_TITLE)); | 60 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_UNSUCCESSFUL)); |
| 58 localized_strings.SetString("listTitle", | 61 localized_strings.SetString("title", |
| 59 l10n_util::GetStringUTF16(IDS_IMAGEBURN_ROOT_LIST_TITLE)); | 62 l10n_util::GetStringUTF16(IDS_IMAGEBURN_TITLE)); |
| 60 localized_strings.SetString("downloadStatusStart", | 63 localized_strings.SetString("listTitle", |
| 61 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_STARTING_STATUS)); | 64 l10n_util::GetStringUTF16(IDS_IMAGEBURN_ROOT_LIST_TITLE)); |
| 62 localized_strings.SetString("downloadStatusInProgress", | 65 localized_strings.SetString("downloadStatusStart", |
| 63 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_IN_PROGRESS_STATUS)); | 66 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_STARTING_STATUS)); |
| 64 localized_strings.SetString("downloadStatusComplete", | 67 localized_strings.SetString("downloadStatusInProgress", |
| 65 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_COMPLETE_STATUS)); | 68 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_IN_PROGRESS_STATUS)); |
| 66 localized_strings.SetString("downloadStatusCanceled", | 69 localized_strings.SetString("downloadStatusComplete", |
| 67 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_CANCELED_STATUS)); | 70 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_COMPLETE_STATUS)); |
| 68 localized_strings.SetString("burnStatusStart", | 71 localized_strings.SetString("downloadStatusCanceled", |
| 69 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_STARTING_STATUS)); | 72 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_CANCELED_STATUS)); |
| 70 localized_strings.SetString("burnStatusInProgress", | 73 localized_strings.SetString("burnStatusStart", |
| 71 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_IN_PROGRESS_STATUS)); | 74 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_STARTING_STATUS)); |
| 72 localized_strings.SetString("burnStatusComplete", | 75 localized_strings.SetString("burnStatusInProgress", |
| 73 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_COMPLETE_STATUS)); | 76 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_IN_PROGRESS_STATUS)); |
| 74 localized_strings.SetString("burnStatusCanceled", | 77 localized_strings.SetString("burnStatusComplete", |
| 75 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_CANCELED_STATUS)); | 78 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_COMPLETE_STATUS)); |
| 79 localized_strings.SetString("burnStatusCanceled", | |
| 80 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_CANCELED_STATUS)); | |
| 76 | 81 |
| 77 SetFontAndTextDirection(&localized_strings); | 82 SetFontAndTextDirection(&localized_strings); |
| 78 | 83 |
| 79 static const base::StringPiece imageburn_html( | 84 static const base::StringPiece imageburn_html( |
| 80 ResourceBundle::GetSharedInstance().GetRawDataResource( | 85 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 81 IDR_IMAGEBURNER_HTML)); | 86 IDR_IMAGEBURNER_HTML)); |
| 82 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( | 87 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( |
| 83 imageburn_html, &localized_strings); | 88 imageburn_html, &localized_strings); |
| 84 | 89 |
| 85 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 90 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); |
| 86 html_bytes->data.resize(full_html.size()); | 91 html_bytes->data.resize(full_html.size()); |
| 87 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | 92 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); |
| 88 | 93 |
| 89 SendResponse(request_id, html_bytes); | 94 SendResponse(request_id, html_bytes); |
| 90 } | 95 } |
| 96 | |
| 97 virtual std::string GetMimeType(const std::string&) const { | |
| 98 return "text/html"; | |
| 99 } | |
| 100 | |
| 101 private: | |
| 102 virtual ~ImageBurnUIHTMLSource() {} | |
| 103 | |
| 104 DISALLOW_COPY_AND_ASSIGN(ImageBurnUIHTMLSource); | |
| 105 }; | |
| 106 | |
| 107 //////////////////////////////////////////////////////////////////////////////// | |
| 108 // | |
| 109 // ImageBurnTaskProxy | |
| 110 // | |
| 111 //////////////////////////////////////////////////////////////////////////////// | |
| 112 | |
| 113 class ImageBurnTaskProxy | |
| 114 : public base::RefCountedThreadSafe<ImageBurnTaskProxy> { | |
| 115 public: | |
| 116 explicit ImageBurnTaskProxy(const base::WeakPtr<ImageBurnHandler>& handler) | |
| 117 : handler_(handler) { | |
|
xiyuan
2011/01/25 17:28:30
nit: indent 4 more spaces
achuithb
2011/01/25 22:21:45
Done.
| |
| 118 resource_manager_ = ImageBurnResourceManager::GetInstance(); | |
| 119 } | |
| 120 | |
| 121 bool ReportDownloadInitialized() { | |
| 122 bool initialized = resource_manager_-> CheckImageDownloadStarted(); | |
| 123 if (!initialized) | |
| 124 resource_manager_-> ReportImageDownloadStarted(); | |
| 125 return initialized; | |
| 126 } | |
| 127 | |
| 128 bool CheckDownloadFinished() { | |
| 129 return resource_manager_->CheckDownloadFinished(); | |
| 130 } | |
| 131 | |
| 132 void BurnImage() { | |
| 133 if (!resource_manager_->CheckBurnInProgress() && handler_) { | |
| 134 resource_manager_->SetBurnInProgress(true); | |
| 135 handler_->BurnImage(); | |
| 136 } | |
| 137 } | |
| 138 | |
| 139 void FinalizeBurn(bool success) { | |
| 140 if (handler_) { | |
| 141 handler_->FinalizeBurn(success); | |
| 142 resource_manager_->SetBurnInProgress(false); | |
| 143 } | |
| 144 } | |
| 145 | |
| 146 void CreateImageUrl(TabContents* tab_contents, ImageBurnHandler* downloader) { | |
| 147 resource_manager_->CreateImageUrl(tab_contents, downloader); | |
| 148 } | |
| 149 | |
| 150 private: | |
| 151 base::WeakPtr<ImageBurnHandler> handler_; | |
| 152 ImageBurnResourceManager* resource_manager_; | |
| 153 | |
| 154 friend class base::RefCountedThreadSafe<ImageBurnTaskProxy>; | |
| 155 | |
| 156 DISALLOW_COPY_AND_ASSIGN(ImageBurnTaskProxy); | |
| 157 }; | |
| 91 | 158 |
| 92 //////////////////////////////////////////////////////////////////////////////// | 159 //////////////////////////////////////////////////////////////////////////////// |
| 93 // | 160 // |
| 94 // ImageBurnHandler | 161 // ImageBurnHandler |
| 95 // | 162 // |
| 96 //////////////////////////////////////////////////////////////////////////////// | 163 //////////////////////////////////////////////////////////////////////////////// |
| 97 | 164 |
| 98 ImageBurnHandler::ImageBurnHandler(TabContents* contents) | 165 ImageBurnHandler::ImageBurnHandler(TabContents* contents) |
| 99 :tab_contents_(contents), | 166 :tab_contents_(contents), |
| 100 download_manager_(NULL), | 167 download_manager_(NULL), |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 local_image_file_path_ = download->full_path(); | 249 local_image_file_path_ = download->full_path(); |
| 183 DownloadCompleted(true); | 250 DownloadCompleted(true); |
| 184 } | 251 } |
| 185 | 252 |
| 186 void ImageBurnHandler::OnDownloadOpened(DownloadItem* download) { | 253 void ImageBurnHandler::OnDownloadOpened(DownloadItem* download) { |
| 187 if (download->safety_state() == DownloadItem::DANGEROUS) | 254 if (download->safety_state() == DownloadItem::DANGEROUS) |
| 188 download->DangerousDownloadValidated(); | 255 download->DangerousDownloadValidated(); |
| 189 } | 256 } |
| 190 | 257 |
| 191 void ImageBurnHandler::ModelChanged() { | 258 void ImageBurnHandler::ModelChanged() { |
| 259 // Find our item and observe it. | |
| 192 std::vector<DownloadItem*> downloads; | 260 std::vector<DownloadItem*> downloads; |
| 193 download_manager_->GetTemporaryDownloads( | 261 download_manager_->GetTemporaryDownloads( |
| 194 burn_resource_manager_->GetLocalImageDirPath(), &downloads); | 262 burn_resource_manager_->GetLocalImageDirPath(), &downloads); |
| 195 if (download_item_observer_added_) | 263 if (download_item_observer_added_) // Already added. |
|
xiyuan
2011/01/25 17:28:30
nit: two spaces before comment at line end
achuithb
2011/01/25 22:21:45
Done.
| |
| 196 return; | 264 return; |
| 197 std::vector<DownloadItem*>::const_iterator it = downloads.begin(); | 265 std::vector<DownloadItem*>::const_iterator it = downloads.begin(); |
| 198 for (; it != downloads.end(); ++it) { | 266 for (; it != downloads.end(); ++it) { |
| 199 if ((*it)->url() == *image_download_url_) { | 267 if ((*it)->original_url() == *image_download_url_) { |
| 268 // Found it. | |
| 200 download_item_observer_added_ = true; | 269 download_item_observer_added_ = true; |
| 201 (*it)->AddObserver(this); | 270 (*it)->AddObserver(this); |
| 202 active_download_item_ = *it; | 271 active_download_item_ = *it; |
| 203 break; | 272 break; |
| 204 } | 273 } |
| 205 } | 274 } |
| 206 } | 275 } |
| 207 | 276 |
| 208 void ImageBurnHandler::HandleGetRoots(const ListValue* args) { | 277 void ImageBurnHandler::HandleGetRoots(const ListValue* args) { |
| 209 ListValue results_value; | 278 ListValue results_value; |
| 210 DictionaryValue info_value; | 279 DictionaryValue info_value; |
| 211 chromeos::MountLibrary* mount_lib = | 280 chromeos::MountLibrary* mount_lib = |
| 212 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 281 chromeos::CrosLibrary::Get()->GetMountLibrary(); |
| 213 const chromeos::MountLibrary::DiskVector& disks = mount_lib->disks(); | 282 const chromeos::MountLibrary::DiskVector& disks = mount_lib->disks(); |
| 214 if (!burn_resource_manager_->CheckBurnInProgress()) { | 283 if (!burn_resource_manager_->CheckBurnInProgress()) { |
| 215 for (size_t i = 0; i < disks.size(); ++i) { | 284 for (size_t i = 0; i < disks.size(); ++i) { |
| 216 if (!disks[i].mount_path.empty()) { | 285 if (!disks[i].mount_path.empty()) { |
| 217 DictionaryValue* page_value = new DictionaryValue(); | |
| 218 FilePath disk_path = FilePath(disks[i].system_path).DirName(); | 286 FilePath disk_path = FilePath(disks[i].system_path).DirName(); |
| 219 std::string title = "/dev/" + disk_path.BaseName().value(); | 287 std::string title = "/dev/" + disk_path.BaseName().value(); |
| 220 page_value->SetString(kPropertyTitle, title); | 288 if (!mount_lib->IsBootPath(title.c_str())) { |
| 221 page_value->SetString(kPropertyPath, title); | 289 DictionaryValue* page_value = new DictionaryValue(); |
| 222 page_value->SetBoolean(kPropertyDirectory, true); | 290 page_value->SetString(kPropertyTitle, title); |
| 223 results_value.Append(page_value); | 291 page_value->SetString(kPropertyPath, title); |
| 292 page_value->SetBoolean(kPropertyDirectory, true); | |
| 293 results_value.Append(page_value); | |
| 294 } | |
| 224 } | 295 } |
| 225 } | 296 } |
| 226 } | 297 } |
| 227 info_value.SetString("functionCall", "getRoots"); | 298 info_value.SetString("functionCall", "getRoots"); |
| 228 info_value.SetString(kPropertyPath, ""); | 299 info_value.SetString(kPropertyPath, ""); |
| 229 dom_ui_->CallJavascriptFunction(L"browseFileResult", | 300 dom_ui_->CallJavascriptFunction(L"browseFileResult", |
| 230 info_value, results_value); | 301 info_value, results_value); |
| 231 } | 302 } |
| 232 | 303 |
| 233 void ImageBurnHandler::HandleDownloadImage(const ListValue* args) { | 304 void ImageBurnHandler::HandleDownloadImage(const ListValue* args) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 signal_value.SetString("state", "IN_PROGRESS"); | 347 signal_value.SetString("state", "IN_PROGRESS"); |
| 277 signal_value.SetString("path", image_target_.value()); | 348 signal_value.SetString("path", image_target_.value()); |
| 278 signal_value.SetInteger("received", 0); | 349 signal_value.SetInteger("received", 0); |
| 279 signal_value.SetString("progress_status_text", ""); | 350 signal_value.SetString("progress_status_text", ""); |
| 280 dom_ui_->CallJavascriptFunction(L"burnProgressUpdated", signal_value); | 351 dom_ui_->CallJavascriptFunction(L"burnProgressUpdated", signal_value); |
| 281 } | 352 } |
| 282 } | 353 } |
| 283 | 354 |
| 284 void ImageBurnHandler::FinalizeBurn(bool successful) { | 355 void ImageBurnHandler::FinalizeBurn(bool successful) { |
| 285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 286 if (successful) | 357 dom_ui_->CallJavascriptFunction(successful ? |
| 287 dom_ui_->CallJavascriptFunction(L"burnSuccessful"); | 358 L"burnSuccessful" : L"burnUnsuccessful"); |
| 288 else | |
| 289 dom_ui_->CallJavascriptFunction(L"burnUnsuccessful"); | |
| 290 } | 359 } |
| 291 | 360 |
| 292 void ImageBurnHandler::UpdateBurnProgress(int64 total_burnt, | 361 void ImageBurnHandler::UpdateBurnProgress(int64 total_burnt, |
| 293 int64 image_size, | 362 int64 image_size, |
| 294 const std::string& path, | 363 const std::string& path, |
| 295 chromeos::BurnEventType event) { | 364 chromeos::BurnEventType event) { |
| 296 DictionaryValue progress_value; | 365 DictionaryValue progress_value; |
| 297 progress_value.SetString("progress_status_text", | 366 progress_value.SetString("progress_status_text", |
| 298 GetBurnProgressText(total_burnt, image_size)); | 367 GetBurnProgressText(total_burnt, image_size)); |
| 299 if (event == chromeos::BURN_UPDATED) | 368 if (event == chromeos::BURN_UPDATED) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 image_target_ = FilePath(image_dest); | 455 image_target_ = FilePath(image_dest); |
| 387 } | 456 } |
| 388 | 457 |
| 389 void ImageBurnHandler::CreateLocalImagePath() { | 458 void ImageBurnHandler::CreateLocalImagePath() { |
| 390 local_image_file_path_ = | 459 local_image_file_path_ = |
| 391 burn_resource_manager_->GetLocalImageDirPath().Append(kImageFileName); | 460 burn_resource_manager_->GetLocalImageDirPath().Append(kImageFileName); |
| 392 } | 461 } |
| 393 | 462 |
| 394 //////////////////////////////////////////////////////////////////////////////// | 463 //////////////////////////////////////////////////////////////////////////////// |
| 395 // | 464 // |
| 396 // ImageBurnTaskProxy | |
| 397 // | |
| 398 //////////////////////////////////////////////////////////////////////////////// | |
| 399 ImageBurnTaskProxy::ImageBurnTaskProxy( | |
| 400 const base::WeakPtr<ImageBurnHandler>& handler) | |
| 401 : handler_(handler) { | |
| 402 resource_manager_ = ImageBurnResourceManager::GetInstance(); | |
| 403 } | |
| 404 | |
| 405 bool ImageBurnTaskProxy::ReportDownloadInitialized() { | |
| 406 bool initialized = resource_manager_-> CheckImageDownloadStarted(); | |
| 407 if (!initialized) | |
| 408 resource_manager_-> ReportImageDownloadStarted(); | |
| 409 return initialized; | |
| 410 } | |
| 411 | |
| 412 bool ImageBurnTaskProxy::CheckDownloadFinished() { | |
| 413 return resource_manager_->CheckDownloadFinished(); | |
| 414 } | |
| 415 | |
| 416 void ImageBurnTaskProxy:: BurnImage() { | |
| 417 if (!resource_manager_->CheckBurnInProgress() && handler_) { | |
| 418 resource_manager_->SetBurnInProgress(true); | |
| 419 handler_->BurnImage(); | |
| 420 } | |
| 421 } | |
| 422 | |
| 423 void ImageBurnTaskProxy::FinalizeBurn(bool success) { | |
| 424 if (handler_) { | |
| 425 handler_->FinalizeBurn(success); | |
| 426 resource_manager_->SetBurnInProgress(false); | |
| 427 } | |
| 428 } | |
| 429 | |
| 430 void ImageBurnTaskProxy::CreateImageUrl(TabContents* tab_contents, | |
| 431 ImageBurnHandler* downloader) { | |
| 432 resource_manager_->CreateImageUrl(tab_contents, downloader); | |
| 433 } | |
| 434 | |
| 435 | |
| 436 //////////////////////////////////////////////////////////////////////////////// | |
| 437 // | |
| 438 // ImageBurnResourceManager | 465 // ImageBurnResourceManager |
| 439 // | 466 // |
| 440 //////////////////////////////////////////////////////////////////////////////// | 467 //////////////////////////////////////////////////////////////////////////////// |
| 441 | 468 |
| 442 ImageBurnResourceManager::ImageBurnResourceManager() | 469 ImageBurnResourceManager::ImageBurnResourceManager() |
| 443 : image_download_started_(false), | 470 : image_download_started_(false), |
| 444 image_download_finished_(false), | 471 image_download_finished_(false), |
| 445 burn_in_progress_(false), | 472 burn_in_progress_(false), |
| 446 download_manager_(NULL), | 473 download_manager_(NULL), |
| 447 download_item_observer_added_(false), | 474 download_item_observer_added_(false), |
| 448 active_download_item_(NULL), | 475 active_download_item_(NULL), |
| 449 image_url_(NULL), | 476 image_url_(new GURL(kImageDownloadURL)), |
| 450 image_fetcher_url_(kImageBaseURL + kImageFetcherName), | 477 image_fetcher_url_(kImageBaseURL + kImageFetcherName), |
| 451 image_url_fetching_requested_(false), | 478 image_url_fetching_requested_(false), |
| 452 image_url_fetched_(false) { | 479 image_url_fetched_(true) { |
|
xiyuan
2011/01/25 17:28:30
any reason why this needs to be changed?
achuithb
2011/01/25 22:21:45
imageburner was written to use an internal corp ur
| |
| 453 local_image_dir_file_path_.clear(); | 480 local_image_dir_file_path_.clear(); |
| 454 image_fecher_local_path_ = GetLocalImageDirPath().Append(kImageFetcherName); | 481 image_fecher_local_path_ = GetLocalImageDirPath().Append(kImageFetcherName); |
| 455 } | 482 } |
| 456 | 483 |
| 457 ImageBurnResourceManager::~ImageBurnResourceManager() { | 484 ImageBurnResourceManager::~ImageBurnResourceManager() { |
| 458 if (!local_image_dir_file_path_.empty()) { | 485 if (!local_image_dir_file_path_.empty()) { |
| 459 file_util::Delete(local_image_dir_file_path_, true); | 486 file_util::Delete(local_image_dir_file_path_, true); |
| 460 } | 487 } |
| 461 if (active_download_item_) { | 488 if (active_download_item_) { |
| 462 active_download_item_->RemoveObserver(this); | 489 active_download_item_->RemoveObserver(this); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 ImageBurnHandler* handler = new ImageBurnHandler(contents); | 640 ImageBurnHandler* handler = new ImageBurnHandler(contents); |
| 614 AddMessageHandler((handler)->Attach(this)); | 641 AddMessageHandler((handler)->Attach(this)); |
| 615 ImageBurnUIHTMLSource* html_source = new ImageBurnUIHTMLSource(); | 642 ImageBurnUIHTMLSource* html_source = new ImageBurnUIHTMLSource(); |
| 616 BrowserThread::PostTask( | 643 BrowserThread::PostTask( |
| 617 BrowserThread::IO, FROM_HERE, | 644 BrowserThread::IO, FROM_HERE, |
| 618 NewRunnableMethod( | 645 NewRunnableMethod( |
| 619 ChromeURLDataManager::GetInstance(), | 646 ChromeURLDataManager::GetInstance(), |
| 620 &ChromeURLDataManager::AddDataSource, | 647 &ChromeURLDataManager::AddDataSource, |
| 621 make_scoped_refptr(html_source))); | 648 make_scoped_refptr(html_source))); |
| 622 } | 649 } |
| OLD | NEW |