| 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" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // The URLRequest needs to be initialized with the referrer and other | 313 // The URLRequest needs to be initialized with the referrer and other |
| 314 // information prior to issuing it. | 314 // information prior to issuing it. |
| 315 ResourceDispatcherHostImpl::Get()->InitializeURLRequest( | 315 ResourceDispatcherHostImpl::Get()->InitializeURLRequest( |
| 316 request.get(), referrer, | 316 request.get(), referrer, |
| 317 false, // download. | 317 false, // download. |
| 318 render_process_host_id, render_view_routing_id, render_frame_routing_id, | 318 render_process_host_id, render_view_routing_id, render_frame_routing_id, |
| 319 context); | 319 context); |
| 320 | 320 |
| 321 // So far, for saving page, we need fetch content from cache, in the | 321 // 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. | 322 // future, maybe we can use a configuration to configure this behavior. |
| 323 request->SetLoadFlags(net::LOAD_PREFERRING_CACHE); | 323 request->SetLoadFlags(net::LOAD_SKIP_CACHE_VALIDATION); |
| 324 | 324 |
| 325 // Check if the renderer is permitted to request the requested URL. | 325 // Check if the renderer is permitted to request the requested URL. |
| 326 using AuthorizationState = SaveFileResourceHandler::AuthorizationState; | 326 using AuthorizationState = SaveFileResourceHandler::AuthorizationState; |
| 327 AuthorizationState authorization_state = AuthorizationState::AUTHORIZED; | 327 AuthorizationState authorization_state = AuthorizationState::AUTHORIZED; |
| 328 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( | 328 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( |
| 329 render_process_host_id, url)) { | 329 render_process_host_id, url)) { |
| 330 DVLOG(1) << "Denying unauthorized save of " << url.possibly_invalid_spec(); | 330 DVLOG(1) << "Denying unauthorized save of " << url.possibly_invalid_spec(); |
| 331 authorization_state = AuthorizationState::NOT_AUTHORIZED; | 331 authorization_state = AuthorizationState::NOT_AUTHORIZED; |
| 332 // No need to return here (i.e. okay to begin processing the request below), | 332 // No need to return here (i.e. okay to begin processing the request below), |
| 333 // because NOT_AUTHORIZED will cause the request to be cancelled. See also | 333 // because NOT_AUTHORIZED will cause the request to be cancelled. See also |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 SaveFile* save_file = it->second; | 450 SaveFile* save_file = it->second; |
| 451 DCHECK(!save_file->InProgress()); | 451 DCHECK(!save_file->InProgress()); |
| 452 base::DeleteFile(save_file->FullPath(), false); | 452 base::DeleteFile(save_file->FullPath(), false); |
| 453 delete save_file; | 453 delete save_file; |
| 454 save_file_map_.erase(it); | 454 save_file_map_.erase(it); |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 | 458 |
| 459 } // namespace content | 459 } // namespace content |
| OLD | NEW |