blob: d4cc49e058217b1ef27cdc39fd28734d2bba7cde [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// Copyright (c) 2011 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.
4
5#ifndef NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_
6#define NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_
7
8#include <string>
9
10#include "base/basictypes.h"
11#include "base/compiler_specific.h"
12#include "base/threading/non_thread_safe.h"
13#include "net/base/net_export.h"
14
15class GURL;
16
17namespace net {
18
19class NetworkDelegate;
20class URLRequest;
21class URLRequestJob;
22
23class NET_EXPORT URLRequestJobFactory
24 : NON_EXPORTED_BASE(public base::NonThreadSafe) {
25 public:
26 // TODO(shalev): Move this to URLRequestJobFactoryImpl.
27 class NET_EXPORT ProtocolHandler {
28 public:
29 virtual ~ProtocolHandler();
30
31 virtual URLRequestJob* MaybeCreateJob(
32 URLRequest* request, NetworkDelegate* network_delegate) const = 0;
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +010033
34 // Indicates if it should be safe to redirect to |location|. Should handle
35 // protocols handled by MaybeCreateJob(). Only called when registered with
36 // URLRequestJobFactoryImpl::SetProtocolHandler() not called when used with
37 // ProtocolInterceptJobFactory.
38 // NOTE(pauljensen): Default implementation returns true.
39 virtual bool IsSafeRedirectTarget(const GURL& location) const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000040 };
41
Torne (Richard Coles)58218062012-11-14 11:43:16 +000042 URLRequestJobFactory();
43 virtual ~URLRequestJobFactory();
44
Torne (Richard Coles)58218062012-11-14 11:43:16 +000045 virtual URLRequestJob* MaybeCreateJobWithProtocolHandler(
46 const std::string& scheme,
47 URLRequest* request,
48 NetworkDelegate* network_delegate) const = 0;
49
Torne (Richard Coles)58218062012-11-14 11:43:16 +000050 virtual bool IsHandledProtocol(const std::string& scheme) const = 0;
51
52 virtual bool IsHandledURL(const GURL& url) const = 0;
53
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +010054 virtual bool IsSafeRedirectTarget(const GURL& location) const = 0;
55
Torne (Richard Coles)58218062012-11-14 11:43:16 +000056 private:
57 DISALLOW_COPY_AND_ASSIGN(URLRequestJobFactory);
58};
59
60} // namespace net
61
62#endif // NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_