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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 #include "chrome/browser/ui/browser_list.h" | 76 #include "chrome/browser/ui/browser_list.h" |
77 #include "chrome/browser/ui/views/frame/browser_view.h" | 77 #include "chrome/browser/ui/views/frame/browser_view.h" |
78 #include "ui/base/dragdrop/drag_source.h" | 78 #include "ui/base/dragdrop/drag_source.h" |
79 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 79 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
80 #endif | 80 #endif |
81 | 81 |
82 // TODO(phajdan.jr): Find some standard location for this, maintaining | 82 // TODO(phajdan.jr): Find some standard location for this, maintaining |
83 // the same value on all platforms. | 83 // the same value on all platforms. |
84 static const double PI = 3.141592653589793; | 84 static const double PI = 3.141592653589793; |
85 | 85 |
86 namespace { | |
87 | |
88 const char* GetDangerTypeString(DownloadStateInfo::DangerType danger_type) { | |
89 switch (danger_type) { | |
90 case DownloadStateInfo::NOT_DANGEROUS: | |
91 return "NOT_DANGEROUS"; | |
92 case DownloadStateInfo::DANGEROUS_FILE: | |
93 return "DANGEROUS_FILE"; | |
94 case DownloadStateInfo::DANGEROUS_URL: | |
95 return "DANGEROUS_URL"; | |
96 case DownloadStateInfo::DANGEROUS_CONTENT: | |
97 return "DANGEROUS_CONTENT"; | |
98 default: | |
99 // We shouldn't be returning a danger type string if it is | |
100 // MAYBE_DANGEROUS_CONTENT. | |
Randy Smith (Not in Mondays)
2011/11/21 01:18:15
For consistency, I'd think that either NOT_DANGERO
asanka
2011/11/21 17:08:57
Good point. I'll remove the NOT_DANGEROUS string,
| |
101 NOTREACHED(); | |
102 } | |
103 return NULL; | |
104 } | |
105 | |
106 } // namespace | |
107 | |
86 namespace download_util { | 108 namespace download_util { |
87 | 109 |
88 // How many times to cycle the complete animation. This should be an odd number | 110 // How many times to cycle the complete animation. This should be an odd number |
89 // so that the animation ends faded out. | 111 // so that the animation ends faded out. |
90 static const int kCompleteAnimationCycles = 5; | 112 static const int kCompleteAnimationCycles = 5; |
91 | 113 |
92 // Download temporary file creation -------------------------------------------- | 114 // Download temporary file creation -------------------------------------------- |
93 | 115 |
94 class DefaultDownloadDirectory { | 116 class DefaultDownloadDirectory { |
95 public: | 117 public: |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 file_value->SetString("url", download->GetURL().spec()); | 444 file_value->SetString("url", download->GetURL().spec()); |
423 file_value->SetBoolean("otr", download->is_otr()); | 445 file_value->SetBoolean("otr", download->is_otr()); |
424 file_value->SetInteger("total", static_cast<int>(download->total_bytes())); | 446 file_value->SetInteger("total", static_cast<int>(download->total_bytes())); |
425 file_value->SetBoolean("file_externally_removed", | 447 file_value->SetBoolean("file_externally_removed", |
426 download->file_externally_removed()); | 448 download->file_externally_removed()); |
427 | 449 |
428 if (download->IsInProgress()) { | 450 if (download->IsInProgress()) { |
429 if (download->safety_state() == DownloadItem::DANGEROUS) { | 451 if (download->safety_state() == DownloadItem::DANGEROUS) { |
430 file_value->SetString("state", "DANGEROUS"); | 452 file_value->SetString("state", "DANGEROUS"); |
431 DCHECK(download->GetDangerType() == DownloadStateInfo::DANGEROUS_FILE || | 453 DCHECK(download->GetDangerType() == DownloadStateInfo::DANGEROUS_FILE || |
432 download->GetDangerType() == DownloadStateInfo::DANGEROUS_URL); | 454 download->GetDangerType() == DownloadStateInfo::DANGEROUS_URL || |
455 download->GetDangerType() == DownloadStateInfo::DANGEROUS_CONTENT); | |
433 const char* danger_type_value = | 456 const char* danger_type_value = |
434 download->GetDangerType() == DownloadStateInfo::DANGEROUS_FILE ? | 457 GetDangerTypeString(download->GetDangerType()); |
435 "DANGEROUS_FILE" : "DANGEROUS_URL"; | |
436 file_value->SetString("danger_type", danger_type_value); | 458 file_value->SetString("danger_type", danger_type_value); |
437 } else if (download->is_paused()) { | 459 } else if (download->is_paused()) { |
438 file_value->SetString("state", "PAUSED"); | 460 file_value->SetString("state", "PAUSED"); |
439 } else { | 461 } else { |
440 file_value->SetString("state", "IN_PROGRESS"); | 462 file_value->SetString("state", "IN_PROGRESS"); |
441 } | 463 } |
442 | 464 |
443 file_value->SetString("progress_status_text", | 465 file_value->SetString("progress_status_text", |
444 GetProgressStatusText(download)); | 466 GetProgressStatusText(download)); |
445 | 467 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 return DownloadFile::GetUniquePathNumberWithSuffix( | 588 return DownloadFile::GetUniquePathNumberWithSuffix( |
567 path, FILE_PATH_LITERAL(".crdownload")); | 589 path, FILE_PATH_LITERAL(".crdownload")); |
568 } | 590 } |
569 | 591 |
570 FilePath GetCrDownloadPath(const FilePath& suggested_path) { | 592 FilePath GetCrDownloadPath(const FilePath& suggested_path) { |
571 return DownloadFile::AppendSuffixToPath( | 593 return DownloadFile::AppendSuffixToPath( |
572 suggested_path, FILE_PATH_LITERAL(".crdownload")); | 594 suggested_path, FILE_PATH_LITERAL(".crdownload")); |
573 } | 595 } |
574 | 596 |
575 } // namespace download_util | 597 } // namespace download_util |
OLD | NEW |