OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "content/browser/download/download_resource_handler.h" | 5 #include "content/browser/download/download_resource_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 void DownloadResourceHandler::ResumeRequest() { | 189 void DownloadResourceHandler::ResumeRequest() { |
190 core_.ResumeRequest(); | 190 core_.ResumeRequest(); |
191 } | 191 } |
192 | 192 |
193 void DownloadResourceHandler::OnStart( | 193 void DownloadResourceHandler::OnStart( |
194 std::unique_ptr<DownloadCreateInfo> create_info, | 194 std::unique_ptr<DownloadCreateInfo> create_info, |
195 std::unique_ptr<ByteStreamReader> stream_reader, | 195 std::unique_ptr<ByteStreamReader> stream_reader, |
196 const DownloadUrlParameters::OnStartedCallback& callback) { | 196 const DownloadUrlParameters::OnStartedCallback& callback) { |
197 // If the user cancels the download, then don't call start. Instead ignore the | 197 // If the user cancels the download, then don't call start. Instead ignore the |
198 // download entirely. | 198 // download entirely. |
199 if (create_info->result == DOWNLOAD_INTERRUPT_REASON_USER_CANCELED && | 199 bool download_canceled = |
200 create_info->download_id == DownloadItem::kInvalidId) { | 200 create_info->result == DOWNLOAD_INTERRUPT_REASON_USER_CANCELED && |
| 201 create_info->download_id == DownloadItem::kInvalidId; |
| 202 // Also don't start a download if it has to be handed off to OfflinePages. |
| 203 download_canceled = download_canceled || |
| 204 create_info->result == DOWNLOAD_INTERRUPT_REASON_PAGE_DOWNLOAD_HANDOFF; |
| 205 if (download_canceled) { |
201 if (!callback.is_null()) | 206 if (!callback.is_null()) |
202 BrowserThread::PostTask( | 207 BrowserThread::PostTask( |
203 BrowserThread::UI, FROM_HERE, | 208 BrowserThread::UI, FROM_HERE, |
204 base::Bind(callback, nullptr, create_info->result)); | 209 base::Bind(callback, nullptr, create_info->result)); |
205 return; | 210 return; |
206 } | 211 } |
207 | 212 |
208 const ResourceRequestInfoImpl* request_info = GetRequestInfo(); | 213 const ResourceRequestInfoImpl* request_info = GetRequestInfo(); |
209 create_info->has_user_gesture = request_info->HasUserGesture(); | 214 create_info->has_user_gesture = request_info->HasUserGesture(); |
210 create_info->transition_type = request_info->GetPageTransition(); | 215 create_info->transition_type = request_info->GetPageTransition(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 " }", | 256 " }", |
252 request() ? | 257 request() ? |
253 request()->url().spec().c_str() : | 258 request()->url().spec().c_str() : |
254 "<NULL request>", | 259 "<NULL request>", |
255 info->GetChildID(), | 260 info->GetChildID(), |
256 info->GetRequestID(), | 261 info->GetRequestID(), |
257 info->GetRouteID()); | 262 info->GetRouteID()); |
258 } | 263 } |
259 | 264 |
260 } // namespace content | 265 } // namespace content |
OLD | NEW |