Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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; | 5 package org.chromium.chrome.browser.download; |
| 6 | 6 |
| 7 import org.chromium.base.annotations.CalledByNative; | 7 import org.chromium.base.annotations.CalledByNative; |
| 8 import org.chromium.content_public.browser.DownloadState; | 8 import org.chromium.content_public.browser.DownloadState; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 private final String mContentDisposition; | 26 private final String mContentDisposition; |
| 27 private final boolean mIsGETRequest; | 27 private final boolean mIsGETRequest; |
| 28 private final int mPercentCompleted; | 28 private final int mPercentCompleted; |
| 29 private final long mTimeRemainingInMillis; | 29 private final long mTimeRemainingInMillis; |
| 30 private final boolean mIsResumable; | 30 private final boolean mIsResumable; |
| 31 private final boolean mIsPaused; | 31 private final boolean mIsPaused; |
| 32 private final boolean mIsOffTheRecord; | 32 private final boolean mIsOffTheRecord; |
| 33 private final boolean mIsOfflinePage; | 33 private final boolean mIsOfflinePage; |
| 34 private final int mState; | 34 private final int mState; |
| 35 private final long mLastAccessTime; | 35 private final long mLastAccessTime; |
| 36 private final boolean mIsVisible; | |
| 36 | 37 |
| 37 private DownloadInfo(Builder builder) { | 38 private DownloadInfo(Builder builder) { |
| 38 mUrl = builder.mUrl; | 39 mUrl = builder.mUrl; |
| 39 mUserAgent = builder.mUserAgent; | 40 mUserAgent = builder.mUserAgent; |
| 40 mMimeType = builder.mMimeType; | 41 mMimeType = builder.mMimeType; |
| 41 mCookie = builder.mCookie; | 42 mCookie = builder.mCookie; |
| 42 mFileName = builder.mFileName; | 43 mFileName = builder.mFileName; |
| 43 mDescription = builder.mDescription; | 44 mDescription = builder.mDescription; |
| 44 mFilePath = builder.mFilePath; | 45 mFilePath = builder.mFilePath; |
| 45 mReferrer = builder.mReferrer; | 46 mReferrer = builder.mReferrer; |
| 46 mOriginalUrl = builder.mOriginalUrl; | 47 mOriginalUrl = builder.mOriginalUrl; |
| 47 mBytesReceived = builder.mBytesReceived; | 48 mBytesReceived = builder.mBytesReceived; |
| 48 mDownloadGuid = builder.mDownloadGuid; | 49 mDownloadGuid = builder.mDownloadGuid; |
| 49 mHasUserGesture = builder.mHasUserGesture; | 50 mHasUserGesture = builder.mHasUserGesture; |
| 50 mIsGETRequest = builder.mIsGETRequest; | 51 mIsGETRequest = builder.mIsGETRequest; |
| 51 mContentDisposition = builder.mContentDisposition; | 52 mContentDisposition = builder.mContentDisposition; |
| 52 mPercentCompleted = builder.mPercentCompleted; | 53 mPercentCompleted = builder.mPercentCompleted; |
| 53 mTimeRemainingInMillis = builder.mTimeRemainingInMillis; | 54 mTimeRemainingInMillis = builder.mTimeRemainingInMillis; |
| 54 mIsResumable = builder.mIsResumable; | 55 mIsResumable = builder.mIsResumable; |
| 55 mIsPaused = builder.mIsPaused; | 56 mIsPaused = builder.mIsPaused; |
| 56 mIsOffTheRecord = builder.mIsOffTheRecord; | 57 mIsOffTheRecord = builder.mIsOffTheRecord; |
| 57 mIsOfflinePage = builder.mIsOfflinePage; | 58 mIsOfflinePage = builder.mIsOfflinePage; |
| 58 mState = builder.mState; | 59 mState = builder.mState; |
| 59 mLastAccessTime = builder.mLastAccessTime; | 60 mLastAccessTime = builder.mLastAccessTime; |
| 61 mIsVisible = builder.mIsVisible; | |
| 60 } | 62 } |
| 61 | 63 |
| 62 public String getUrl() { | 64 public String getUrl() { |
| 63 return mUrl; | 65 return mUrl; |
| 64 } | 66 } |
| 65 | 67 |
| 66 public String getUserAgent() { | 68 public String getUserAgent() { |
| 67 return mUserAgent; | 69 return mUserAgent; |
| 68 } | 70 } |
| 69 | 71 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 } | 148 } |
| 147 | 149 |
| 148 public int state() { | 150 public int state() { |
| 149 return mState; | 151 return mState; |
| 150 } | 152 } |
| 151 | 153 |
| 152 public long getLastAccessTime() { | 154 public long getLastAccessTime() { |
| 153 return mLastAccessTime; | 155 return mLastAccessTime; |
| 154 } | 156 } |
| 155 | 157 |
| 158 public boolean isVisible() { | |
|
David Trainor- moved to gerrit
2017/03/06 18:28:39
Do we want to make this have an impact on the UI?
shaktisahu
2017/03/08 06:51:30
Removed from Java layer.
| |
| 159 return mIsVisible; | |
| 160 } | |
| 161 | |
| 156 /** | 162 /** |
| 157 * Helper class for building the DownloadInfo object. | 163 * Helper class for building the DownloadInfo object. |
| 158 */ | 164 */ |
| 159 public static class Builder { | 165 public static class Builder { |
| 160 private String mUrl; | 166 private String mUrl; |
| 161 private String mUserAgent; | 167 private String mUserAgent; |
| 162 private String mMimeType; | 168 private String mMimeType; |
| 163 private String mCookie; | 169 private String mCookie; |
| 164 private String mFileName; | 170 private String mFileName; |
| 165 private String mDescription; | 171 private String mDescription; |
| 166 private String mFilePath; | 172 private String mFilePath; |
| 167 private String mReferrer; | 173 private String mReferrer; |
| 168 private String mOriginalUrl; | 174 private String mOriginalUrl; |
| 169 private long mBytesReceived; | 175 private long mBytesReceived; |
| 170 private boolean mIsGETRequest; | 176 private boolean mIsGETRequest; |
| 171 private String mDownloadGuid; | 177 private String mDownloadGuid; |
| 172 private boolean mHasUserGesture; | 178 private boolean mHasUserGesture; |
| 173 private String mContentDisposition; | 179 private String mContentDisposition; |
| 174 private int mPercentCompleted = -1; | 180 private int mPercentCompleted = -1; |
| 175 private long mTimeRemainingInMillis; | 181 private long mTimeRemainingInMillis; |
| 176 private boolean mIsResumable = true; | 182 private boolean mIsResumable = true; |
| 177 private boolean mIsPaused; | 183 private boolean mIsPaused; |
| 178 private boolean mIsOffTheRecord; | 184 private boolean mIsOffTheRecord; |
| 179 private boolean mIsOfflinePage; | 185 private boolean mIsOfflinePage; |
| 180 private int mState = DownloadState.IN_PROGRESS; | 186 private int mState = DownloadState.IN_PROGRESS; |
| 181 private long mLastAccessTime; | 187 private long mLastAccessTime; |
| 188 private boolean mIsVisible; | |
| 182 | 189 |
| 183 public Builder setUrl(String url) { | 190 public Builder setUrl(String url) { |
| 184 mUrl = url; | 191 mUrl = url; |
| 185 return this; | 192 return this; |
| 186 } | 193 } |
| 187 | 194 |
| 188 public Builder setUserAgent(String userAgent) { | 195 public Builder setUserAgent(String userAgent) { |
| 189 mUserAgent = userAgent; | 196 mUserAgent = userAgent; |
| 190 return this; | 197 return this; |
| 191 } | 198 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 public Builder setState(int downloadState) { | 291 public Builder setState(int downloadState) { |
| 285 mState = downloadState; | 292 mState = downloadState; |
| 286 return this; | 293 return this; |
| 287 } | 294 } |
| 288 | 295 |
| 289 public Builder setLastAccessTime(long lastAccessTime) { | 296 public Builder setLastAccessTime(long lastAccessTime) { |
| 290 mLastAccessTime = lastAccessTime; | 297 mLastAccessTime = lastAccessTime; |
| 291 return this; | 298 return this; |
| 292 } | 299 } |
| 293 | 300 |
| 301 public Builder setIsVisible(boolean isVisible) { | |
| 302 mIsVisible = isVisible; | |
| 303 return this; | |
| 304 } | |
| 305 | |
| 294 public DownloadInfo build() { | 306 public DownloadInfo build() { |
| 295 return new DownloadInfo(this); | 307 return new DownloadInfo(this); |
| 296 } | 308 } |
| 297 | 309 |
| 298 /** | 310 /** |
| 299 * Create a builder from the DownloadInfo object. | 311 * Create a builder from the DownloadInfo object. |
| 300 * @param downloadInfo DownloadInfo object from which builder fields are populated. | 312 * @param downloadInfo DownloadInfo object from which builder fields are populated. |
| 301 * @return A builder initialized with fields from downloadInfo object. | 313 * @return A builder initialized with fields from downloadInfo object. |
| 302 */ | 314 */ |
| 303 public static Builder fromDownloadInfo(final DownloadInfo downloadInfo) { | 315 public static Builder fromDownloadInfo(final DownloadInfo downloadInfo) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 316 .setHasUserGesture(downloadInfo.hasUserGesture()) | 328 .setHasUserGesture(downloadInfo.hasUserGesture()) |
| 317 .setContentDisposition(downloadInfo.getContentDisposition()) | 329 .setContentDisposition(downloadInfo.getContentDisposition()) |
| 318 .setIsGETRequest(downloadInfo.isGETRequest()) | 330 .setIsGETRequest(downloadInfo.isGETRequest()) |
| 319 .setPercentCompleted(downloadInfo.getPercentCompleted()) | 331 .setPercentCompleted(downloadInfo.getPercentCompleted()) |
| 320 .setTimeRemainingInMillis(downloadInfo.getTimeRemainingInMil lis()) | 332 .setTimeRemainingInMillis(downloadInfo.getTimeRemainingInMil lis()) |
| 321 .setIsResumable(downloadInfo.isResumable()) | 333 .setIsResumable(downloadInfo.isResumable()) |
| 322 .setIsPaused(downloadInfo.isPaused()) | 334 .setIsPaused(downloadInfo.isPaused()) |
| 323 .setIsOffTheRecord(downloadInfo.isOffTheRecord()) | 335 .setIsOffTheRecord(downloadInfo.isOffTheRecord()) |
| 324 .setIsOfflinePage(downloadInfo.isOfflinePage()) | 336 .setIsOfflinePage(downloadInfo.isOfflinePage()) |
| 325 .setState(downloadInfo.state()) | 337 .setState(downloadInfo.state()) |
| 326 .setLastAccessTime(downloadInfo.getLastAccessTime()); | 338 .setLastAccessTime(downloadInfo.getLastAccessTime()) |
| 339 .setIsVisible(downloadInfo.isVisible()); | |
| 327 return builder; | 340 return builder; |
| 328 } | 341 } |
| 329 } | 342 } |
| 330 | 343 |
| 331 @CalledByNative | 344 @CalledByNative |
| 332 private static DownloadInfo createDownloadInfo(String downloadGuid, String f ileName, | 345 private static DownloadInfo createDownloadInfo(String downloadGuid, String f ileName, |
| 333 String filePath, String url, String mimeType, long bytesReceived, bo olean isIncognito, | 346 String filePath, String url, String mimeType, long bytesReceived, bo olean isIncognito, |
| 334 int state, int percentCompleted, boolean isPaused, boolean hasUserGe sture, | 347 int state, int percentCompleted, boolean isPaused, boolean hasUserGe sture, |
| 335 boolean isResumable, String originalUrl, String referrerUrl, long ti meRemainingInMs, | 348 boolean isResumable, String originalUrl, String referrerUrl, long ti meRemainingInMs, |
| 336 long lastAccessTime) { | 349 long lastAccessTime, boolean isVisible) { |
| 337 String remappedMimeType = ChromeDownloadDelegate.remapGenericMimeType( | 350 String remappedMimeType = ChromeDownloadDelegate.remapGenericMimeType( |
| 338 mimeType, url, fileName); | 351 mimeType, url, fileName); |
| 339 return new DownloadInfo.Builder() | 352 return new DownloadInfo.Builder() |
| 340 .setBytesReceived(bytesReceived) | 353 .setBytesReceived(bytesReceived) |
| 341 .setDescription(fileName) | 354 .setDescription(fileName) |
| 342 .setDownloadGuid(downloadGuid) | 355 .setDownloadGuid(downloadGuid) |
| 343 .setFileName(fileName) | 356 .setFileName(fileName) |
| 344 .setFilePath(filePath) | 357 .setFilePath(filePath) |
| 345 .setHasUserGesture(hasUserGesture) | 358 .setHasUserGesture(hasUserGesture) |
| 346 .setIsOffTheRecord(isIncognito) | 359 .setIsOffTheRecord(isIncognito) |
| 347 .setIsPaused(isPaused) | 360 .setIsPaused(isPaused) |
| 348 .setIsResumable(isResumable) | 361 .setIsResumable(isResumable) |
| 349 .setMimeType(remappedMimeType) | 362 .setMimeType(remappedMimeType) |
| 350 .setOriginalUrl(originalUrl) | 363 .setOriginalUrl(originalUrl) |
| 351 .setPercentCompleted(percentCompleted) | 364 .setPercentCompleted(percentCompleted) |
| 352 .setReferrer(referrerUrl) | 365 .setReferrer(referrerUrl) |
| 353 .setState(state) | 366 .setState(state) |
| 354 .setTimeRemainingInMillis(timeRemainingInMs) | 367 .setTimeRemainingInMillis(timeRemainingInMs) |
| 355 .setLastAccessTime(lastAccessTime) | 368 .setLastAccessTime(lastAccessTime) |
| 369 .setIsVisible(isVisible) | |
| 356 .setUrl(url) | 370 .setUrl(url) |
| 357 .build(); | 371 .build(); |
| 358 } | 372 } |
| 359 } | 373 } |
| OLD | NEW |