OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 | 8 |
9 import org.chromium.base.CalledByNative; | 9 import org.chromium.base.CalledByNative; |
10 import org.chromium.base.JNINamespace; | 10 import org.chromium.base.JNINamespace; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 /** | 127 /** |
128 * Notifies the download delegate about progress of a download. Downloads th
at use Chrome | 128 * Notifies the download delegate about progress of a download. Downloads th
at use Chrome |
129 * network stack use custom notification to display the progress of download
s. | 129 * network stack use custom notification to display the progress of download
s. |
130 */ | 130 */ |
131 @CalledByNative | 131 @CalledByNative |
132 public void onDownloadUpdated(Context context, String url, String mimeType, | 132 public void onDownloadUpdated(Context context, String url, String mimeType, |
133 String filename, String path, long contentLength, boolean successful
, int downloadId, | 133 String filename, String path, long contentLength, boolean successful
, int downloadId, |
134 int percentCompleted, long timeRemainingInMs) { | 134 int percentCompleted, long timeRemainingInMs) { |
135 if (sDownloadNotificationService != null) { | 135 if (sDownloadNotificationService != null) { |
136 DownloadInfo downloadInfo = new DownloadInfo.Builder() | 136 DownloadInfo downloadInfo = new DownloadInfo.Builder() |
137 .setUrl(url) | 137 .setUrl(url) |
138 .setMimeType(mimeType) | 138 .setMimeType(mimeType) |
139 .setFileName(filename) | 139 .setFileName(filename) |
140 .setFilePath(path) | 140 .setFilePath(path) |
141 .setContentLength(contentLength) | 141 .setContentLength(contentLength) |
142 .setIsSuccessful(successful) | 142 .setIsSuccessful(successful) |
143 .setDescription(filename) | 143 .setDescription(filename) |
144 .setDownloadId(downloadId) | 144 .setDownloadId(downloadId) |
145 .setHasDownloadId(true) | 145 .setHasDownloadId(true) |
146 .setPercentCompleted(percentCompleted) | 146 .setPercentCompleted(percentCompleted) |
147 .setTimeRemainingInMillis(timeRemainingInMs) | 147 .setTimeRemainingInMillis(timeRemainingInMs) |
148 .build(); | 148 .build(); |
149 sDownloadNotificationService.onDownloadUpdated(downloadInfo); | 149 sDownloadNotificationService.onDownloadUpdated(downloadInfo); |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 /** | 153 /** |
154 * Notifies the download delegate that a dangerous download started. | 154 * Notifies the download delegate that a dangerous download started. |
155 */ | 155 */ |
156 @CalledByNative | 156 @CalledByNative |
157 public void onDangerousDownload(ContentViewCore view, String filename, | 157 public void onDangerousDownload(ContentViewCore view, String filename, |
158 int downloadId) { | 158 int downloadId) { |
159 ContentViewDownloadDelegate downloadDelegate = downloadDelegateFromView(
view); | 159 ContentViewDownloadDelegate downloadDelegate = downloadDelegateFromView(
view); |
160 if (downloadDelegate != null) { | 160 if (downloadDelegate != null) { |
161 downloadDelegate.onDangerousDownload(filename, downloadId); | 161 downloadDelegate.onDangerousDownload(filename, downloadId); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 // native methods | 165 // native methods |
166 private native void nativeInit(); | 166 private native void nativeInit(); |
167 } | 167 } |
OLD | NEW |