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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "content/browser/download/save_file_manager.h" | 7 #include "content/browser/download/save_file_manager.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "content/browser/child_process_security_policy_impl.h" | 15 #include "content/browser/child_process_security_policy_impl.h" |
16 #include "content/browser/download/save_file.h" | 16 #include "content/browser/download/save_file.h" |
17 #include "content/browser/download/save_file_resource_handler.h" | 17 #include "content/browser/download/save_file_resource_handler.h" |
18 #include "content/browser/download/save_package.h" | 18 #include "content/browser/download/save_package.h" |
19 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 19 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
20 #include "content/browser/renderer_host/render_view_host_impl.h" | 20 #include "content/browser/renderer_host/render_view_host_impl.h" |
21 #include "content/browser/web_contents/web_contents_impl.h" | 21 #include "content/browser/web_contents/web_contents_impl.h" |
22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
24 #include "content/public/browser/resource_context.h" | 24 #include "content/public/browser/resource_context.h" |
| 25 #include "content/public/common/previews_state.h" |
25 #include "net/base/io_buffer.h" | 26 #include "net/base/io_buffer.h" |
26 #include "net/base/load_flags.h" | 27 #include "net/base/load_flags.h" |
27 #include "net/url_request/url_request.h" | 28 #include "net/url_request/url_request.h" |
28 #include "net/url_request/url_request_context.h" | 29 #include "net/url_request/url_request_context.h" |
29 #include "net/url_request/url_request_job_factory.h" | 30 #include "net/url_request/url_request_job_factory.h" |
30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
31 | 32 |
32 namespace content { | 33 namespace content { |
33 | 34 |
34 namespace { | 35 namespace { |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 std::unique_ptr<net::URLRequest> request( | 310 std::unique_ptr<net::URLRequest> request( |
310 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL)); | 311 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL)); |
311 request->set_method("GET"); | 312 request->set_method("GET"); |
312 | 313 |
313 // The URLRequest needs to be initialized with the referrer and other | 314 // The URLRequest needs to be initialized with the referrer and other |
314 // information prior to issuing it. | 315 // information prior to issuing it. |
315 ResourceDispatcherHostImpl::Get()->InitializeURLRequest( | 316 ResourceDispatcherHostImpl::Get()->InitializeURLRequest( |
316 request.get(), referrer, | 317 request.get(), referrer, |
317 false, // download. | 318 false, // download. |
318 render_process_host_id, render_view_routing_id, render_frame_routing_id, | 319 render_process_host_id, render_view_routing_id, render_frame_routing_id, |
319 context); | 320 PREVIEWS_OFF, context); |
320 | 321 |
321 // So far, for saving page, we need fetch content from cache, in the | 322 // So far, for saving page, we need fetch content from cache, in the |
322 // future, maybe we can use a configuration to configure this behavior. | 323 // future, maybe we can use a configuration to configure this behavior. |
323 request->SetLoadFlags(net::LOAD_SKIP_CACHE_VALIDATION); | 324 request->SetLoadFlags(net::LOAD_SKIP_CACHE_VALIDATION); |
324 | 325 |
325 // Check if the renderer is permitted to request the requested URL. | 326 // Check if the renderer is permitted to request the requested URL. |
326 using AuthorizationState = SaveFileResourceHandler::AuthorizationState; | 327 using AuthorizationState = SaveFileResourceHandler::AuthorizationState; |
327 AuthorizationState authorization_state = AuthorizationState::AUTHORIZED; | 328 AuthorizationState authorization_state = AuthorizationState::AUTHORIZED; |
328 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( | 329 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( |
329 render_process_host_id, url)) { | 330 render_process_host_id, url)) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 if (it != save_file_map_.end()) { | 448 if (it != save_file_map_.end()) { |
448 SaveFile* save_file = it->second.get(); | 449 SaveFile* save_file = it->second.get(); |
449 DCHECK(!save_file->InProgress()); | 450 DCHECK(!save_file->InProgress()); |
450 base::DeleteFile(save_file->FullPath(), false); | 451 base::DeleteFile(save_file->FullPath(), false); |
451 save_file_map_.erase(it); | 452 save_file_map_.erase(it); |
452 } | 453 } |
453 } | 454 } |
454 } | 455 } |
455 | 456 |
456 } // namespace content | 457 } // namespace content |
OLD | NEW |