1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DOWNLOAD_OFFLINE_ITEM_UTILS_H_
#define CHROME_BROWSER_DOWNLOAD_OFFLINE_ITEM_UTILS_H_
#include <memory>
#include <optional>
#include <string>
#include "components/download/public/common/download_item.h"
#include "components/offline_items_collection/core/offline_item.h"
#include "components/offline_items_collection/core/rename_result.h"
// Contains various utility methods for conversions between DownloadItem and
// OfflineItem.
class OfflineItemUtils {
using DownloadRenameResult = download::DownloadItem::DownloadRenameResult;
public:
OfflineItemUtils(const OfflineItemUtils&) = delete;
OfflineItemUtils& operator=(const OfflineItemUtils&) = delete;
static offline_items_collection::OfflineItem CreateOfflineItem(
const std::string& name_space,
download::DownloadItem* item);
static offline_items_collection::ContentId GetContentIdForDownload(
download::DownloadItem* download);
static std::string GetDownloadNamespacePrefix(bool is_off_the_record);
static bool IsDownload(const offline_items_collection::ContentId& id);
// Converts DownloadInterruptReason to offline_items_collection::FailState.
static offline_items_collection::FailState
ConvertDownloadInterruptReasonToFailState(
download::DownloadInterruptReason reason);
// Converts offline_items_collection::FailState to DownloadInterruptReason.
static download::DownloadInterruptReason
ConvertFailStateToDownloadInterruptReason(
offline_items_collection::FailState fail_state);
// Gets the short text to display for a offline_items_collection::FailState.
static std::u16string GetFailStateMessage(
offline_items_collection::FailState fail_state);
// Converts download::DownloadItem::DownloadRenameResult to
// offline_items_collection::RenameResult.
static RenameResult ConvertDownloadRenameResultToRenameResult(
DownloadRenameResult download_rename_result);
};
#endif // CHROME_BROWSER_DOWNLOAD_OFFLINE_ITEM_UTILS_H_
|