API migration: picture.draw -> picture.playback
[chromium-blink-merge.git] / android_webview / browser / net / aw_url_request_job_factory.cc
blob984458cd80285652a8267b70abe56d617d9b14aa
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
3 // found in the LICENSE file.
5 #include "android_webview/browser/net/aw_url_request_job_factory.h"
7 #include "net/base/net_errors.h"
8 #include "net/url_request/url_request_error_job.h"
9 #include "net/url_request/url_request_job_factory_impl.h"
10 #include "net/url_request/url_request_job_manager.h"
12 using net::NetworkDelegate;
13 using net::URLRequest;
14 using net::URLRequestJob;
16 namespace android_webview {
18 AwURLRequestJobFactory::AwURLRequestJobFactory()
19 : next_factory_(new net::URLRequestJobFactoryImpl()) {
22 AwURLRequestJobFactory::~AwURLRequestJobFactory() {
25 bool AwURLRequestJobFactory::IsHandledProtocol(
26 const std::string& scheme) const {
27 // This introduces a dependency on the URLRequestJobManager
28 // implementation. The assumption is that if true is returned from this
29 // method it is still valid to return NULL from the
30 // MaybeCreateJobWithProtocolHandler method and in that case the
31 // URLRequestJobManager will try and create the URLRequestJob by using the
32 // set of built in handlers.
33 return true;
36 bool AwURLRequestJobFactory::IsHandledURL(const GURL& url) const {
37 return true;
40 URLRequestJob* AwURLRequestJobFactory::MaybeCreateJobWithProtocolHandler(
41 const std::string& scheme,
42 URLRequest* request,
43 NetworkDelegate* network_delegate) const {
44 URLRequestJob* job = next_factory_->MaybeCreateJobWithProtocolHandler(
45 scheme, request, network_delegate);
47 if (job)
48 return job;
50 // If URLRequest supports the scheme NULL should be returned from this method.
51 // In that case the built in handlers will then be used to create the job.
52 // NOTE(joth): See the assumption in IsHandledProtocol above.
53 if (net::URLRequest::IsHandledProtocol(scheme))
54 return NULL;
56 return new net::URLRequestErrorJob(
57 request, network_delegate, net::ERR_UNKNOWN_URL_SCHEME);
60 net::URLRequestJob* AwURLRequestJobFactory::MaybeInterceptRedirect(
61 net::URLRequest* request,
62 net::NetworkDelegate* network_delegate,
63 const GURL& location) const {
64 return next_factory_->MaybeInterceptRedirect(
65 request, network_delegate, location);
68 net::URLRequestJob* AwURLRequestJobFactory::MaybeInterceptResponse(
69 net::URLRequest* request,
70 net::NetworkDelegate* network_delegate) const {
71 return next_factory_->MaybeInterceptResponse(request, network_delegate);
74 bool AwURLRequestJobFactory::SetProtocolHandler(
75 const std::string& scheme,
76 ProtocolHandler* protocol_handler) {
77 return next_factory_->SetProtocolHandler(scheme, protocol_handler);
80 bool AwURLRequestJobFactory::IsSafeRedirectTarget(const GURL& location) const {
81 return next_factory_->IsSafeRedirectTarget(location);
84 } // namespace android_webview