OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/history/content/browser/download_constants_utils.h" | |
6 | |
7 #include "base/logging.h" | |
8 | |
9 namespace history { | |
10 | |
11 content::DownloadItem::DownloadState ToContentDownloadState( | |
12 DownloadState state) { | |
13 if (state == kStateInProgress) { | |
14 return content::DownloadItem::IN_PROGRESS; | |
15 } | |
16 if (state == kStateComplete) { | |
17 return content::DownloadItem::COMPLETE; | |
18 } | |
19 if (state == kStateCancelled) { | |
20 return content::DownloadItem::CANCELLED; | |
21 } | |
22 if (state == kStateInterrupted) { | |
23 return content::DownloadItem::INTERRUPTED; | |
24 } | |
25 // We should not need kStateBug140687 here because MigrateDownloadsState() | |
26 // is called in HistoryDatabase::Init(). | |
27 NOTREACHED(); | |
28 return content::DownloadItem::MAX_DOWNLOAD_STATE; | |
29 } | |
30 | |
31 DownloadState ToHistoryDownloadState( | |
32 content::DownloadItem::DownloadState state) { | |
33 switch (state) { | |
34 case content::DownloadItem::IN_PROGRESS: | |
35 return kStateInProgress; | |
36 case content::DownloadItem::COMPLETE: | |
37 return kStateComplete; | |
38 case content::DownloadItem::CANCELLED: | |
39 return kStateCancelled; | |
40 case content::DownloadItem::INTERRUPTED: | |
41 return kStateInterrupted; | |
42 default: | |
droger
2015/01/05 18:02:58
If possible get rid of the default case. That way,
sdefresne
2015/01/05 20:08:33
Done.
| |
43 NOTREACHED(); | |
44 return kStateInvalid; | |
45 } | |
46 } | |
47 | |
48 content::DownloadDangerType ToContentDownloadDangerType( | |
49 DownloadDangerType danger_type) { | |
50 if (danger_type == kDangerTypeNotDangerous) { | |
51 return content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS; | |
52 } | |
53 if (danger_type == kDangerTypeDangerousFile) { | |
54 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE; | |
55 } | |
56 if (danger_type == kDangerTypeDangerousUrl) { | |
57 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL; | |
58 } | |
59 if (danger_type == kDangerTypeDangerousContent) { | |
60 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT; | |
61 } | |
62 if (danger_type == kDangerTypeMaybeDangerousContent) { | |
63 return content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT; | |
64 } | |
65 if (danger_type == kDangerTypeUncommonContent) { | |
66 return content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT; | |
67 } | |
68 if (danger_type == kDangerTypeUserValidated) { | |
69 return content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED; | |
70 } | |
71 if (danger_type == kDangerTypeDangerousHost) { | |
72 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST; | |
73 } | |
74 if (danger_type == kDangerTypePotentiallyUnwanted) { | |
75 return content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED; | |
76 } | |
77 NOTREACHED(); | |
78 return content::DOWNLOAD_DANGER_TYPE_MAX; | |
79 } | |
80 | |
81 DownloadDangerType ToHistoryDownloadDangerType( | |
82 content::DownloadDangerType danger_type) { | |
83 switch (danger_type) { | |
84 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: | |
85 return kDangerTypeNotDangerous; | |
86 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: | |
87 return kDangerTypeDangerousFile; | |
88 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: | |
89 return kDangerTypeDangerousUrl; | |
90 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: | |
91 return kDangerTypeDangerousContent; | |
92 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: | |
93 return kDangerTypeMaybeDangerousContent; | |
94 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: | |
95 return kDangerTypeUncommonContent; | |
96 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: | |
97 return kDangerTypeUserValidated; | |
98 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: | |
99 return kDangerTypeDangerousHost; | |
100 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: | |
101 return kDangerTypePotentiallyUnwanted; | |
102 default: | |
droger
2015/01/05 18:02:58
If possible get rid of the default case. That way,
sdefresne
2015/01/05 20:08:33
Done.
| |
103 NOTREACHED(); | |
104 return kDangerTypeInvalid; | |
105 } | |
106 } | |
107 | |
108 content::DownloadInterruptReason ToContentDownloadInterruptReason( | |
109 DownloadInterruptReason interrupt_reason) { | |
110 return static_cast<content::DownloadInterruptReason>(interrupt_reason); | |
111 } | |
112 | |
113 DownloadInterruptReason ToHistoryDownloadInterruptReason( | |
114 content::DownloadInterruptReason interrupt_reason) { | |
115 return static_cast<DownloadInterruptReason>(interrupt_reason); | |
116 } | |
117 | |
118 } // namespace history | |
OLD | NEW |