| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ | 5 #ifndef CONTENT_BROWSER_CONTENT_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ | 6 #define CONTENT_BROWSER_CONTENT_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 #include <memory> | |
| 10 #include <set> | |
| 11 | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "chrome/browser/external_protocol/external_protocol_handler.h" | |
| 16 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 8 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 17 | 9 |
| 18 class DelayedResourceQueue; | 10 namespace content { |
| 19 class DownloadRequestLimiter; | |
| 20 | 11 |
| 21 namespace extensions { | 12 // ResourceDispatcherHostDelegate that implements content-specific |
| 22 class UserScriptListener; | 13 // functionality before delegating again the the content client. Used to |
| 23 } | 14 // separate content/browser/loader from the rest of content. |
| 15 class ContentResourceDispatcherHostDelegate |
| 16 : public ResourceDispatcherHostDelegate { |
| 17 public: |
| 18 ContentResourceDispatcherHostDelegate(); |
| 19 ~ContentResourceDispatcherHostDelegate() override; |
| 24 | 20 |
| 25 namespace safe_browsing { | 21 void SetChild(ResourceDispatcherHostDelegate* child); |
| 26 class SafeBrowsingService; | |
| 27 } | |
| 28 | |
| 29 // Implements ResourceDispatcherHostDelegate. Currently used by the Prerender | |
| 30 // system to abort requests and add to the load flags when a request begins. | |
| 31 class ChromeResourceDispatcherHostDelegate | |
| 32 : public content::ResourceDispatcherHostDelegate { | |
| 33 public: | |
| 34 ChromeResourceDispatcherHostDelegate(); | |
| 35 ~ChromeResourceDispatcherHostDelegate() override; | |
| 36 | 22 |
| 37 // ResourceDispatcherHostDelegate implementation. | 23 // ResourceDispatcherHostDelegate implementation. |
| 38 bool ShouldBeginRequest(const std::string& method, | 24 bool ShouldBeginRequest(const std::string& method, |
| 39 const GURL& url, | 25 const GURL& url, |
| 40 content::ResourceType resource_type, | 26 content::ResourceType resource_type, |
| 41 content::ResourceContext* resource_context) override; | 27 content::ResourceContext* resource_context) override; |
| 42 void RequestBeginning( | 28 void RequestBeginning( |
| 43 net::URLRequest* request, | 29 net::URLRequest* request, |
| 44 content::ResourceContext* resource_context, | 30 content::ResourceContext* resource_context, |
| 45 content::AppCacheService* appcache_service, | 31 content::AppCacheService* appcache_service, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 IPC::Sender* sender) override; | 66 IPC::Sender* sender) override; |
| 81 void OnRequestRedirected(const GURL& redirect_url, | 67 void OnRequestRedirected(const GURL& redirect_url, |
| 82 net::URLRequest* request, | 68 net::URLRequest* request, |
| 83 content::ResourceContext* resource_context, | 69 content::ResourceContext* resource_context, |
| 84 content::ResourceResponse* response) override; | 70 content::ResourceResponse* response) override; |
| 85 void RequestComplete(net::URLRequest* url_request) override; | 71 void RequestComplete(net::URLRequest* url_request) override; |
| 86 bool ShouldEnableLoFiMode( | 72 bool ShouldEnableLoFiMode( |
| 87 const net::URLRequest& url_request, | 73 const net::URLRequest& url_request, |
| 88 content::ResourceContext* resource_context) override; | 74 content::ResourceContext* resource_context) override; |
| 89 | 75 |
| 90 // Called on the UI thread. Allows switching out the | |
| 91 // ExternalProtocolHandler::Delegate for testing code. | |
| 92 static void SetExternalProtocolHandlerDelegateForTesting( | |
| 93 ExternalProtocolHandler::Delegate* delegate); | |
| 94 | |
| 95 private: | 76 private: |
| 96 #if defined(ENABLE_EXTENSIONS) | 77 ResourceDispatcherHostDelegate* child_; // weak |
| 97 struct StreamTargetInfo { | |
| 98 std::string extension_id; | |
| 99 std::string view_id; | |
| 100 }; | |
| 101 #endif | |
| 102 | |
| 103 void AppendStandardResourceThrottles( | |
| 104 net::URLRequest* request, | |
| 105 content::ResourceContext* resource_context, | |
| 106 content::ResourceType resource_type, | |
| 107 ScopedVector<content::ResourceThrottle>* throttles); | |
| 108 | |
| 109 scoped_refptr<DownloadRequestLimiter> download_request_limiter_; | |
| 110 scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_; | |
| 111 #if defined(ENABLE_EXTENSIONS) | |
| 112 scoped_refptr<extensions::UserScriptListener> user_script_listener_; | |
| 113 std::map<net::URLRequest*, StreamTargetInfo> stream_target_info_; | |
| 114 #endif | |
| 115 | |
| 116 DISALLOW_COPY_AND_ASSIGN(ChromeResourceDispatcherHostDelegate); | |
| 117 }; | 78 }; |
| 118 | 79 |
| 119 #endif // CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE
_H_ | 80 } // namespace content |
| 81 |
| 82 #endif // CONTENT_BROWSER_CONTENT_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ |
| OLD | NEW |