Commit 194e406d authored by dfalcantara's avatar dfalcantara Committed by Commit bot

[Downloads] Expose basic download history to UI

* Adds hooks in DownloadManagerService for calling GetAllDownloads()
  and sending the information back to Java.  This creates a
  List of DownloadItems that contain the basic information needed
  for the UI.

* Adds a basic RecyclerView to display the files in the user's
  download history.

* Adds a DownloadHistoryAdapter that is used to track information
  about the download history.  This *should* be reusable among
  multiple RecyclerViews in case the user opens up multi-window
  mode.

- This currently doesn't monitor any changes to the history and is
  used solely for getting a skeleton working.

BUG=616324

Review-Url: https://codereview.chromium.org/2143303002
Cr-Commit-Position: refs/heads/master@{#405607}
parent 8484d565
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 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. -->
<!-- Represents a single item in the DownloadHistoryAdapterView. -->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp" >
<ImageView
android:id="@+id/icon_view"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="16dp"
android:contentDescription="@null"
android:scaleType="centerInside"
android:background="@color/light_active_color" />
<TextView
android:id="@+id/filename_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@+id/icon_view"
android:singleLine="true"
android:textColor="@color/default_text_color"
android:textSize="16sp" />
<TextView
android:id="@+id/hostname_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@+id/icon_view"
android:layout_toStartOf="@+id/filesize_view"
android:layout_below="@+id/filename_view"
android:layout_marginEnd="16dp"
android:layout_marginTop="0dp"
android:ellipsize="start"
android:singleLine="true" />
<TextView
android:id="@+id/filesize_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_below="@+id/filename_view"
android:layout_marginTop="0dp"
android:textAlignment="viewEnd"
android:singleLine="true" />
</RelativeLayout>
\ No newline at end of file
...@@ -9,30 +9,32 @@ ...@@ -9,30 +9,32 @@
android:layout_height="match_parent" > android:layout_height="match_parent" >
<!-- MAIN CONTENT --> <!-- MAIN CONTENT -->
<RelativeLayout <LinearLayout
android:id="@+id/content_frame" android:id="@+id/content_frame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#ffffff"> android:background="#ffffff"
android:orientation="vertical" >
<org.chromium.chrome.browser.download.ui.DownloadManagerToolbar <org.chromium.chrome.browser.download.ui.DownloadManagerToolbar
android:id="@id/action_bar" android:id="@id/action_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true" android:background="@color/appbar_background" />
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:background="@color/appbar_background" >
</org.chromium.chrome.browser.download.ui.DownloadManagerToolbar>
<org.chromium.chrome.browser.widget.FadingShadowView <org.chromium.chrome.browser.widget.FadingShadowView
android:id="@+id/shadow" android:id="@+id/shadow"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="10dp" android:layout_height="10dp"
android:layout_below="@id/action_bar" /> android:layout_marginBottom="-10dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<!-- Insert RecyclerView here for showing items (or lack thereof). --> </LinearLayout>
</RelativeLayout>
<!-- NAVIGATION DRAWER <!-- NAVIGATION DRAWER
We can't assign a paddingStart or paddingEnd because the section highlights are full-bleed. We can't assign a paddingStart or paddingEnd because the section highlights are full-bleed.
......
...@@ -7,7 +7,7 @@ package org.chromium.chrome.browser.download; ...@@ -7,7 +7,7 @@ package org.chromium.chrome.browser.download;
/** /**
* Class representing the state of a single download. * Class representing the state of a single download.
*/ */
final class DownloadInfo { public final class DownloadInfo {
private final String mUrl; private final String mUrl;
private final String mUserAgent; private final String mUserAgent;
private final String mMimeType; private final String mMimeType;
......
...@@ -29,6 +29,7 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -29,6 +29,7 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.SuppressFBWarnings; import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.ui.DownloadHistoryAdapter;
import org.chromium.chrome.browser.externalnav.ExternalNavigationDelegateImpl; import org.chromium.chrome.browser.externalnav.ExternalNavigationDelegateImpl;
import org.chromium.net.ConnectionType; import org.chromium.net.ConnectionType;
import org.chromium.net.NetworkChangeNotifierAutoDetect; import org.chromium.net.NetworkChangeNotifierAutoDetect;
...@@ -123,6 +124,8 @@ public class DownloadManagerService extends BroadcastReceiver implements ...@@ -123,6 +124,8 @@ public class DownloadManagerService extends BroadcastReceiver implements
@VisibleForTesting protected final Vector<String> mAutoResumableDownloadIds = @VisibleForTesting protected final Vector<String> mAutoResumableDownloadIds =
new Vector<String>(); new Vector<String>();
private final List<DownloadUmaStatsEntry> mUmaEntries = new ArrayList<DownloadUmaStatsEntry>(); private final List<DownloadUmaStatsEntry> mUmaEntries = new ArrayList<DownloadUmaStatsEntry>();
private final DownloadHistoryAdapter mDownloadHistoryAdapter;
private OMADownloadHandler mOMADownloadHandler; private OMADownloadHandler mOMADownloadHandler;
private DownloadSnackbarController mDownloadSnackbarController; private DownloadSnackbarController mDownloadSnackbarController;
private long mNativeDownloadManagerService; private long mNativeDownloadManagerService;
...@@ -232,6 +235,7 @@ public class DownloadManagerService extends BroadcastReceiver implements ...@@ -232,6 +235,7 @@ public class DownloadManagerService extends BroadcastReceiver implements
mOMADownloadHandler = new OMADownloadHandler(context); mOMADownloadHandler = new OMADownloadHandler(context);
mDownloadSnackbarController = new DownloadSnackbarController(context); mDownloadSnackbarController = new DownloadSnackbarController(context);
mDownloadManagerDelegate = new DownloadManagerDelegate(mContext); mDownloadManagerDelegate = new DownloadManagerDelegate(mContext);
mDownloadHistoryAdapter = new DownloadHistoryAdapter();
if (mSharedPrefs.contains(DEPRECATED_DOWNLOAD_NOTIFICATION_IDS)) { if (mSharedPrefs.contains(DEPRECATED_DOWNLOAD_NOTIFICATION_IDS)) {
mSharedPrefs.edit().remove(DEPRECATED_DOWNLOAD_NOTIFICATION_IDS).apply(); mSharedPrefs.edit().remove(DEPRECATED_DOWNLOAD_NOTIFICATION_IDS).apply();
} }
...@@ -1449,6 +1453,49 @@ public class DownloadManagerService extends BroadcastReceiver implements ...@@ -1449,6 +1453,49 @@ public class DownloadManagerService extends BroadcastReceiver implements
} }
} }
/**
* Returns the Adapter that provides a view into the download history.
*/
public DownloadHistoryAdapter getDownloadHistoryAdapter() {
return mDownloadHistoryAdapter;
}
/**
* Begins sending back information about all entries in the user's DownloadHistory, with each
* individual DownloadItem's data passed back via
* {@link #onDownloadInfoAdded(String, String, String, String, long, long)}.
*
* This call will be delayed if the native side has not yet been initialized.
*/
public void getAllDownloads() {
mDownloadHistoryAdapter.clear();
nativeGetAllDownloads(getNativeDownloadManagerService());
}
@CalledByNative
private List<DownloadItem> createDownloadItemList() {
return new ArrayList<DownloadItem>();
}
@CalledByNative
private void addDownloadItemToList(List<DownloadItem> list, String guid, String filename,
String url, String mimeType, long startTimestamp, long totalBytes) {
DownloadInfo.Builder builder = new DownloadInfo.Builder()
.setDownloadGuid(guid)
.setFileName(filename)
.setUrl(url)
.setMimeType(mimeType)
.setContentLength(totalBytes);
DownloadItem downloadItem = new DownloadItem(false, builder.build());
downloadItem.setStartTime(startTimestamp);
list.add(downloadItem);
}
@CalledByNative
private void onAllDownloadsRetrieved(final List<DownloadItem> list) {
mDownloadHistoryAdapter.onAllDownloadsRetrieved(list);
}
@Override @Override
public void onMaxBandwidthChanged(double maxBandwidthMbps) {} public void onMaxBandwidthChanged(double maxBandwidthMbps) {}
...@@ -1471,4 +1518,5 @@ public class DownloadManagerService extends BroadcastReceiver implements ...@@ -1471,4 +1518,5 @@ public class DownloadManagerService extends BroadcastReceiver implements
long nativeDownloadManagerService, String downloadGuid, boolean isOffTheRecord, long nativeDownloadManagerService, String downloadGuid, boolean isOffTheRecord,
boolean isNotificationDismissed); boolean isNotificationDismissed);
private native void nativePauseDownload(long nativeDownloadManagerService, String downloadGuid); private native void nativePauseDownload(long nativeDownloadManagerService, String downloadGuid);
private native void nativeGetAllDownloads(long nativeDownloadManagerService);
} }
// Copyright 2016 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.chrome.browser.download.ui;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.text.format.Formatter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.DownloadItem;
import org.chromium.chrome.browser.util.UrlUtilities;
import java.util.ArrayList;
import java.util.List;
/** Bridges the user's download history and the UI used to display it. */
public class DownloadHistoryAdapter
extends RecyclerView.Adapter<DownloadHistoryAdapter.ViewHolder> {
/** Holds onto a View that displays information about a downloaded file. */
static class ViewHolder extends RecyclerView.ViewHolder {
public ImageView mIconView;
public TextView mFilenameView;
public TextView mHostnameView;
public TextView mFilesizeView;
public ViewHolder(View itemView) {
super(itemView);
mIconView = (ImageView) itemView.findViewById(R.id.icon_view);
mFilenameView = (TextView) itemView.findViewById(R.id.filename_view);
mHostnameView = (TextView) itemView.findViewById(R.id.hostname_view);
mFilesizeView = (TextView) itemView.findViewById(R.id.filesize_view);
}
}
private static final int FILETYPE_OTHER = 0;
private static final int FILETYPE_PAGE = 1;
private static final int FILETYPE_VIDEO = 2;
private static final int FILETYPE_AUDIO = 3;
private static final int FILETYPE_IMAGE = 4;
private static final int FILETYPE_DOCUMENT = 5;
private static final String MIMETYPE_VIDEO = "video";
private static final String MIMETYPE_AUDIO = "audio";
private static final String MIMETYPE_IMAGE = "image";
private static final String MIMETYPE_DOCUMENT = "text";
private final List<DownloadItem> mDownloadItems = new ArrayList<>();
/** Called when the user's download history has been gathered into a List of DownloadItems. */
public void onAllDownloadsRetrieved(List<DownloadItem> list) {
mDownloadItems.clear();
for (DownloadItem item : list) mDownloadItems.add(item);
notifyDataSetChanged();
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(
R.layout.download_item_view, parent, false);
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Context context = holder.mFilesizeView.getContext();
DownloadItem item = mDownloadItems.get(position);
holder.mFilenameView.setText(item.getDownloadInfo().getFileName());
holder.mHostnameView.setText(
UrlUtilities.formatUrlForSecurityDisplay(item.getDownloadInfo().getUrl(), false));
holder.mFilesizeView.setText(
Formatter.formatFileSize(context, item.getDownloadInfo().getContentLength()));
// Pick what icon to display for the item.
int fileType = convertMimeTypeToFileType(item.getDownloadInfo().getMimeType());
int iconResource = R.drawable.ic_drive_file_white_24dp;
switch (fileType) {
case FILETYPE_PAGE:
iconResource = R.drawable.ic_drive_site_white_24dp;
break;
case FILETYPE_VIDEO:
iconResource = R.drawable.ic_music_video_white_24dp;
break;
case FILETYPE_AUDIO:
iconResource = R.drawable.ic_music_note_white_24dp;
break;
case FILETYPE_IMAGE:
iconResource = R.drawable.ic_image_white_24dp;
break;
case FILETYPE_DOCUMENT:
iconResource = R.drawable.ic_drive_file_white_24dp;
break;
default:
}
holder.mIconView.setImageResource(iconResource);
}
@Override
public int getItemCount() {
return mDownloadItems.size();
}
/** Clears out all of the downloads tracked by the Adapter. */
public void clear() {
mDownloadItems.clear();
}
/** Identifies the type of file represented by the given MIME type string. */
private static int convertMimeTypeToFileType(String mimeType) {
if (TextUtils.isEmpty(mimeType)) return FILETYPE_OTHER;
String[] pieces = mimeType.toLowerCase().split("/");
if (pieces.length != 2) return FILETYPE_OTHER;
if (MIMETYPE_VIDEO.equals(pieces[0])) {
return FILETYPE_VIDEO;
} else if (MIMETYPE_AUDIO.equals(pieces[0])) {
return FILETYPE_AUDIO;
} else if (MIMETYPE_IMAGE.equals(pieces[0])) {
return FILETYPE_IMAGE;
} else if (MIMETYPE_DOCUMENT.equals(pieces[0])) {
return FILETYPE_DOCUMENT;
} else {
return FILETYPE_OTHER;
}
}
}
...@@ -13,6 +13,8 @@ import android.os.Environment; ...@@ -13,6 +13,8 @@ import android.os.Environment;
import android.os.StatFs; import android.os.StatFs;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.support.v7.widget.Toolbar.OnMenuItemClickListener; import android.support.v7.widget.Toolbar.OnMenuItemClickListener;
import android.text.format.Formatter; import android.text.format.Formatter;
...@@ -29,8 +31,10 @@ import android.widget.ProgressBar; ...@@ -29,8 +31,10 @@ import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.DownloadManagerService;
import org.chromium.chrome.browser.widget.FadingShadow; import org.chromium.chrome.browser.widget.FadingShadow;
import org.chromium.chrome.browser.widget.FadingShadowView; import org.chromium.chrome.browser.widget.FadingShadowView;
import org.chromium.chrome.browser.widget.TintedDrawable; import org.chromium.chrome.browser.widget.TintedDrawable;
...@@ -191,6 +195,7 @@ public class DownloadManagerUi extends DrawerLayout implements OnMenuItemClickLi ...@@ -191,6 +195,7 @@ public class DownloadManagerUi extends DrawerLayout implements OnMenuItemClickLi
private DownloadManagerToolbar mToolbar; private DownloadManagerToolbar mToolbar;
private SpaceDisplay mSpaceDisplay; private SpaceDisplay mSpaceDisplay;
private ListView mFilterView; private ListView mFilterView;
private RecyclerView mRecyclerView;
public DownloadManagerUi(Context context, AttributeSet attrs) { public DownloadManagerUi(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
...@@ -208,6 +213,12 @@ public class DownloadManagerUi extends DrawerLayout implements OnMenuItemClickLi ...@@ -208,6 +213,12 @@ public class DownloadManagerUi extends DrawerLayout implements OnMenuItemClickLi
mFilterView = (ListView) findViewById(R.id.section_list); mFilterView = (ListView) findViewById(R.id.section_list);
mFilterView.setAdapter(mFilterAdapter); mFilterView.setAdapter(mFilterAdapter);
mFilterView.setOnItemClickListener(mFilterAdapter); mFilterView.setOnItemClickListener(mFilterAdapter);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setAdapter(getDownloadManagerService().getDownloadHistoryAdapter());
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
getDownloadManagerService().getAllDownloads();
} }
/** /**
...@@ -260,4 +271,9 @@ public class DownloadManagerUi extends DrawerLayout implements OnMenuItemClickLi ...@@ -260,4 +271,9 @@ public class DownloadManagerUi extends DrawerLayout implements OnMenuItemClickLi
return false; return false;
} }
private DownloadManagerService getDownloadManagerService() {
return DownloadManagerService.getDownloadManagerService(
ContextUtils.getApplicationContext());
}
} }
...@@ -309,6 +309,7 @@ chrome_java_sources = [ ...@@ -309,6 +309,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/download/DownloadUmaStatsEntry.java", "java/src/org/chromium/chrome/browser/download/DownloadUmaStatsEntry.java",
"java/src/org/chromium/chrome/browser/download/OMADownloadHandler.java", "java/src/org/chromium/chrome/browser/download/OMADownloadHandler.java",
"java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java", "java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java",
"java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java",
"java/src/org/chromium/chrome/browser/download/ui/DownloadManagerUi.java", "java/src/org/chromium/chrome/browser/download/ui/DownloadManagerUi.java",
"java/src/org/chromium/chrome/browser/download/ui/DownloadManagerToolbar.java", "java/src/org/chromium/chrome/browser/download/ui/DownloadManagerToolbar.java",
"java/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtils.java", "java/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtils.java",
......
...@@ -23,6 +23,16 @@ using base::android::JavaParamRef; ...@@ -23,6 +23,16 @@ using base::android::JavaParamRef;
using base::android::ConvertJavaStringToUTF8; using base::android::ConvertJavaStringToUTF8;
using base::android::ConvertUTF8ToJavaString; using base::android::ConvertUTF8ToJavaString;
namespace {
bool ShouldShowDownloadItem(content::DownloadItem* item) {
return !item->IsTemporary() &&
!item->GetFileNameToReportUser().empty() &&
!item->GetTargetFilePath().empty();
}
} // namespace
// static // static
bool DownloadManagerService::RegisterDownloadManagerService(JNIEnv* env) { bool DownloadManagerService::RegisterDownloadManagerService(JNIEnv* env) {
return RegisterNativesImpl(env); return RegisterNativesImpl(env);
...@@ -73,6 +83,50 @@ void DownloadManagerService::PauseDownload( ...@@ -73,6 +83,50 @@ void DownloadManagerService::PauseDownload(
EnqueueDownloadAction(download_guid, PAUSE); EnqueueDownloadAction(download_guid, PAUSE);
} }
void DownloadManagerService::GetAllDownloads(JNIEnv* env,
const JavaParamRef<jobject>& obj) {
if (is_history_query_complete_)
GetAllDownloadsInternal();
else
EnqueueDownloadAction(std::string(), INITIALIZE_UI);
}
void DownloadManagerService::GetAllDownloadsInternal() {
content::DownloadManager* manager = GetDownloadManager(false);
if (java_ref_.is_null() || !manager)
return;
content::DownloadManager::DownloadVector all_items;
manager->GetAllDownloads(&all_items);
// Create a Java array of all of the visible DownloadItems.
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> j_download_item_list =
Java_DownloadManagerService_createDownloadItemList(env, java_ref_.obj());
for (size_t i = 0; i < all_items.size(); i++) {
content::DownloadItem* item = all_items[i];
if (!ShouldShowDownloadItem(item))
continue;
Java_DownloadManagerService_addDownloadItemToList(
env,
java_ref_.obj(),
j_download_item_list.obj(),
ConvertUTF8ToJavaString(env, item->GetGuid()).obj(),
ConvertUTF8ToJavaString(
env, item->GetFileNameToReportUser().BaseName().value()).obj(),
ConvertUTF8ToJavaString(env, item->GetTabUrl().spec()).obj(),
ConvertUTF8ToJavaString(env, item->GetMimeType()).obj(),
item->GetStartTime().ToJavaTime(),
item->GetTotalBytes());
}
Java_DownloadManagerService_onAllDownloadsRetrieved(
env, java_ref_.obj(), j_download_item_list.obj());
}
void DownloadManagerService::CancelDownload( void DownloadManagerService::CancelDownload(
JNIEnv* env, JNIEnv* env,
jobject obj, jobject obj,
...@@ -114,6 +168,9 @@ void DownloadManagerService::OnHistoryQueryComplete() { ...@@ -114,6 +168,9 @@ void DownloadManagerService::OnHistoryQueryComplete() {
case CANCEL: case CANCEL:
CancelDownloadInternal(download_guid, false); CancelDownloadInternal(download_guid, false);
break; break;
case INITIALIZE_UI:
GetAllDownloadsInternal();
break;
default: default:
NOTREACHED(); NOTREACHED();
break; break;
...@@ -188,6 +245,9 @@ void DownloadManagerService::EnqueueDownloadAction( ...@@ -188,6 +245,9 @@ void DownloadManagerService::EnqueueDownloadAction(
case CANCEL: case CANCEL:
iter->second = action; iter->second = action;
break; break;
case INITIALIZE_UI:
iter->second = action;
break;
default: default:
NOTREACHED(); NOTREACHED();
break; break;
......
...@@ -52,6 +52,10 @@ class DownloadManagerService : public DownloadHistory::Observer { ...@@ -52,6 +52,10 @@ class DownloadManagerService : public DownloadHistory::Observer {
jobject obj, jobject obj,
const JavaParamRef<jstring>& jdownload_guid); const JavaParamRef<jstring>& jdownload_guid);
// Called to request that the DownloadManagerService return data about all
// downloads in the user's history.
void GetAllDownloads(JNIEnv* env, const JavaParamRef<jobject>& obj);
// DownloadHistory::Observer methods. // DownloadHistory::Observer methods.
void OnHistoryQueryComplete() override; void OnHistoryQueryComplete() override;
...@@ -73,6 +77,9 @@ class DownloadManagerService : public DownloadHistory::Observer { ...@@ -73,6 +77,9 @@ class DownloadManagerService : public DownloadHistory::Observer {
// Helper function to pause a download. // Helper function to pause a download.
void PauseDownloadInternal(const std::string& download_guid); void PauseDownloadInternal(const std::string& download_guid);
// Helper function to send info about all downloads to the Java-side.
void GetAllDownloadsInternal();
// Called to notify the java side that download resumption failed. // Called to notify the java side that download resumption failed.
void OnResumptionFailed(const std::string& download_guid); void OnResumptionFailed(const std::string& download_guid);
...@@ -88,7 +95,7 @@ class DownloadManagerService : public DownloadHistory::Observer { ...@@ -88,7 +95,7 @@ class DownloadManagerService : public DownloadHistory::Observer {
bool is_history_query_complete_; bool is_history_query_complete_;
enum DownloadAction { RESUME, PAUSE, CANCEL, UNKNOWN }; enum DownloadAction { RESUME, PAUSE, CANCEL, INITIALIZE_UI, UNKNOWN };
using PendingDownloadActions = std::map<std::string, DownloadAction>; using PendingDownloadActions = std::map<std::string, DownloadAction>;
PendingDownloadActions pending_actions_; PendingDownloadActions pending_actions_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment