Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / renderer_host / chrome_resource_dispatcher_host_delegate.h
blobb154b5b0f6e99bfb5e1bf8ffb4e9df0b1a34d7f2
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 <set>
10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h"
12 #include "chrome/browser/external_protocol/external_protocol_handler.h"
13 #include "content/public/browser/resource_dispatcher_host_delegate.h"
15 class DelayedResourceQueue;
16 class DownloadRequestLimiter;
17 class SafeBrowsingService;
19 namespace extensions {
20 class UserScriptListener;
23 namespace prerender {
24 class PrerenderTracker;
27 // Implements ResourceDispatcherHostDelegate. Currently used by the Prerender
28 // system to abort requests and add to the load flags when a request begins.
29 class ChromeResourceDispatcherHostDelegate
30 : public content::ResourceDispatcherHostDelegate {
31 public:
32 // This class does not take ownership of the tracker but merely holds a
33 // reference to it to avoid accessing g_browser_process.
34 // |prerender_tracker| must outlive |this|.
35 explicit ChromeResourceDispatcherHostDelegate(
36 prerender::PrerenderTracker* prerender_tracker);
37 virtual ~ChromeResourceDispatcherHostDelegate();
39 // ResourceDispatcherHostDelegate implementation.
40 virtual bool ShouldBeginRequest(
41 int child_id,
42 int route_id,
43 const std::string& method,
44 const GURL& url,
45 ResourceType::Type resource_type,
46 content::ResourceContext* resource_context) OVERRIDE;
47 virtual void RequestBeginning(
48 net::URLRequest* request,
49 content::ResourceContext* resource_context,
50 appcache::AppCacheService* appcache_service,
51 ResourceType::Type resource_type,
52 int child_id,
53 int route_id,
54 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
55 virtual void DownloadStarting(
56 net::URLRequest* request,
57 content::ResourceContext* resource_context,
58 int child_id,
59 int route_id,
60 int request_id,
61 bool is_content_initiated,
62 bool must_download,
63 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
64 virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
65 net::AuthChallengeInfo* auth_info, net::URLRequest* request) OVERRIDE;
66 virtual bool HandleExternalProtocol(const GURL& url,
67 int child_id,
68 int route_id,
69 bool initiated_by_user_gesture) OVERRIDE;
70 virtual bool ShouldForceDownloadResource(
71 const GURL& url, const std::string& mime_type) OVERRIDE;
72 virtual bool ShouldInterceptResourceAsStream(
73 content::ResourceContext* resource_context,
74 const GURL& url,
75 const std::string& mime_type,
76 GURL* origin,
77 std::string* target_id) OVERRIDE;
78 virtual void OnStreamCreated(
79 content::ResourceContext* resource_context,
80 int render_process_id,
81 int render_view_id,
82 const std::string& target_id,
83 scoped_ptr<content::StreamHandle> stream,
84 int64 expected_content_size) OVERRIDE;
85 virtual void OnResponseStarted(
86 net::URLRequest* request,
87 content::ResourceContext* resource_context,
88 content::ResourceResponse* response,
89 IPC::Sender* sender) OVERRIDE;
90 virtual void OnRequestRedirected(
91 const GURL& redirect_url,
92 net::URLRequest* request,
93 content::ResourceContext* resource_context,
94 content::ResourceResponse* response) OVERRIDE;
95 virtual void RequestComplete(net::URLRequest* url_request) OVERRIDE;
97 // Called on the UI thread. Allows switching out the
98 // ExternalProtocolHandler::Delegate for testing code.
99 static void SetExternalProtocolHandlerDelegateForTesting(
100 ExternalProtocolHandler::Delegate* delegate);
102 private:
103 void AppendStandardResourceThrottles(
104 net::URLRequest* request,
105 content::ResourceContext* resource_context,
106 ResourceType::Type resource_type,
107 ScopedVector<content::ResourceThrottle>* throttles);
109 #if defined(ENABLE_ONE_CLICK_SIGNIN)
110 // Append headers required to tell Gaia whether the sync interstitial
111 // should be shown or not. This header is only added for valid Gaia URLs.
112 void AppendChromeSyncGaiaHeader(
113 net::URLRequest* request,
114 content::ResourceContext* resource_context);
115 #endif
117 scoped_refptr<DownloadRequestLimiter> download_request_limiter_;
118 scoped_refptr<SafeBrowsingService> safe_browsing_;
119 scoped_refptr<extensions::UserScriptListener> user_script_listener_;
120 prerender::PrerenderTracker* prerender_tracker_;
122 DISALLOW_COPY_AND_ASSIGN(ChromeResourceDispatcherHostDelegate);
125 #endif // CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_