Skip to content

Commit

Permalink
[Android] Fix XWALK unable to support download behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
js0701 committed Nov 7, 2014
1 parent 11ee4d9 commit 85afe79
Show file tree
Hide file tree
Showing 4 changed files with 20 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
16 changes: 14 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,20 @@ 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 85afe79

Please sign in to comment.