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/webui/url_data_manager_backend.h" | 5 #include "content/browser/webui/url_data_manager_backend.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/debug/alias.h" | 12 #include "base/debug/alias.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
17 #include "base/memory/ref_counted_memory.h" | 18 #include "base/memory/ref_counted_memory.h" |
18 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
19 #include "base/profiler/scoped_tracker.h" | 20 #include "base/profiler/scoped_tracker.h" |
20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
21 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
23 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
24 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
25 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 26 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
(...skipping 12 matching lines...) Expand all Loading... |
38 #include "net/base/io_buffer.h" | 39 #include "net/base/io_buffer.h" |
39 #include "net/base/net_errors.h" | 40 #include "net/base/net_errors.h" |
40 #include "net/http/http_response_headers.h" | 41 #include "net/http/http_response_headers.h" |
41 #include "net/http/http_status_code.h" | 42 #include "net/http/http_status_code.h" |
42 #include "net/log/net_log_util.h" | 43 #include "net/log/net_log_util.h" |
43 #include "net/url_request/url_request.h" | 44 #include "net/url_request/url_request.h" |
44 #include "net/url_request/url_request_context.h" | 45 #include "net/url_request/url_request_context.h" |
45 #include "net/url_request/url_request_error_job.h" | 46 #include "net/url_request/url_request_error_job.h" |
46 #include "net/url_request/url_request_job.h" | 47 #include "net/url_request/url_request_job.h" |
47 #include "net/url_request/url_request_job_factory.h" | 48 #include "net/url_request/url_request_job_factory.h" |
48 | |
49 #include "url/url_util.h" | 49 #include "url/url_util.h" |
50 | 50 |
51 namespace content { | 51 namespace content { |
52 | 52 |
53 namespace { | 53 namespace { |
54 | 54 |
55 const char kChromeURLContentSecurityPolicyHeaderBase[] = | 55 const char kChromeURLContentSecurityPolicyHeaderBase[] = |
56 "Content-Security-Policy: script-src chrome://resources 'self'"; | 56 "Content-Security-Policy: script-src chrome://resources 'self'"; |
57 | 57 |
58 const char kChromeURLXFrameOptionsHeader[] = "X-Frame-Options: DENY"; | 58 const char kChromeURLXFrameOptionsHeader[] = "X-Frame-Options: DENY"; |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 BrowserThread::PostTask( | 451 BrowserThread::PostTask( |
452 BrowserThread::IO, FROM_HERE, | 452 BrowserThread::IO, FROM_HERE, |
453 base::Bind(&URLRequestChromeJob::MimeTypeAvailable, job, mime_type)); | 453 base::Bind(&URLRequestChromeJob::MimeTypeAvailable, job, mime_type)); |
454 } | 454 } |
455 | 455 |
456 } // namespace | 456 } // namespace |
457 | 457 |
458 namespace { | 458 namespace { |
459 | 459 |
460 bool IsValidNetworkErrorCode(int error_code) { | 460 bool IsValidNetworkErrorCode(int error_code) { |
461 scoped_ptr<base::DictionaryValue> error_codes = net::GetNetConstants(); | 461 std::unique_ptr<base::DictionaryValue> error_codes = net::GetNetConstants(); |
462 const base::DictionaryValue* net_error_codes_dict = nullptr; | 462 const base::DictionaryValue* net_error_codes_dict = nullptr; |
463 | 463 |
464 for (base::DictionaryValue::Iterator itr(*error_codes); !itr.IsAtEnd(); | 464 for (base::DictionaryValue::Iterator itr(*error_codes); !itr.IsAtEnd(); |
465 itr.Advance()) { | 465 itr.Advance()) { |
466 if (itr.key() == kNetworkErrorKey) { | 466 if (itr.key() == kNetworkErrorKey) { |
467 itr.value().GetAsDictionary(&net_error_codes_dict); | 467 itr.value().GetAsDictionary(&net_error_codes_dict); |
468 break; | 468 break; |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 | 566 |
567 URLDataManagerBackend::~URLDataManagerBackend() { | 567 URLDataManagerBackend::~URLDataManagerBackend() { |
568 for (DataSourceMap::iterator i = data_sources_.begin(); | 568 for (DataSourceMap::iterator i = data_sources_.begin(); |
569 i != data_sources_.end(); ++i) { | 569 i != data_sources_.end(); ++i) { |
570 i->second->backend_ = NULL; | 570 i->second->backend_ = NULL; |
571 } | 571 } |
572 data_sources_.clear(); | 572 data_sources_.clear(); |
573 } | 573 } |
574 | 574 |
575 // static | 575 // static |
576 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 576 std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler> |
577 URLDataManagerBackend::CreateProtocolHandler( | 577 URLDataManagerBackend::CreateProtocolHandler( |
578 content::ResourceContext* resource_context, | 578 content::ResourceContext* resource_context, |
579 bool is_incognito, | 579 bool is_incognito, |
580 ChromeBlobStorageContext* blob_storage_context) { | 580 ChromeBlobStorageContext* blob_storage_context) { |
581 DCHECK(resource_context); | 581 DCHECK(resource_context); |
582 return make_scoped_ptr(new ChromeProtocolHandler( | 582 return base::WrapUnique(new ChromeProtocolHandler( |
583 resource_context, is_incognito, blob_storage_context)); | 583 resource_context, is_incognito, blob_storage_context)); |
584 } | 584 } |
585 | 585 |
586 void URLDataManagerBackend::AddDataSource( | 586 void URLDataManagerBackend::AddDataSource( |
587 URLDataSourceImpl* source) { | 587 URLDataSourceImpl* source) { |
588 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 588 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
589 DataSourceMap::iterator i = data_sources_.find(source->source_name()); | 589 DataSourceMap::iterator i = data_sources_.find(source->source_name()); |
590 if (i != data_sources_.end()) { | 590 if (i != data_sources_.end()) { |
591 if (!source->source()->ShouldReplaceExistingSource()) | 591 if (!source->source()->ShouldReplaceExistingSource()) |
592 return; | 592 return; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 | 796 |
797 } // namespace | 797 } // namespace |
798 | 798 |
799 net::URLRequestJobFactory::ProtocolHandler* | 799 net::URLRequestJobFactory::ProtocolHandler* |
800 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, | 800 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, |
801 bool is_incognito) { | 801 bool is_incognito) { |
802 return new DevToolsJobFactory(resource_context, is_incognito); | 802 return new DevToolsJobFactory(resource_context, is_incognito); |
803 } | 803 } |
804 | 804 |
805 } // namespace content | 805 } // namespace content |
OLD | NEW |