ExtensionSyncService cleanup: process uninstalls in one step
[chromium-blink-merge.git] / chrome / browser / renderer_host / chrome_resource_dispatcher_host_delegate.h
blobb0d6f34a03766458b44c5600e588b2c255a70cce
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,
58 bool is_main_frame,
59 ui::PageTransition page_transition,
60 bool has_user_gesture) override;
61 bool ShouldForceDownloadResource(const GURL& url,
62 const std::string& mime_type) override;
63 bool ShouldInterceptResourceAsStream(net::URLRequest* request,
64 const std::string& mime_type,
65 GURL* origin,
66 std::string* payload) override;
67 void OnStreamCreated(net::URLRequest* request,
68 scoped_ptr<content::StreamInfo> stream) override;
69 void OnResponseStarted(net::URLRequest* request,
70 content::ResourceContext* resource_context,
71 content::ResourceResponse* response,
72 IPC::Sender* sender) override;
73 void OnRequestRedirected(const GURL& redirect_url,
74 net::URLRequest* request,
75 content::ResourceContext* resource_context,
76 content::ResourceResponse* response) override;
77 void RequestComplete(net::URLRequest* url_request) override;
79 // Called on the UI thread. Allows switching out the
80 // ExternalProtocolHandler::Delegate for testing code.
81 static void SetExternalProtocolHandlerDelegateForTesting(
82 ExternalProtocolHandler::Delegate* delegate);
84 private:
85 #if defined(ENABLE_EXTENSIONS)
86 struct StreamTargetInfo {
87 std::string extension_id;
88 std::string view_id;
90 #endif
92 void AppendStandardResourceThrottles(
93 net::URLRequest* request,
94 content::ResourceContext* resource_context,
95 content::ResourceType resource_type,
96 ScopedVector<content::ResourceThrottle>* throttles);
98 scoped_refptr<DownloadRequestLimiter> download_request_limiter_;
99 scoped_refptr<SafeBrowsingService> safe_browsing_;
100 #if defined(ENABLE_EXTENSIONS)
101 scoped_refptr<extensions::UserScriptListener> user_script_listener_;
102 std::map<net::URLRequest*, StreamTargetInfo> stream_target_info_;
103 #endif
105 DISALLOW_COPY_AND_ASSIGN(ChromeResourceDispatcherHostDelegate);
108 #endif // CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_