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 "content/public/common/previews_state.h" |
26 #include "net/base/io_buffer.h" | 26 #include "net/base/io_buffer.h" |
27 #include "net/base/load_flags.h" | 27 #include "net/base/load_flags.h" |
| 28 #include "net/traffic_annotation/network_traffic_annotation.h" |
28 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
29 #include "net/url_request/url_request_context.h" | 30 #include "net/url_request/url_request_context.h" |
30 #include "net/url_request/url_request_job_factory.h" | 31 #include "net/url_request/url_request_job_factory.h" |
31 #include "url/gurl.h" | 32 #include "url/gurl.h" |
32 | 33 |
33 namespace content { | 34 namespace content { |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 // Pointer to the singleton SaveFileManager instance. | 38 // Pointer to the singleton SaveFileManager instance. |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 301 |
301 const net::URLRequestContext* request_context = context->GetRequestContext(); | 302 const net::URLRequestContext* request_context = context->GetRequestContext(); |
302 if (!request_context->job_factory()->IsHandledProtocol(url.scheme())) { | 303 if (!request_context->job_factory()->IsHandledProtocol(url.scheme())) { |
303 // Since any URLs which have non-standard scheme have been filtered | 304 // Since any URLs which have non-standard scheme have been filtered |
304 // by save manager(see GURL::SchemeIsStandard). This situation | 305 // by save manager(see GURL::SchemeIsStandard). This situation |
305 // should not happen. | 306 // should not happen. |
306 NOTREACHED(); | 307 NOTREACHED(); |
307 return; | 308 return; |
308 } | 309 } |
309 | 310 |
310 std::unique_ptr<net::URLRequest> request( | 311 net::NetworkTrafficAnnotationTag traffic_annotation = |
311 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL)); | 312 net::DefineNetworkTrafficAnnotation("...", R"( |
| 313 semantics { |
| 314 sender: "..." |
| 315 description: "..." |
| 316 trigger: "..." |
| 317 data: "..." |
| 318 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER/LOCAL |
| 319 } |
| 320 policy { |
| 321 cookies_allowed: false/true |
| 322 cookies_store: "..." |
| 323 setting: "..." |
| 324 chrome_policy { |
| 325 [POLICY_NAME] { |
| 326 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} |
| 327 [POLICY_NAME]: ... //(value to disable it) |
| 328 } |
| 329 } |
| 330 policy_exception_justification: "..." |
| 331 })"); |
| 332 std::unique_ptr<net::URLRequest> request(request_context->CreateRequest( |
| 333 url, net::DEFAULT_PRIORITY, NULL, traffic_annotation)); |
312 request->set_method("GET"); | 334 request->set_method("GET"); |
313 | 335 |
314 // The URLRequest needs to be initialized with the referrer and other | 336 // The URLRequest needs to be initialized with the referrer and other |
315 // information prior to issuing it. | 337 // information prior to issuing it. |
316 ResourceDispatcherHostImpl::Get()->InitializeURLRequest( | 338 ResourceDispatcherHostImpl::Get()->InitializeURLRequest( |
317 request.get(), referrer, | 339 request.get(), referrer, |
318 false, // download. | 340 false, // download. |
319 render_process_host_id, render_view_routing_id, render_frame_routing_id, | 341 render_process_host_id, render_view_routing_id, render_frame_routing_id, |
320 PREVIEWS_OFF, context); | 342 PREVIEWS_OFF, context); |
321 | 343 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 if (it != save_file_map_.end()) { | 470 if (it != save_file_map_.end()) { |
449 SaveFile* save_file = it->second.get(); | 471 SaveFile* save_file = it->second.get(); |
450 DCHECK(!save_file->InProgress()); | 472 DCHECK(!save_file->InProgress()); |
451 base::DeleteFile(save_file->FullPath(), false); | 473 base::DeleteFile(save_file->FullPath(), false); |
452 save_file_map_.erase(it); | 474 save_file_map_.erase(it); |
453 } | 475 } |
454 } | 476 } |
455 } | 477 } |
456 | 478 |
457 } // namespace content | 479 } // namespace content |
OLD | NEW |