| 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 // Download utility implementation |    5 // Download utility implementation | 
|    6  |    6  | 
|    7 #include "chrome/browser/download/download_util.h" |    7 #include "chrome/browser/download/download_util.h" | 
|    8  |    8  | 
|    9 #if defined(OS_WIN) |    9 #if defined(OS_WIN) | 
|   10 #include <shobjidl.h> |   10 #include <shobjidl.h> | 
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  658   file_value->SetInteger("id", id); |  658   file_value->SetInteger("id", id); | 
|  659   file_value->Set("file_path", |  659   file_value->Set("file_path", | 
|  660                   base::CreateFilePathValue(download->GetTargetFilePath())); |  660                   base::CreateFilePathValue(download->GetTargetFilePath())); | 
|  661   // Keep file names as LTR. |  661   // Keep file names as LTR. | 
|  662   string16 file_name = download->GetFileNameToReportUser().LossyDisplayName(); |  662   string16 file_name = download->GetFileNameToReportUser().LossyDisplayName(); | 
|  663   file_name = base::i18n::GetDisplayStringInLTRDirectionality(file_name); |  663   file_name = base::i18n::GetDisplayStringInLTRDirectionality(file_name); | 
|  664   file_value->SetString("file_name", file_name); |  664   file_value->SetString("file_name", file_name); | 
|  665   file_value->SetString("url", download->GetURL().spec()); |  665   file_value->SetString("url", download->GetURL().spec()); | 
|  666   file_value->SetBoolean("otr", download->is_otr()); |  666   file_value->SetBoolean("otr", download->is_otr()); | 
|  667   file_value->SetInteger("total", static_cast<int>(download->total_bytes())); |  667   file_value->SetInteger("total", static_cast<int>(download->total_bytes())); | 
 |  668   file_value->SetBoolean("file_externally_removed", | 
 |  669                          download->file_externally_removed()); | 
|  668  |  670  | 
|  669   if (download->IsInProgress()) { |  671   if (download->IsInProgress()) { | 
|  670     if (download->safety_state() == DownloadItem::DANGEROUS) { |  672     if (download->safety_state() == DownloadItem::DANGEROUS) { | 
|  671       file_value->SetString("state", "DANGEROUS"); |  673       file_value->SetString("state", "DANGEROUS"); | 
|  672       DCHECK(download->GetDangerType() == DownloadItem::DANGEROUS_FILE || |  674       DCHECK(download->GetDangerType() == DownloadItem::DANGEROUS_FILE || | 
|  673              download->GetDangerType() == DownloadItem::DANGEROUS_URL); |  675              download->GetDangerType() == DownloadItem::DANGEROUS_URL); | 
|  674       const char* danger_type_value = |  676       const char* danger_type_value = | 
|  675           download->GetDangerType() == DownloadItem::DANGEROUS_FILE ? |  677           download->GetDangerType() == DownloadItem::DANGEROUS_FILE ? | 
|  676           "DANGEROUS_FILE" : "DANGEROUS_URL"; |  678           "DANGEROUS_FILE" : "DANGEROUS_URL"; | 
|  677       file_value->SetString("danger_type", danger_type_value); |  679       file_value->SetString("danger_type", danger_type_value); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
|  694     file_value->SetString("progress_status_text", |  696     file_value->SetString("progress_status_text", | 
|  695         GetProgressStatusText(download)); |  697         GetProgressStatusText(download)); | 
|  696  |  698  | 
|  697     file_value->SetInteger("percent", |  699     file_value->SetInteger("percent", | 
|  698         static_cast<int>(download->PercentComplete())); |  700         static_cast<int>(download->PercentComplete())); | 
|  699     file_value->SetInteger("received", |  701     file_value->SetInteger("received", | 
|  700         static_cast<int>(download->received_bytes())); |  702         static_cast<int>(download->received_bytes())); | 
|  701   } else if (download->IsCancelled()) { |  703   } else if (download->IsCancelled()) { | 
|  702     file_value->SetString("state", "CANCELLED"); |  704     file_value->SetString("state", "CANCELLED"); | 
|  703   } else if (download->IsComplete()) { |  705   } else if (download->IsComplete()) { | 
|  704     if (download->safety_state() == DownloadItem::DANGEROUS) { |  706     if (download->safety_state() == DownloadItem::DANGEROUS) | 
|  705       file_value->SetString("state", "DANGEROUS"); |  707       file_value->SetString("state", "DANGEROUS"); | 
|  706     } else { |  708     else | 
|  707       file_value->SetString("state", "COMPLETE"); |  709       file_value->SetString("state", "COMPLETE"); | 
|  708     } |  | 
|  709   } else if (download->state() == DownloadItem::REMOVING) { |  710   } else if (download->state() == DownloadItem::REMOVING) { | 
|  710     file_value->SetString("state", "REMOVING"); |  711     file_value->SetString("state", "REMOVING"); | 
|  711   } else { |  712   } else { | 
|  712     NOTREACHED() << "state undefined"; |  713     NOTREACHED() << "state undefined"; | 
|  713   } |  714   } | 
|  714  |  715  | 
|  715   return file_value; |  716   return file_value; | 
|  716 } |  717 } | 
|  717  |  718  | 
|  718 string16 GetProgressStatusText(DownloadItem* download) { |  719 string16 GetProgressStatusText(DownloadItem* download) { | 
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  903 FilePath GetCrDownloadPath(const FilePath& suggested_path) { |  904 FilePath GetCrDownloadPath(const FilePath& suggested_path) { | 
|  904   FilePath::StringType file_name; |  905   FilePath::StringType file_name; | 
|  905   base::SStringPrintf( |  906   base::SStringPrintf( | 
|  906       &file_name, |  907       &file_name, | 
|  907       PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), |  908       PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), | 
|  908       suggested_path.value().c_str()); |  909       suggested_path.value().c_str()); | 
|  909   return FilePath(file_name); |  910   return FilePath(file_name); | 
|  910 } |  911 } | 
|  911  |  912  | 
|  912 }  // namespace download_util |  913 }  // namespace download_util | 
| OLD | NEW |