Chromium Code Reviews| 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 "chrome/browser/ui/webui/chrome_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/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
| 22 #include "chrome/browser/net/chrome_url_request_context.h" | 22 #include "chrome/browser/net/chrome_url_request_context.h" |
|
mmenke
2013/01/16 16:51:26
Don't think this is needed any more.
| |
| 23 #include "chrome/browser/ui/webui/shared_resources_data_source.h" | 23 #include "chrome/browser/ui/webui/shared_resources_data_source.h" |
| 24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 28 #include "googleurl/src/url_util.h" | 28 #include "googleurl/src/url_util.h" |
| 29 #include "grit/platform_locale_settings.h" | 29 #include "grit/platform_locale_settings.h" |
| 30 #include "net/base/io_buffer.h" | 30 #include "net/base/io_buffer.h" |
| 31 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
| 32 #include "net/http/http_response_headers.h" | 32 #include "net/http/http_response_headers.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 | 201 |
| 202 } // namespace | 202 } // namespace |
| 203 | 203 |
| 204 // URLRequestChromeJob is a net::URLRequestJob that manages running | 204 // URLRequestChromeJob is a net::URLRequestJob that manages running |
| 205 // chrome-internal resource requests asynchronously. | 205 // chrome-internal resource requests asynchronously. |
| 206 // It hands off URL requests to ChromeURLDataManager, which asynchronously | 206 // It hands off URL requests to ChromeURLDataManager, which asynchronously |
| 207 // calls back once the data is available. | 207 // calls back once the data is available. |
| 208 class URLRequestChromeJob : public net::URLRequestJob, | 208 class URLRequestChromeJob : public net::URLRequestJob, |
| 209 public base::SupportsWeakPtr<URLRequestChromeJob> { | 209 public base::SupportsWeakPtr<URLRequestChromeJob> { |
| 210 public: | 210 public: |
| 211 // |is_incognito| set when job is generated from an incognito profile. | |
| 211 URLRequestChromeJob(net::URLRequest* request, | 212 URLRequestChromeJob(net::URLRequest* request, |
| 212 net::NetworkDelegate* network_delegate, | 213 net::NetworkDelegate* network_delegate, |
| 213 ChromeURLDataManagerBackend* backend); | 214 ChromeURLDataManagerBackend* backend, |
| 215 bool is_incognito); | |
| 214 | 216 |
| 215 // net::URLRequestJob implementation. | 217 // net::URLRequestJob implementation. |
| 216 virtual void Start() OVERRIDE; | 218 virtual void Start() OVERRIDE; |
| 217 virtual void Kill() OVERRIDE; | 219 virtual void Kill() OVERRIDE; |
| 218 virtual bool ReadRawData(net::IOBuffer* buf, | 220 virtual bool ReadRawData(net::IOBuffer* buf, |
| 219 int buf_size, | 221 int buf_size, |
| 220 int* bytes_read) OVERRIDE; | 222 int* bytes_read) OVERRIDE; |
| 221 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 223 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 222 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; | 224 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; |
| 223 | 225 |
| 224 // Used to notify that the requested data's |mime_type| is ready. | 226 // Used to notify that the requested data's |mime_type| is ready. |
| 225 void MimeTypeAvailable(const std::string& mime_type); | 227 void MimeTypeAvailable(const std::string& mime_type); |
| 226 | 228 |
| 227 // Called by ChromeURLDataManager to notify us that the data blob is ready | 229 // Called by ChromeURLDataManager to notify us that the data blob is ready |
| 228 // for us. | 230 // for us. |
| 229 void DataAvailable(base::RefCountedMemory* bytes); | 231 void DataAvailable(base::RefCountedMemory* bytes); |
| 230 | 232 |
| 231 void set_mime_type(const std::string& mime_type) { | 233 void set_mime_type(const std::string& mime_type) { |
| 232 mime_type_ = mime_type; | 234 mime_type_ = mime_type; |
| 233 } | 235 } |
| 234 | 236 |
| 235 void set_allow_caching(bool allow_caching) { | 237 void set_allow_caching(bool allow_caching) { |
| 236 allow_caching_ = allow_caching; | 238 allow_caching_ = allow_caching; |
| 237 } | 239 } |
| 238 | 240 |
| 241 // Returns true when job was generated from an incognito profile. | |
| 242 bool is_incognito() const { | |
| 243 return is_incognito_; | |
| 244 } | |
| 245 | |
| 239 private: | 246 private: |
| 240 virtual ~URLRequestChromeJob(); | 247 virtual ~URLRequestChromeJob(); |
| 241 | 248 |
| 242 // Helper for Start(), to let us start asynchronously. | 249 // Helper for Start(), to let us start asynchronously. |
| 243 // (This pattern is shared by most net::URLRequestJob implementations.) | 250 // (This pattern is shared by most net::URLRequestJob implementations.) |
| 244 void StartAsync(); | 251 void StartAsync(); |
| 245 | 252 |
| 246 // Do the actual copy from data_ (the data we're serving) into |buf|. | 253 // Do the actual copy from data_ (the data we're serving) into |buf|. |
| 247 // Separate from ReadRawData so we can handle async I/O. | 254 // Separate from ReadRawData so we can handle async I/O. |
| 248 void CompleteRead(net::IOBuffer* buf, int buf_size, int* bytes_read); | 255 void CompleteRead(net::IOBuffer* buf, int buf_size, int* bytes_read); |
| 249 | 256 |
| 250 // The actual data we're serving. NULL until it's been fetched. | 257 // The actual data we're serving. NULL until it's been fetched. |
| 251 scoped_refptr<base::RefCountedMemory> data_; | 258 scoped_refptr<base::RefCountedMemory> data_; |
| 252 // The current offset into the data that we're handing off to our | 259 // The current offset into the data that we're handing off to our |
| 253 // callers via the Read interfaces. | 260 // callers via the Read interfaces. |
| 254 int data_offset_; | 261 int data_offset_; |
| 255 | 262 |
| 256 // For async reads, we keep around a pointer to the buffer that | 263 // For async reads, we keep around a pointer to the buffer that |
| 257 // we're reading into. | 264 // we're reading into. |
| 258 scoped_refptr<net::IOBuffer> pending_buf_; | 265 scoped_refptr<net::IOBuffer> pending_buf_; |
| 259 int pending_buf_size_; | 266 int pending_buf_size_; |
| 260 std::string mime_type_; | 267 std::string mime_type_; |
| 261 | 268 |
| 262 // If true, set a header in the response to prevent it from being cached. | 269 // If true, set a header in the response to prevent it from being cached. |
| 263 bool allow_caching_; | 270 bool allow_caching_; |
| 264 | 271 |
| 272 // True when job is generated from an incognito profile. | |
| 273 const bool is_incognito_; | |
| 274 | |
| 265 // The backend is owned by ChromeURLRequestContext and always outlives us. | 275 // The backend is owned by ChromeURLRequestContext and always outlives us. |
| 266 ChromeURLDataManagerBackend* backend_; | 276 ChromeURLDataManagerBackend* backend_; |
| 267 | 277 |
| 268 base::WeakPtrFactory<URLRequestChromeJob> weak_factory_; | 278 base::WeakPtrFactory<URLRequestChromeJob> weak_factory_; |
| 269 | 279 |
| 270 DISALLOW_COPY_AND_ASSIGN(URLRequestChromeJob); | 280 DISALLOW_COPY_AND_ASSIGN(URLRequestChromeJob); |
| 271 }; | 281 }; |
| 272 | 282 |
| 273 URLRequestChromeJob::URLRequestChromeJob(net::URLRequest* request, | 283 URLRequestChromeJob::URLRequestChromeJob(net::URLRequest* request, |
| 274 net::NetworkDelegate* network_delegate, | 284 net::NetworkDelegate* network_delegate, |
| 275 ChromeURLDataManagerBackend* backend) | 285 ChromeURLDataManagerBackend* backend, |
| 286 bool is_incognito) | |
| 276 : net::URLRequestJob(request, network_delegate), | 287 : net::URLRequestJob(request, network_delegate), |
| 277 data_offset_(0), | 288 data_offset_(0), |
| 278 pending_buf_size_(0), | 289 pending_buf_size_(0), |
| 279 allow_caching_(true), | 290 allow_caching_(true), |
| 291 is_incognito_(is_incognito), | |
| 280 backend_(backend), | 292 backend_(backend), |
| 281 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 293 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 282 DCHECK(backend); | 294 DCHECK(backend); |
| 283 } | 295 } |
| 284 | 296 |
| 285 URLRequestChromeJob::~URLRequestChromeJob() { | 297 URLRequestChromeJob::~URLRequestChromeJob() { |
| 286 CHECK(!backend_->HasPendingJob(this)); | 298 CHECK(!backend_->HasPendingJob(this)); |
| 287 } | 299 } |
| 288 | 300 |
| 289 void URLRequestChromeJob::Start() { | 301 void URLRequestChromeJob::Start() { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 base::Bind(&URLRequestChromeJob::MimeTypeAvailable, job, mime_type)); | 412 base::Bind(&URLRequestChromeJob::MimeTypeAvailable, job, mime_type)); |
| 401 } | 413 } |
| 402 | 414 |
| 403 } // namespace | 415 } // namespace |
| 404 | 416 |
| 405 namespace { | 417 namespace { |
| 406 | 418 |
| 407 class ChromeProtocolHandler | 419 class ChromeProtocolHandler |
| 408 : public net::URLRequestJobFactory::ProtocolHandler { | 420 : public net::URLRequestJobFactory::ProtocolHandler { |
| 409 public: | 421 public: |
| 410 explicit ChromeProtocolHandler(ChromeURLDataManagerBackend* backend); | 422 // |is_incognito| should be set for incognito profiles. |
| 423 explicit ChromeProtocolHandler(ChromeURLDataManagerBackend* backend, | |
| 424 bool is_incognito); | |
| 411 ~ChromeProtocolHandler(); | 425 ~ChromeProtocolHandler(); |
| 412 | 426 |
| 413 virtual net::URLRequestJob* MaybeCreateJob( | 427 virtual net::URLRequestJob* MaybeCreateJob( |
| 414 net::URLRequest* request, | 428 net::URLRequest* request, |
| 415 net::NetworkDelegate* network_delegate) const OVERRIDE; | 429 net::NetworkDelegate* network_delegate) const OVERRIDE; |
| 416 | 430 |
| 417 private: | 431 private: |
| 418 // These members are owned by ProfileIOData, which owns this ProtocolHandler. | 432 // These members are owned by ProfileIOData, which owns this ProtocolHandler. |
| 419 ChromeURLDataManagerBackend* const backend_; | 433 ChromeURLDataManagerBackend* const backend_; |
| 420 | 434 |
| 435 // True when generated from an incognito profile. | |
| 436 const bool is_incognito_; | |
| 437 | |
| 421 DISALLOW_COPY_AND_ASSIGN(ChromeProtocolHandler); | 438 DISALLOW_COPY_AND_ASSIGN(ChromeProtocolHandler); |
| 422 }; | 439 }; |
| 423 | 440 |
| 424 ChromeProtocolHandler::ChromeProtocolHandler( | 441 ChromeProtocolHandler::ChromeProtocolHandler( |
| 425 ChromeURLDataManagerBackend* backend) | 442 ChromeURLDataManagerBackend* backend, bool is_incognito) |
| 426 : backend_(backend) {} | 443 : backend_(backend), is_incognito_(is_incognito) {} |
| 427 | 444 |
| 428 ChromeProtocolHandler::~ChromeProtocolHandler() {} | 445 ChromeProtocolHandler::~ChromeProtocolHandler() {} |
| 429 | 446 |
| 430 net::URLRequestJob* ChromeProtocolHandler::MaybeCreateJob( | 447 net::URLRequestJob* ChromeProtocolHandler::MaybeCreateJob( |
| 431 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { | 448 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
| 432 DCHECK(request); | 449 DCHECK(request); |
| 433 | 450 |
| 434 // Fall back to using a custom handler | 451 // Fall back to using a custom handler |
| 435 return new URLRequestChromeJob(request, network_delegate, backend_); | 452 return new URLRequestChromeJob(request, network_delegate, backend_, |
| 453 is_incognito_); | |
| 436 } | 454 } |
| 437 | 455 |
| 438 } // namespace | 456 } // namespace |
| 439 | 457 |
| 440 ChromeURLDataManagerBackend::ChromeURLDataManagerBackend() | 458 ChromeURLDataManagerBackend::ChromeURLDataManagerBackend() |
| 441 : next_request_id_(0) { | 459 : next_request_id_(0) { |
| 442 content::URLDataSourceDelegate* shared_source = | 460 content::URLDataSourceDelegate* shared_source = |
| 443 new SharedResourcesDataSource(); | 461 new SharedResourcesDataSource(); |
| 444 shared_source->url_data_source_ = | 462 shared_source->url_data_source_ = |
| 445 new URLDataSource(shared_source->GetSource(), shared_source); | 463 new URLDataSource(shared_source->GetSource(), shared_source); |
| 446 AddDataSource(shared_source->url_data_source_); | 464 AddDataSource(shared_source->url_data_source_); |
| 447 } | 465 } |
| 448 | 466 |
| 449 ChromeURLDataManagerBackend::~ChromeURLDataManagerBackend() { | 467 ChromeURLDataManagerBackend::~ChromeURLDataManagerBackend() { |
| 450 for (DataSourceMap::iterator i = data_sources_.begin(); | 468 for (DataSourceMap::iterator i = data_sources_.begin(); |
| 451 i != data_sources_.end(); ++i) { | 469 i != data_sources_.end(); ++i) { |
| 452 i->second->backend_ = NULL; | 470 i->second->backend_ = NULL; |
| 453 } | 471 } |
| 454 data_sources_.clear(); | 472 data_sources_.clear(); |
| 455 } | 473 } |
| 456 | 474 |
| 457 // static | 475 // static |
| 458 net::URLRequestJobFactory::ProtocolHandler* | 476 net::URLRequestJobFactory::ProtocolHandler* |
| 459 ChromeURLDataManagerBackend::CreateProtocolHandler( | 477 ChromeURLDataManagerBackend::CreateProtocolHandler( |
| 460 ChromeURLDataManagerBackend* backend) { | 478 ChromeURLDataManagerBackend* backend, bool is_incognito) { |
| 461 DCHECK(backend); | 479 DCHECK(backend); |
| 462 return new ChromeProtocolHandler(backend); | 480 return new ChromeProtocolHandler(backend, is_incognito); |
| 463 } | 481 } |
| 464 | 482 |
| 465 void ChromeURLDataManagerBackend::AddDataSource( | 483 void ChromeURLDataManagerBackend::AddDataSource( |
| 466 URLDataSource* source) { | 484 URLDataSource* source) { |
| 467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 485 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 468 DataSourceMap::iterator i = data_sources_.find(source->source_name()); | 486 DataSourceMap::iterator i = data_sources_.find(source->source_name()); |
| 469 if (i != data_sources_.end()) { | 487 if (i != data_sources_.end()) { |
| 470 if (!source->delegate()->ShouldReplaceExistingSource()) | 488 if (!source->delegate()->ShouldReplaceExistingSource()) |
| 471 return; | 489 return; |
| 472 i->second->backend_ = NULL; | 490 i->second->backend_ = NULL; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 498 return false; | 516 return false; |
| 499 | 517 |
| 500 URLDataSource* source = i->second; | 518 URLDataSource* source = i->second; |
| 501 | 519 |
| 502 // Save this request so we know where to send the data. | 520 // Save this request so we know where to send the data. |
| 503 RequestID request_id = next_request_id_++; | 521 RequestID request_id = next_request_id_++; |
| 504 pending_requests_.insert(std::make_pair(request_id, job)); | 522 pending_requests_.insert(std::make_pair(request_id, job)); |
| 505 | 523 |
| 506 job->set_allow_caching(source->delegate()->AllowCaching()); | 524 job->set_allow_caching(source->delegate()->AllowCaching()); |
| 507 | 525 |
| 508 const ChromeURLRequestContext* context = | |
| 509 static_cast<const ChromeURLRequestContext*>(job->request()->context()); | |
| 510 | |
| 511 // Forward along the request to the data source. | 526 // Forward along the request to the data source. |
| 512 MessageLoop* target_message_loop = | 527 MessageLoop* target_message_loop = |
| 513 source->delegate()->MessageLoopForRequestPath(path); | 528 source->delegate()->MessageLoopForRequestPath(path); |
| 514 if (!target_message_loop) { | 529 if (!target_message_loop) { |
| 515 job->MimeTypeAvailable(source->delegate()->GetMimeType(path)); | 530 job->MimeTypeAvailable(source->delegate()->GetMimeType(path)); |
| 516 | 531 |
| 517 // The DataSource is agnostic to which thread StartDataRequest is called | 532 // The DataSource is agnostic to which thread StartDataRequest is called |
| 518 // on for this path. Call directly into it from this thread, the IO | 533 // on for this path. Call directly into it from this thread, the IO |
| 519 // thread. | 534 // thread. |
| 520 source->delegate()->StartDataRequest( | 535 source->delegate()->StartDataRequest(path, job->is_incognito(), request_id); |
| 521 path, context->is_incognito(), request_id); | |
| 522 } else { | 536 } else { |
| 523 // URLRequestChromeJob should receive mime type before data. This | 537 // URLRequestChromeJob should receive mime type before data. This |
| 524 // is guaranteed because request for mime type is placed in the | 538 // is guaranteed because request for mime type is placed in the |
| 525 // message loop before request for data. And correspondingly their | 539 // message loop before request for data. And correspondingly their |
| 526 // replies are put on the IO thread in the same order. | 540 // replies are put on the IO thread in the same order. |
| 527 target_message_loop->PostTask( | 541 target_message_loop->PostTask( |
| 528 FROM_HERE, | 542 FROM_HERE, |
| 529 base::Bind(&GetMimeTypeOnUI, | 543 base::Bind(&GetMimeTypeOnUI, |
| 530 scoped_refptr<URLDataSource>(source), | 544 scoped_refptr<URLDataSource>(source), |
| 531 path, job->AsWeakPtr())); | 545 path, job->AsWeakPtr())); |
| 532 | 546 |
| 533 // The DataSource wants StartDataRequest to be called on a specific thread, | 547 // The DataSource wants StartDataRequest to be called on a specific thread, |
| 534 // usually the UI thread, for this path. | 548 // usually the UI thread, for this path. |
| 535 target_message_loop->PostTask( | 549 target_message_loop->PostTask( |
| 536 FROM_HERE, | 550 FROM_HERE, |
| 537 base::Bind(&ChromeURLDataManagerBackend::CallStartRequest, | 551 base::Bind(&ChromeURLDataManagerBackend::CallStartRequest, |
| 538 make_scoped_refptr(source), path, context->is_incognito(), | 552 make_scoped_refptr(source), path, job->is_incognito(), |
| 539 request_id)); | 553 request_id)); |
| 540 } | 554 } |
| 541 return true; | 555 return true; |
| 542 } | 556 } |
| 543 | 557 |
| 544 void ChromeURLDataManagerBackend::CallStartRequest( | 558 void ChromeURLDataManagerBackend::CallStartRequest( |
| 545 scoped_refptr<URLDataSource> source, | 559 scoped_refptr<URLDataSource> source, |
| 546 const std::string& path, | 560 const std::string& path, |
| 547 bool is_incognito, | 561 bool is_incognito, |
| 548 int request_id) { | 562 int request_id) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 return false; | 628 return false; |
| 615 | 629 |
| 616 *path = inspector_dir.AppendASCII(relative_path); | 630 *path = inspector_dir.AppendASCII(relative_path); |
| 617 return true; | 631 return true; |
| 618 } | 632 } |
| 619 #endif // defined(DEBUG_DEVTOOLS) | 633 #endif // defined(DEBUG_DEVTOOLS) |
| 620 | 634 |
| 621 class DevToolsJobFactory | 635 class DevToolsJobFactory |
| 622 : public net::URLRequestJobFactory::ProtocolHandler { | 636 : public net::URLRequestJobFactory::ProtocolHandler { |
| 623 public: | 637 public: |
| 638 // |is_incognito| should be set for incognito profiles. | |
| 624 DevToolsJobFactory(ChromeURLDataManagerBackend* backend, | 639 DevToolsJobFactory(ChromeURLDataManagerBackend* backend, |
| 625 net::NetworkDelegate* network_delegate); | 640 net::NetworkDelegate* network_delegate, |
| 641 bool is_incognito); | |
| 626 virtual ~DevToolsJobFactory(); | 642 virtual ~DevToolsJobFactory(); |
| 627 | 643 |
| 628 virtual net::URLRequestJob* MaybeCreateJob( | 644 virtual net::URLRequestJob* MaybeCreateJob( |
| 629 net::URLRequest* request, | 645 net::URLRequest* request, |
| 630 net::NetworkDelegate* network_delegate) const OVERRIDE; | 646 net::NetworkDelegate* network_delegate) const OVERRIDE; |
| 631 | 647 |
| 632 private: | 648 private: |
| 633 // |backend_| and |network_delegate_| are owned by ProfileIOData, which owns | 649 // |backend_| and |network_delegate_| are owned by ProfileIOData, which owns |
| 634 // this ProtocolHandler. | 650 // this ProtocolHandler. |
| 635 ChromeURLDataManagerBackend* const backend_; | 651 ChromeURLDataManagerBackend* const backend_; |
| 636 net::NetworkDelegate* network_delegate_; | 652 net::NetworkDelegate* network_delegate_; |
| 637 | 653 |
| 654 // True when generated from an incognito profile. | |
| 655 const bool is_incognito_; | |
| 656 | |
| 638 DISALLOW_COPY_AND_ASSIGN(DevToolsJobFactory); | 657 DISALLOW_COPY_AND_ASSIGN(DevToolsJobFactory); |
| 639 }; | 658 }; |
| 640 | 659 |
| 641 DevToolsJobFactory::DevToolsJobFactory(ChromeURLDataManagerBackend* backend, | 660 DevToolsJobFactory::DevToolsJobFactory(ChromeURLDataManagerBackend* backend, |
| 642 net::NetworkDelegate* network_delegate) | 661 net::NetworkDelegate* network_delegate, |
| 662 bool is_incognito) | |
| 643 : backend_(backend), | 663 : backend_(backend), |
| 644 network_delegate_(network_delegate) { | 664 network_delegate_(network_delegate), |
| 665 is_incognito_(is_incognito) { | |
| 645 DCHECK(backend_); | 666 DCHECK(backend_); |
| 646 } | 667 } |
| 647 | 668 |
| 648 DevToolsJobFactory::~DevToolsJobFactory() {} | 669 DevToolsJobFactory::~DevToolsJobFactory() {} |
| 649 | 670 |
| 650 net::URLRequestJob* | 671 net::URLRequestJob* |
| 651 DevToolsJobFactory::MaybeCreateJob( | 672 DevToolsJobFactory::MaybeCreateJob( |
| 652 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { | 673 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
| 653 #if defined(DEBUG_DEVTOOLS) | 674 #if defined(DEBUG_DEVTOOLS) |
| 654 FilePath path; | 675 FilePath path; |
| 655 if (IsSupportedDevToolsURL(request->url(), &path)) | 676 if (IsSupportedDevToolsURL(request->url(), &path)) |
| 656 return new net::URLRequestFileJob(request, network_delegate, path); | 677 return new net::URLRequestFileJob(request, network_delegate, path); |
| 657 #endif | 678 #endif |
| 658 return new URLRequestChromeJob(request, network_delegate, backend_); | 679 return new URLRequestChromeJob(request, network_delegate, backend_, |
| 680 is_incognito_); | |
| 659 } | 681 } |
| 660 | 682 |
| 661 } // namespace | 683 } // namespace |
| 662 | 684 |
| 663 net::URLRequestJobFactory::ProtocolHandler* | 685 net::URLRequestJobFactory::ProtocolHandler* |
| 664 CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend, | 686 CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend, |
| 665 net::NetworkDelegate* network_delegate) { | 687 net::NetworkDelegate* network_delegate, |
| 666 return new DevToolsJobFactory(backend, network_delegate); | 688 bool is_incognito) { |
| 689 return new DevToolsJobFactory(backend, network_delegate, is_incognito); | |
| 667 } | 690 } |
| OLD | NEW |