| Index: components/offline_items_collection/core/android/java/src/org/chromium/components/offline_items_collection/LegacyHelpers.java
|
| diff --git a/components/offline_items_collection/core/android/java/src/org/chromium/components/offline_items_collection/LegacyHelpers.java b/components/offline_items_collection/core/android/java/src/org/chromium/components/offline_items_collection/LegacyHelpers.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e2c797148f4e537260948a9da818ab16260ec18e
|
| --- /dev/null
|
| +++ b/components/offline_items_collection/core/android/java/src/org/chromium/components/offline_items_collection/LegacyHelpers.java
|
| @@ -0,0 +1,53 @@
|
| +// Copyright 2017 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.
|
| +
|
| +package org.chromium.components.offline_items_collection;
|
| +
|
| +import android.text.TextUtils;
|
| +
|
| +/**
|
| + * Legacy helper information meant to help with the migration process to OfflineItems.
|
| + */
|
| +public class LegacyHelpers {
|
| + // These are legacy namespaces for the purpose of ID generation that will only affect the UI.
|
| + public static final String LEGACY_DOWNLOAD_NAMESPACE = "LEGACY_DOWNLOAD";
|
| + public static final String LEGACY_OFFLINE_PAGE_NAMESPACE = "LEGACY_OFFLINE_PAGE";
|
| +
|
| + /**
|
| + * Helper to build a {@link ContentId} based on a single GUID for old offline content sources
|
| + * (downloads and offline pages).
|
| + * @param isOfflinePage Whether or not {@code guid} is for an offline page or a download.
|
| + * @param guid The {@code guid} of the download.
|
| + * @return A new {@link ContentId} instance.
|
| + */
|
| + public static ContentId buildLegacyContentId(boolean isOfflinePage, String guid) {
|
| + String namespace =
|
| + isOfflinePage ? LEGACY_OFFLINE_PAGE_NAMESPACE : LEGACY_DOWNLOAD_NAMESPACE;
|
| + return new ContentId(namespace, guid);
|
| + }
|
| +
|
| + /**
|
| + * Helper to determine if a {@link ContentId} was created from
|
| + * {@link #buildLegacyContentId(boolean, String)} for a download ({@code false} for {@code
|
| + * isOfflinePage}).
|
| + * @param id The {@link ContentId} to inspect.
|
| + * @return Whether or not {@code id} was built for a traditional download.
|
| + */
|
| + public static boolean isLegacyDownload(ContentId id) {
|
| + return TextUtils.equals(LEGACY_DOWNLOAD_NAMESPACE, id.namespace);
|
| + }
|
| +
|
| + /**
|
| + * Helper to determine if a {@link ContentId} was created from
|
| + * {@link #buildLegacyContentId(boolean, String)} for an offline page ({@code true} for {@code
|
| + * isOfflinePage}).
|
| + * @param id The {@link ContentId} to inspect.
|
| + * @return Whether or not {@code id} was built for a traditional offline page.
|
| + */
|
| + public static boolean isLegacyOfflinePage(ContentId id) {
|
| + return TextUtils.equals(LEGACY_OFFLINE_PAGE_NAMESPACE, id.namespace);
|
| + }
|
| +
|
| + private LegacyHelpers() {}
|
| +}
|
|
|