Index: chrome/browser/ui/webui/chrome_url_data_manager_backend.cc |
diff --git a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc |
index 9a0fcfdf53599e5b601df27b80eea6575c76cb33..48cc809a6f5027259e9e6e2e56ae6994f2177e9d 100644 |
--- a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc |
+++ b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc |
@@ -208,9 +208,11 @@ void URLToRequest(const GURL& url, std::string* source_name, |
class URLRequestChromeJob : public net::URLRequestJob, |
public base::SupportsWeakPtr<URLRequestChromeJob> { |
public: |
+ // |is_incognito| set when job is generated from an incognito profile. |
URLRequestChromeJob(net::URLRequest* request, |
net::NetworkDelegate* network_delegate, |
- ChromeURLDataManagerBackend* backend); |
+ ChromeURLDataManagerBackend* backend, |
+ bool is_incognito); |
// net::URLRequestJob implementation. |
virtual void Start() OVERRIDE; |
@@ -236,6 +238,11 @@ class URLRequestChromeJob : public net::URLRequestJob, |
allow_caching_ = allow_caching; |
} |
+ // Returns true when job was generated from an incognito profile. |
+ bool is_incognito() const { |
+ return is_incognito_; |
+ } |
+ |
private: |
virtual ~URLRequestChromeJob(); |
@@ -262,6 +269,9 @@ class URLRequestChromeJob : public net::URLRequestJob, |
// If true, set a header in the response to prevent it from being cached. |
bool allow_caching_; |
+ // True when job is generated from an incognito profile. |
+ const bool is_incognito_; |
+ |
// The backend is owned by ChromeURLRequestContext and always outlives us. |
ChromeURLDataManagerBackend* backend_; |
@@ -272,11 +282,13 @@ class URLRequestChromeJob : public net::URLRequestJob, |
URLRequestChromeJob::URLRequestChromeJob(net::URLRequest* request, |
net::NetworkDelegate* network_delegate, |
- ChromeURLDataManagerBackend* backend) |
+ ChromeURLDataManagerBackend* backend, |
+ bool is_incognito) |
: net::URLRequestJob(request, network_delegate), |
data_offset_(0), |
pending_buf_size_(0), |
allow_caching_(true), |
+ is_incognito_(is_incognito), |
backend_(backend), |
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
DCHECK(backend); |
@@ -407,7 +419,9 @@ namespace { |
class ChromeProtocolHandler |
: public net::URLRequestJobFactory::ProtocolHandler { |
public: |
- explicit ChromeProtocolHandler(ChromeURLDataManagerBackend* backend); |
+ // |is_incognito| should be set for incognito profiles. |
+ explicit ChromeProtocolHandler(ChromeURLDataManagerBackend* backend, |
+ bool is_incognito); |
~ChromeProtocolHandler(); |
virtual net::URLRequestJob* MaybeCreateJob( |
@@ -418,12 +432,15 @@ class ChromeProtocolHandler |
// These members are owned by ProfileIOData, which owns this ProtocolHandler. |
ChromeURLDataManagerBackend* const backend_; |
+ // True when generated from an incognito profile. |
+ const bool is_incognito_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ChromeProtocolHandler); |
}; |
ChromeProtocolHandler::ChromeProtocolHandler( |
- ChromeURLDataManagerBackend* backend) |
- : backend_(backend) {} |
+ ChromeURLDataManagerBackend* backend, bool is_incognito) |
+ : backend_(backend), is_incognito_(is_incognito) {} |
ChromeProtocolHandler::~ChromeProtocolHandler() {} |
@@ -432,7 +449,8 @@ net::URLRequestJob* ChromeProtocolHandler::MaybeCreateJob( |
DCHECK(request); |
// Fall back to using a custom handler |
- return new URLRequestChromeJob(request, network_delegate, backend_); |
+ return new URLRequestChromeJob(request, network_delegate, backend_, |
+ is_incognito_); |
} |
} // namespace |
@@ -457,9 +475,9 @@ ChromeURLDataManagerBackend::~ChromeURLDataManagerBackend() { |
// static |
net::URLRequestJobFactory::ProtocolHandler* |
ChromeURLDataManagerBackend::CreateProtocolHandler( |
- ChromeURLDataManagerBackend* backend) { |
+ ChromeURLDataManagerBackend* backend, bool is_incognito) { |
DCHECK(backend); |
- return new ChromeProtocolHandler(backend); |
+ return new ChromeProtocolHandler(backend, is_incognito); |
} |
void ChromeURLDataManagerBackend::AddDataSource( |
@@ -505,9 +523,6 @@ bool ChromeURLDataManagerBackend::StartRequest(const GURL& url, |
job->set_allow_caching(source->delegate()->AllowCaching()); |
- const ChromeURLRequestContext* context = |
- static_cast<const ChromeURLRequestContext*>(job->request()->context()); |
- |
// Forward along the request to the data source. |
MessageLoop* target_message_loop = |
source->delegate()->MessageLoopForRequestPath(path); |
@@ -517,8 +532,7 @@ bool ChromeURLDataManagerBackend::StartRequest(const GURL& url, |
// The DataSource is agnostic to which thread StartDataRequest is called |
// on for this path. Call directly into it from this thread, the IO |
// thread. |
- source->delegate()->StartDataRequest( |
- path, context->is_incognito(), request_id); |
+ source->delegate()->StartDataRequest(path, job->is_incognito(), request_id); |
} else { |
// URLRequestChromeJob should receive mime type before data. This |
// is guaranteed because request for mime type is placed in the |
@@ -535,7 +549,7 @@ bool ChromeURLDataManagerBackend::StartRequest(const GURL& url, |
target_message_loop->PostTask( |
FROM_HERE, |
base::Bind(&ChromeURLDataManagerBackend::CallStartRequest, |
- make_scoped_refptr(source), path, context->is_incognito(), |
+ make_scoped_refptr(source), path, job->is_incognito(), |
request_id)); |
} |
return true; |
@@ -621,8 +635,10 @@ bool IsSupportedDevToolsURL(const GURL& url, FilePath* path) { |
class DevToolsJobFactory |
: public net::URLRequestJobFactory::ProtocolHandler { |
public: |
+ // |is_incognito| should be set for incognito profiles. |
DevToolsJobFactory(ChromeURLDataManagerBackend* backend, |
- net::NetworkDelegate* network_delegate); |
+ net::NetworkDelegate* network_delegate, |
+ bool is_incognito); |
virtual ~DevToolsJobFactory(); |
virtual net::URLRequestJob* MaybeCreateJob( |
@@ -635,13 +651,18 @@ class DevToolsJobFactory |
ChromeURLDataManagerBackend* const backend_; |
net::NetworkDelegate* network_delegate_; |
+ // True when generated from an incognito profile. |
+ const bool is_incognito_; |
+ |
DISALLOW_COPY_AND_ASSIGN(DevToolsJobFactory); |
}; |
DevToolsJobFactory::DevToolsJobFactory(ChromeURLDataManagerBackend* backend, |
- net::NetworkDelegate* network_delegate) |
+ net::NetworkDelegate* network_delegate, |
+ bool is_incognito) |
: backend_(backend), |
- network_delegate_(network_delegate) { |
+ network_delegate_(network_delegate), |
+ is_incognito_(is_incognito) { |
DCHECK(backend_); |
} |
@@ -655,13 +676,15 @@ DevToolsJobFactory::MaybeCreateJob( |
if (IsSupportedDevToolsURL(request->url(), &path)) |
return new net::URLRequestFileJob(request, network_delegate, path); |
#endif |
- return new URLRequestChromeJob(request, network_delegate, backend_); |
+ return new URLRequestChromeJob(request, network_delegate, backend_, |
+ is_incognito_); |
} |
} // namespace |
net::URLRequestJobFactory::ProtocolHandler* |
CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend, |
- net::NetworkDelegate* network_delegate) { |
- return new DevToolsJobFactory(backend, network_delegate); |
+ net::NetworkDelegate* network_delegate, |
+ bool is_incognito) { |
+ return new DevToolsJobFactory(backend, network_delegate, is_incognito); |
} |