Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java

Issue 2110543004: Move JNI bindings for url_formatter from chrome to //components/url_formatter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.download.ui; 5 package org.chromium.chrome.browser.download.ui;
6 6
7 import android.content.ComponentName; 7 import android.content.ComponentName;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.res.Resources; 9 import android.content.res.Resources;
10 import android.graphics.Paint; 10 import android.graphics.Paint;
(...skipping 11 matching lines...) Expand all
22 import org.chromium.base.metrics.RecordHistogram; 22 import org.chromium.base.metrics.RecordHistogram;
23 import org.chromium.chrome.R; 23 import org.chromium.chrome.R;
24 import org.chromium.chrome.browser.download.DownloadItem; 24 import org.chromium.chrome.browser.download.DownloadItem;
25 import org.chromium.chrome.browser.download.ui.BackendProvider.DownloadDelegate; 25 import org.chromium.chrome.browser.download.ui.BackendProvider.DownloadDelegate;
26 import org.chromium.chrome.browser.download.ui.BackendProvider.OfflinePageDelega te; 26 import org.chromium.chrome.browser.download.ui.BackendProvider.OfflinePageDelega te;
27 import org.chromium.chrome.browser.download.ui.DownloadHistoryItemWrapper.Downlo adItemWrapper; 27 import org.chromium.chrome.browser.download.ui.DownloadHistoryItemWrapper.Downlo adItemWrapper;
28 import org.chromium.chrome.browser.download.ui.DownloadHistoryItemWrapper.Offlin ePageItemWrapper; 28 import org.chromium.chrome.browser.download.ui.DownloadHistoryItemWrapper.Offlin ePageItemWrapper;
29 import org.chromium.chrome.browser.download.ui.DownloadManagerUi.DownloadUiObser ver; 29 import org.chromium.chrome.browser.download.ui.DownloadManagerUi.DownloadUiObser ver;
30 import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadBri dge; 30 import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadBri dge;
31 import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadIte m; 31 import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadIte m;
32 import org.chromium.chrome.browser.util.UrlUtilities;
33 import org.chromium.chrome.browser.widget.DateDividedAdapter; 32 import org.chromium.chrome.browser.widget.DateDividedAdapter;
34 import org.chromium.chrome.browser.widget.selection.SelectionDelegate; 33 import org.chromium.chrome.browser.widget.selection.SelectionDelegate;
34 import org.chromium.components.url_formatter.UrlFormatter;
35 35
36 import java.util.ArrayList; 36 import java.util.ArrayList;
37 import java.util.List; 37 import java.util.List;
38 38
39 /** Bridges the user's download history and the UI used to display it. */ 39 /** Bridges the user's download history and the UI used to display it. */
40 public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo adUiObserver { 40 public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo adUiObserver {
41 41
42 /** Holds onto a View that displays information about a downloaded file. */ 42 /** Holds onto a View that displays information about a downloaded file. */
43 public static class ItemViewHolder extends RecyclerView.ViewHolder { 43 public static class ItemViewHolder extends RecyclerView.ViewHolder {
44 public DownloadItemView mItemView; 44 public DownloadItemView mItemView;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 @Override 157 @Override
158 public void bindViewHolderForTimedItem(ViewHolder current, TimedItem timedIt em) { 158 public void bindViewHolderForTimedItem(ViewHolder current, TimedItem timedIt em) {
159 final DownloadHistoryItemWrapper item = (DownloadHistoryItemWrapper) tim edItem; 159 final DownloadHistoryItemWrapper item = (DownloadHistoryItemWrapper) tim edItem;
160 160
161 ItemViewHolder holder = (ItemViewHolder) current; 161 ItemViewHolder holder = (ItemViewHolder) current;
162 DownloadHistoryItemWrapper previousItem = holder.mItemView.mItem; 162 DownloadHistoryItemWrapper previousItem = holder.mItemView.mItem;
163 Context context = holder.mFilesizeView.getContext(); 163 Context context = holder.mFilesizeView.getContext();
164 holder.mFilenameView.setText(item.getDisplayFileName()); 164 holder.mFilenameView.setText(item.getDisplayFileName());
165 holder.mHostnameView.setText( 165 holder.mHostnameView.setText(
166 UrlUtilities.formatUrlForSecurityDisplay(item.getUrl(), false)); 166 UrlFormatter.formatUrlForSecurityDisplay(item.getUrl(), false));
167 holder.mFilesizeView.setText( 167 holder.mFilesizeView.setText(
168 Formatter.formatFileSize(context, item.getFileSize())); 168 Formatter.formatFileSize(context, item.getFileSize()));
169 holder.mItemView.initialize(item); 169 holder.mItemView.initialize(item);
170 170
171 // Pick what icon to display for the item. 171 // Pick what icon to display for the item.
172 int fileType = item.getFilterType(); 172 int fileType = item.getFilterType();
173 int iconResource = R.drawable.ic_drive_file_white_24dp; 173 int iconResource = R.drawable.ic_drive_file_white_24dp;
174 switch (fileType) { 174 switch (fileType) {
175 case DownloadFilter.FILTER_PAGE: 175 case DownloadFilter.FILTER_PAGE:
176 iconResource = R.drawable.ic_drive_site_white_24dp; 176 iconResource = R.drawable.ic_drive_site_white_24dp;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCou nt.Image", 391 RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCou nt.Image",
392 itemCounts[DownloadFilter.FILTER_IMAGE]); 392 itemCounts[DownloadFilter.FILTER_IMAGE]);
393 RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCou nt.Other", 393 RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCou nt.Other",
394 itemCounts[DownloadFilter.FILTER_OTHER]); 394 itemCounts[DownloadFilter.FILTER_OTHER]);
395 RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCou nt.Video", 395 RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCou nt.Video",
396 itemCounts[DownloadFilter.FILTER_VIDEO]); 396 itemCounts[DownloadFilter.FILTER_VIDEO]);
397 RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCou nt.Total", 397 RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCou nt.Total",
398 totalCount); 398 totalCount);
399 } 399 }
400 } 400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698