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

Commit

Permalink
[Android] Fix XWALK unable to support download behavior
Browse files Browse the repository at this point in the history
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
  • Loading branch information
js0701 committed Nov 10, 2014
1 parent 11ee4d9 commit cff355d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,16 @@ public void onDownloadStart(String url,
String contentDisposition,
String mimeType,
long contentLength) {
if (mDownloadListener != null) {
mDownloadListener.onDownloadStart(url, userAgent, contentDisposition,
mimeType, contentLength);
}
}

@Override
public boolean onCreateWindow(boolean isDialog, boolean isUserGesture) {
if (isDialog) return false;

XWalkUIClientInternal.InitiateByInternal initiator =
XWalkUIClientInternal.InitiateByInternal.BY_JAVASCRIPT;
if (isUserGesture) {
Expand Down
17 changes: 15 additions & 2 deletions runtime/browser/android/xwalk_contents_io_thread_client_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,21 @@ void RfhToIoThreadClientMap::Set(pair<int, int> rfh_id,
bool RfhToIoThreadClientMap::Get(
pair<int, int> rfh_id, IoThreadClientData* client) {
base::AutoLock lock(map_lock_);
RenderFrameHostToIoThreadClientType::iterator iterator =
rfh_to_io_thread_client_.find(rfh_id);
RenderFrameHostToIoThreadClientType::iterator iterator;

if (rfh_id.second != MSG_ROUTING_NONE) {
iterator = rfh_to_io_thread_client_.find(rfh_id);
} else {
// Content use render_frame_id= MSG_ROUTING_NONE for download request
// So just find the matched process_id
iterator = rfh_to_io_thread_client_.begin();
while (iterator != rfh_to_io_thread_client_.end()) {
if (iterator->first.first == rfh_id.first)
break;
iterator++;
}
}

if (iterator == rfh_to_io_thread_client_.end())
return false;

Expand Down
2 changes: 1 addition & 1 deletion runtime/browser/runtime_download_manager_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void RuntimeDownloadManagerDelegate::ChooseDownloadPath(
if (GetSaveFileName(&save_as))
result = base::FilePath(std::wstring(save_as.lpstrFile));
#else
NOTIMPLEMENTED();
result = suggested_path;
#endif

callback.Run(result, content::DownloadItem::TARGET_DISPOSITION_PROMPT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ void RuntimeResourceDispatcherHostDelegateAndroid::DownloadStarting(
response_headers->GetMimeType(&mime_type);
}

request->Cancel();

const content::ResourceRequestInfo* request_info =
content::ResourceRequestInfo::ForRequest(request);

Expand Down

0 comments on commit cff355d

Please sign in to comment.