Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / content / public / browser / resource_dispatcher_host_delegate.h
blob181962eee2d3f5ea5f5ce9313e7b87a065cff087
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 #ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
6 #define CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/common/content_export.h"
14 #include "content/public/common/resource_type.h"
15 #include "ui/base/page_transition_types.h"
17 class GURL;
18 template <class T> class ScopedVector;
20 namespace IPC {
21 class Sender;
24 namespace net {
25 class AuthChallengeInfo;
26 class URLRequest;
29 namespace content {
31 class AppCacheService;
32 class ResourceContext;
33 class ResourceDispatcherHostLoginDelegate;
34 class ResourceThrottle;
35 struct Referrer;
36 struct ResourceResponse;
37 struct StreamInfo;
39 // Interface that the embedder provides to ResourceDispatcherHost to allow
40 // observing and modifying requests.
41 class CONTENT_EXPORT ResourceDispatcherHostDelegate {
42 public:
43 // Called when a request begins. Return false to abort the request.
44 virtual bool ShouldBeginRequest(const std::string& method,
45 const GURL& url,
46 ResourceType resource_type,
47 ResourceContext* resource_context);
49 // Called after ShouldBeginRequest to allow the embedder to add resource
50 // throttles.
51 virtual void RequestBeginning(net::URLRequest* request,
52 ResourceContext* resource_context,
53 AppCacheService* appcache_service,
54 ResourceType resource_type,
55 ScopedVector<ResourceThrottle>* throttles);
57 // Allows an embedder to add additional resource handlers for a download.
58 // |must_download| is set if the request must be handled as a download.
59 virtual void DownloadStarting(net::URLRequest* request,
60 ResourceContext* resource_context,
61 int child_id,
62 int route_id,
63 int request_id,
64 bool is_content_initiated,
65 bool must_download,
66 ScopedVector<ResourceThrottle>* throttles);
68 // Creates a ResourceDispatcherHostLoginDelegate that asks the user for a
69 // username and password.
70 virtual ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
71 net::AuthChallengeInfo* auth_info,
72 net::URLRequest* request);
74 // Launches the url for the given tab. Returns true if an attempt to handle
75 // the url was made, e.g. by launching an app. Note that this does not
76 // guarantee that the app successfully handled it.
77 virtual bool HandleExternalProtocol(const GURL& url,
78 int child_id,
79 int route_id,
80 bool is_main_frame,
81 ui::PageTransition page_transition,
82 bool has_user_gesture);
84 // Returns true if we should force the given resource to be downloaded.
85 // Otherwise, the content layer decides.
86 virtual bool ShouldForceDownloadResource(const GURL& url,
87 const std::string& mime_type);
89 // Returns true and sets |origin| if a Stream should be created for the
90 // resource. |plugin_path| is the plugin which will be used to handle the
91 // request (if the stream will be rendered in a BrowserPlugin). It may be
92 // empty. If true is returned, a new Stream will be created and
93 // OnStreamCreated() will be called with a StreamHandle instance for the
94 // Stream. The handle contains the URL for reading the Stream etc. The
95 // Stream's origin will be set to |origin|.
97 // If the stream will be rendered in a BrowserPlugin, |payload| will contain
98 // the data that should be given to the old ResourceHandler to forward to the
99 // renderer process.
100 virtual bool ShouldInterceptResourceAsStream(
101 net::URLRequest* request,
102 const base::FilePath& plugin_path,
103 const std::string& mime_type,
104 GURL* origin,
105 std::string* payload);
107 // Informs the delegate that a Stream was created. The Stream can be read from
108 // the blob URL of the Stream, but can only be read once.
109 virtual void OnStreamCreated(net::URLRequest* request,
110 scoped_ptr<content::StreamInfo> stream);
112 // Informs the delegate that a response has started.
113 virtual void OnResponseStarted(net::URLRequest* request,
114 ResourceContext* resource_context,
115 ResourceResponse* response,
116 IPC::Sender* sender);
118 // Informs the delegate that a request has been redirected.
119 virtual void OnRequestRedirected(const GURL& redirect_url,
120 net::URLRequest* request,
121 ResourceContext* resource_context,
122 ResourceResponse* response);
124 // Notification that a request has completed.
125 virtual void RequestComplete(net::URLRequest* url_request);
127 protected:
128 ResourceDispatcherHostDelegate();
129 virtual ~ResourceDispatcherHostDelegate();
132 } // namespace content
134 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_