| 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 "chrome/browser/ui/webui/chrome_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/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
| 14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/ref_counted_memory.h" | 17 #include "base/memory/ref_counted_memory.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "chrome/browser/ui/webui/shared_resources_data_source.h" | 21 #include "content/browser/webui/shared_resources_data_source.h" |
| 22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
| 24 #include "googleurl/src/url_util.h" | 24 #include "googleurl/src/url_util.h" |
| 25 #include "grit/platform_locale_settings.h" | |
| 26 #include "net/base/io_buffer.h" | 25 #include "net/base/io_buffer.h" |
| 27 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
| 28 #include "net/http/http_response_headers.h" | 27 #include "net/http/http_response_headers.h" |
| 29 #include "net/url_request/url_request.h" | 28 #include "net/url_request/url_request.h" |
| 30 #include "net/url_request/url_request_context.h" | 29 #include "net/url_request/url_request_context.h" |
| 31 #include "net/url_request/url_request_job.h" | 30 #include "net/url_request/url_request_job.h" |
| 32 #include "net/url_request/url_request_job_factory.h" | 31 #include "net/url_request/url_request_job_factory.h" |
| 33 | 32 |
| 34 using content::BrowserThread; | 33 using content::BrowserThread; |
| 35 | 34 |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } | 514 } |
| 516 } | 515 } |
| 517 | 516 |
| 518 namespace { | 517 namespace { |
| 519 | 518 |
| 520 class DevToolsJobFactory | 519 class DevToolsJobFactory |
| 521 : public net::URLRequestJobFactory::ProtocolHandler { | 520 : public net::URLRequestJobFactory::ProtocolHandler { |
| 522 public: | 521 public: |
| 523 // |is_incognito| should be set for incognito profiles. | 522 // |is_incognito| should be set for incognito profiles. |
| 524 DevToolsJobFactory(ChromeURLDataManagerBackend* backend, | 523 DevToolsJobFactory(ChromeURLDataManagerBackend* backend, |
| 525 net::NetworkDelegate* network_delegate, | |
| 526 bool is_incognito); | 524 bool is_incognito); |
| 527 virtual ~DevToolsJobFactory(); | 525 virtual ~DevToolsJobFactory(); |
| 528 | 526 |
| 529 virtual net::URLRequestJob* MaybeCreateJob( | 527 virtual net::URLRequestJob* MaybeCreateJob( |
| 530 net::URLRequest* request, | 528 net::URLRequest* request, |
| 531 net::NetworkDelegate* network_delegate) const OVERRIDE; | 529 net::NetworkDelegate* network_delegate) const OVERRIDE; |
| 532 | 530 |
| 533 private: | 531 private: |
| 534 // |backend_| and |network_delegate_| are owned by ProfileIOData, which owns | 532 // |backend_| and |network_delegate_| are owned by ProfileIOData, which owns |
| 535 // this ProtocolHandler. | 533 // this ProtocolHandler. |
| 536 ChromeURLDataManagerBackend* const backend_; | 534 ChromeURLDataManagerBackend* const backend_; |
| 537 net::NetworkDelegate* network_delegate_; | |
| 538 | 535 |
| 539 // True when generated from an incognito profile. | 536 // True when generated from an incognito profile. |
| 540 const bool is_incognito_; | 537 const bool is_incognito_; |
| 541 | 538 |
| 542 DISALLOW_COPY_AND_ASSIGN(DevToolsJobFactory); | 539 DISALLOW_COPY_AND_ASSIGN(DevToolsJobFactory); |
| 543 }; | 540 }; |
| 544 | 541 |
| 545 DevToolsJobFactory::DevToolsJobFactory(ChromeURLDataManagerBackend* backend, | 542 DevToolsJobFactory::DevToolsJobFactory(ChromeURLDataManagerBackend* backend, |
| 546 net::NetworkDelegate* network_delegate, | |
| 547 bool is_incognito) | 543 bool is_incognito) |
| 548 : backend_(backend), | 544 : backend_(backend), |
| 549 network_delegate_(network_delegate), | |
| 550 is_incognito_(is_incognito) { | 545 is_incognito_(is_incognito) { |
| 551 DCHECK(backend_); | 546 DCHECK(backend_); |
| 552 } | 547 } |
| 553 | 548 |
| 554 DevToolsJobFactory::~DevToolsJobFactory() {} | 549 DevToolsJobFactory::~DevToolsJobFactory() {} |
| 555 | 550 |
| 556 net::URLRequestJob* | 551 net::URLRequestJob* |
| 557 DevToolsJobFactory::MaybeCreateJob( | 552 DevToolsJobFactory::MaybeCreateJob( |
| 558 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { | 553 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
| 559 return new URLRequestChromeJob(request, network_delegate, backend_, | 554 return new URLRequestChromeJob(request, network_delegate, backend_, |
| 560 is_incognito_); | 555 is_incognito_); |
| 561 } | 556 } |
| 562 | 557 |
| 563 } // namespace | 558 } // namespace |
| 564 | 559 |
| 565 net::URLRequestJobFactory::ProtocolHandler* | 560 net::URLRequestJobFactory::ProtocolHandler* |
| 566 CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend, | 561 CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend, |
| 567 net::NetworkDelegate* network_delegate, | |
| 568 bool is_incognito) { | 562 bool is_incognito) { |
| 569 return new DevToolsJobFactory(backend, network_delegate, is_incognito); | 563 return new DevToolsJobFactory(backend, is_incognito); |
| 570 } | 564 } |
| OLD | NEW |