Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / renderer_host / chrome_resource_dispatcher_host_delegate.h
blobffbab62156f21869933b249cc54c71cbd93ca841
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 CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
6 #define CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
8 #include <map>
9 #include <set>
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "chrome/browser/external_protocol/external_protocol_handler.h"
14 #include "content/public/browser/resource_dispatcher_host_delegate.h"
16 class DelayedResourceQueue;
17 class DownloadRequestLimiter;
18 class SafeBrowsingService;
20 namespace extensions {
21 class UserScriptListener;
24 // Implements ResourceDispatcherHostDelegate. Currently used by the Prerender
25 // system to abort requests and add to the load flags when a request begins.
26 class ChromeResourceDispatcherHostDelegate
27 : public content::ResourceDispatcherHostDelegate {
28 public:
29 ChromeResourceDispatcherHostDelegate();
30 ~ChromeResourceDispatcherHostDelegate() override;
32 // ResourceDispatcherHostDelegate implementation.
33 bool ShouldBeginRequest(const std::string& method,
34 const GURL& url,
35 content::ResourceType resource_type,
36 content::ResourceContext* resource_context) override;
37 void RequestBeginning(
38 net::URLRequest* request,
39 content::ResourceContext* resource_context,
40 content::AppCacheService* appcache_service,
41 content::ResourceType resource_type,
42 ScopedVector<content::ResourceThrottle>* throttles) override;
43 void DownloadStarting(
44 net::URLRequest* request,
45 content::ResourceContext* resource_context,
46 int child_id,
47 int route_id,
48 int request_id,
49 bool is_content_initiated,
50 bool must_download,
51 ScopedVector<content::ResourceThrottle>* throttles) override;
52 content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
53 net::AuthChallengeInfo* auth_info,
54 net::URLRequest* request) override;
55 bool HandleExternalProtocol(const GURL& url,
56 int child_id,
57 int route_id) override;
58 bool ShouldForceDownloadResource(const GURL& url,
59 const std::string& mime_type) override;
60 bool ShouldInterceptResourceAsStream(net::URLRequest* request,
61 const std::string& mime_type,
62 GURL* origin,
63 std::string* payload) override;
64 void OnStreamCreated(net::URLRequest* request,
65 scoped_ptr<content::StreamInfo> stream) override;
66 void OnResponseStarted(net::URLRequest* request,
67 content::ResourceContext* resource_context,
68 content::ResourceResponse* response,
69 IPC::Sender* sender) override;
70 void OnRequestRedirected(const GURL& redirect_url,
71 net::URLRequest* request,
72 content::ResourceContext* resource_context,
73 content::ResourceResponse* response) override;
74 void RequestComplete(net::URLRequest* url_request) override;
76 // Called on the UI thread. Allows switching out the
77 // ExternalProtocolHandler::Delegate for testing code.
78 static void SetExternalProtocolHandlerDelegateForTesting(
79 ExternalProtocolHandler::Delegate* delegate);
81 private:
82 #if defined(ENABLE_EXTENSIONS)
83 struct StreamTargetInfo {
84 std::string extension_id;
85 std::string view_id;
87 #endif
89 void AppendStandardResourceThrottles(
90 net::URLRequest* request,
91 content::ResourceContext* resource_context,
92 content::ResourceType resource_type,
93 ScopedVector<content::ResourceThrottle>* throttles);
95 scoped_refptr<DownloadRequestLimiter> download_request_limiter_;
96 scoped_refptr<SafeBrowsingService> safe_browsing_;
97 #if defined(ENABLE_EXTENSIONS)
98 scoped_refptr<extensions::UserScriptListener> user_script_listener_;
99 std::map<net::URLRequest*, StreamTargetInfo> stream_target_info_;
100 #endif
102 DISALLOW_COPY_AND_ASSIGN(ChromeResourceDispatcherHostDelegate);
105 #endif // CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_