Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit cff355d

Browse files
committed
[Android] Fix XWALK unable to support download behavior
Several bugs reported that Xwalk not able to support "download" attribute from anchor since XWALK4 Changes in this commit 1) Implement onDownloadStart method in XWalkContentsClientBridge to call download listener method 2) Ignore render_frame_id which is set to MSG_ROUTING_NONE from content for download request 3) In runtime_download_manager_deledate, return the suggested path to content 4) In runtime_resource_dispatcher_host_delegate_android, don't cancel request, because content will use it later on to futher operation(rename, trunk..etc) BUG=https://crosswalk-project.org/jira/browse/XWALK-1079
1 parent 11ee4d9 commit cff355d

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClientBridge.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,16 @@ public void onDownloadStart(String url,
373373
String contentDisposition,
374374
String mimeType,
375375
long contentLength) {
376+
if (mDownloadListener != null) {
377+
mDownloadListener.onDownloadStart(url, userAgent, contentDisposition,
378+
mimeType, contentLength);
379+
}
376380
}
377381

378382
@Override
379383
public boolean onCreateWindow(boolean isDialog, boolean isUserGesture) {
380384
if (isDialog) return false;
381-
385+
382386
XWalkUIClientInternal.InitiateByInternal initiator =
383387
XWalkUIClientInternal.InitiateByInternal.BY_JAVASCRIPT;
384388
if (isUserGesture) {

runtime/browser/android/xwalk_contents_io_thread_client_impl.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,21 @@ void RfhToIoThreadClientMap::Set(pair<int, int> rfh_id,
8989
bool RfhToIoThreadClientMap::Get(
9090
pair<int, int> rfh_id, IoThreadClientData* client) {
9191
base::AutoLock lock(map_lock_);
92-
RenderFrameHostToIoThreadClientType::iterator iterator =
93-
rfh_to_io_thread_client_.find(rfh_id);
92+
RenderFrameHostToIoThreadClientType::iterator iterator;
93+
94+
if (rfh_id.second != MSG_ROUTING_NONE) {
95+
iterator = rfh_to_io_thread_client_.find(rfh_id);
96+
} else {
97+
// Content use render_frame_id= MSG_ROUTING_NONE for download request
98+
// So just find the matched process_id
99+
iterator = rfh_to_io_thread_client_.begin();
100+
while (iterator != rfh_to_io_thread_client_.end()) {
101+
if (iterator->first.first == rfh_id.first)
102+
break;
103+
iterator++;
104+
}
105+
}
106+
94107
if (iterator == rfh_to_io_thread_client_.end())
95108
return false;
96109

runtime/browser/runtime_download_manager_delegate.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void RuntimeDownloadManagerDelegate::ChooseDownloadPath(
164164
if (GetSaveFileName(&save_as))
165165
result = base::FilePath(std::wstring(save_as.lpstrFile));
166166
#else
167-
NOTIMPLEMENTED();
167+
result = suggested_path;
168168
#endif
169169

170170
callback.Run(result, content::DownloadItem::TARGET_DISPOSITION_PROMPT,

runtime/browser/runtime_resource_dispatcher_host_delegate_android.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ void RuntimeResourceDispatcherHostDelegateAndroid::DownloadStarting(
259259
response_headers->GetMimeType(&mime_type);
260260
}
261261

262-
request->Cancel();
263-
264262
const content::ResourceRequestInfo* request_info =
265263
content::ResourceRequestInfo::ForRequest(request);
266264

0 commit comments

Comments
 (0)