Index: components/history/content/browser/download_constants_utils.cc |
diff --git a/components/history/content/browser/download_constants_utils.cc b/components/history/content/browser/download_constants_utils.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3469b2bccd2fec6dd781c552ff4c7e87613794f5 |
--- /dev/null |
+++ b/components/history/content/browser/download_constants_utils.cc |
@@ -0,0 +1,118 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/history/content/browser/download_constants_utils.h" |
+ |
+#include "base/logging.h" |
+ |
+namespace history { |
+ |
+content::DownloadItem::DownloadState ToContentDownloadState( |
+ DownloadState state) { |
+ if (state == kStateInProgress) { |
+ return content::DownloadItem::IN_PROGRESS; |
+ } |
+ if (state == kStateComplete) { |
+ return content::DownloadItem::COMPLETE; |
+ } |
+ if (state == kStateCancelled) { |
+ return content::DownloadItem::CANCELLED; |
+ } |
+ if (state == kStateInterrupted) { |
+ return content::DownloadItem::INTERRUPTED; |
+ } |
+ // We should not need kStateBug140687 here because MigrateDownloadsState() |
+ // is called in HistoryDatabase::Init(). |
+ NOTREACHED(); |
+ return content::DownloadItem::MAX_DOWNLOAD_STATE; |
+} |
+ |
+DownloadState ToHistoryDownloadState( |
+ content::DownloadItem::DownloadState state) { |
+ switch (state) { |
+ case content::DownloadItem::IN_PROGRESS: |
+ return kStateInProgress; |
+ case content::DownloadItem::COMPLETE: |
+ return kStateComplete; |
+ case content::DownloadItem::CANCELLED: |
+ return kStateCancelled; |
+ case content::DownloadItem::INTERRUPTED: |
+ return kStateInterrupted; |
+ 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.
|
+ NOTREACHED(); |
+ return kStateInvalid; |
+ } |
+} |
+ |
+content::DownloadDangerType ToContentDownloadDangerType( |
+ DownloadDangerType danger_type) { |
+ if (danger_type == kDangerTypeNotDangerous) { |
+ return content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS; |
+ } |
+ if (danger_type == kDangerTypeDangerousFile) { |
+ return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE; |
+ } |
+ if (danger_type == kDangerTypeDangerousUrl) { |
+ return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL; |
+ } |
+ if (danger_type == kDangerTypeDangerousContent) { |
+ return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT; |
+ } |
+ if (danger_type == kDangerTypeMaybeDangerousContent) { |
+ return content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT; |
+ } |
+ if (danger_type == kDangerTypeUncommonContent) { |
+ return content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT; |
+ } |
+ if (danger_type == kDangerTypeUserValidated) { |
+ return content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED; |
+ } |
+ if (danger_type == kDangerTypeDangerousHost) { |
+ return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST; |
+ } |
+ if (danger_type == kDangerTypePotentiallyUnwanted) { |
+ return content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED; |
+ } |
+ NOTREACHED(); |
+ return content::DOWNLOAD_DANGER_TYPE_MAX; |
+} |
+ |
+DownloadDangerType ToHistoryDownloadDangerType( |
+ content::DownloadDangerType danger_type) { |
+ switch (danger_type) { |
+ case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: |
+ return kDangerTypeNotDangerous; |
+ case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: |
+ return kDangerTypeDangerousFile; |
+ case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: |
+ return kDangerTypeDangerousUrl; |
+ case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: |
+ return kDangerTypeDangerousContent; |
+ case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: |
+ return kDangerTypeMaybeDangerousContent; |
+ case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: |
+ return kDangerTypeUncommonContent; |
+ case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: |
+ return kDangerTypeUserValidated; |
+ case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: |
+ return kDangerTypeDangerousHost; |
+ case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: |
+ return kDangerTypePotentiallyUnwanted; |
+ 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.
|
+ NOTREACHED(); |
+ return kDangerTypeInvalid; |
+ } |
+} |
+ |
+content::DownloadInterruptReason ToContentDownloadInterruptReason( |
+ DownloadInterruptReason interrupt_reason) { |
+ return static_cast<content::DownloadInterruptReason>(interrupt_reason); |
+} |
+ |
+DownloadInterruptReason ToHistoryDownloadInterruptReason( |
+ content::DownloadInterruptReason interrupt_reason) { |
+ return static_cast<DownloadInterruptReason>(interrupt_reason); |
+} |
+ |
+} // namespace history |