Data Reduction Proxy Blocking page and resources
[chromium-blink-merge.git] / chrome / renderer / chrome_content_renderer_client.h
blob81e2d5550d2b27dc054612bcb3bc7455819c6d71
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_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_
6 #define CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/string16.h"
15 #include "content/public/renderer/content_renderer_client.h"
16 #include "ipc/ipc_channel_proxy.h"
18 class ChromeExtensionsDispatcherDelegate;
19 class ChromeRenderProcessObserver;
20 #if defined(ENABLE_PRINT_PREVIEW)
21 class ChromePDFPrintClient;
22 #endif
23 class PrescientNetworkingDispatcher;
24 class SearchBouncer;
25 #if defined(ENABLE_SPELLCHECK)
26 class SpellCheck;
27 class SpellCheckProvider;
28 #endif
30 struct ChromeViewHostMsg_GetPluginInfo_Output;
32 namespace content {
33 class BrowserPluginDelegate;
34 struct WebPluginInfo;
37 namespace network_hints {
38 class PrescientNetworkingDispatcher;
41 namespace extensions {
42 class Dispatcher;
43 class Extension;
44 class ExtensionSet;
45 class RendererPermissionsPolicyDelegate;
48 namespace prerender {
49 class PrerenderDispatcher;
52 namespace safe_browsing {
53 class PhishingClassifierFilter;
56 namespace visitedlink {
57 class VisitedLinkSlave;
60 namespace web_cache {
61 class WebCacheRenderProcessObserver;
64 namespace blink {
65 class WebSecurityOrigin;
68 namespace password_manager {
69 class CredentialManagerClient;
72 #if defined(ENABLE_WEBRTC)
73 class WebRtcLoggingMessageFilter;
74 #endif
76 class ChromeContentRendererClient : public content::ContentRendererClient {
77 public:
78 ChromeContentRendererClient();
79 ~ChromeContentRendererClient() override;
81 void RenderThreadStarted() override;
82 void RenderFrameCreated(content::RenderFrame* render_frame) override;
83 void RenderViewCreated(content::RenderView* render_view) override;
84 SkBitmap* GetSadPluginBitmap() override;
85 SkBitmap* GetSadWebViewBitmap() override;
86 bool OverrideCreatePlugin(content::RenderFrame* render_frame,
87 blink::WebLocalFrame* frame,
88 const blink::WebPluginParams& params,
89 blink::WebPlugin** plugin) override;
90 scoped_ptr<blink::WebPluginPlaceholder> CreatePluginPlaceholder(
91 content::RenderFrame* render_frame,
92 blink::WebLocalFrame* frame,
93 const blink::WebPluginParams& params) override;
94 blink::WebPlugin* CreatePluginReplacement(
95 content::RenderFrame* render_frame,
96 const base::FilePath& plugin_path) override;
97 bool HasErrorPage(int http_status_code, std::string* error_domain) override;
98 bool ShouldSuppressErrorPage(content::RenderFrame* render_frame,
99 const GURL& url) override;
100 void GetNavigationErrorStrings(content::RenderView* render_view,
101 blink::WebFrame* frame,
102 const blink::WebURLRequest& failed_request,
103 const blink::WebURLError& error,
104 std::string* error_html,
105 base::string16* error_description) override;
106 void DeferMediaLoad(content::RenderFrame* render_frame,
107 const base::Closure& closure) override;
108 bool RunIdleHandlerWhenWidgetsHidden() override;
109 bool AllowPopup() override;
110 bool ShouldFork(blink::WebFrame* frame,
111 const GURL& url,
112 const std::string& http_method,
113 bool is_initial_navigation,
114 bool is_server_redirect,
115 bool* send_referrer) override;
116 #if defined(ENABLE_EXTENSIONS)
117 bool ShouldForwardToGuestContainer(const IPC::Message& msg) override;
118 #endif
119 bool WillSendRequest(blink::WebFrame* frame,
120 ui::PageTransition transition_type,
121 const GURL& url,
122 const GURL& first_party_for_cookies,
123 GURL* new_url) override;
124 void DidCreateScriptContext(blink::WebFrame* frame,
125 v8::Handle<v8::Context> context,
126 int extension_group,
127 int world_id) override;
128 unsigned long long VisitedLinkHash(const char* canonical_url,
129 size_t length) override;
130 bool IsLinkVisited(unsigned long long link_hash) override;
131 blink::WebPrescientNetworking* GetPrescientNetworking() override;
132 bool ShouldOverridePageVisibilityState(
133 const content::RenderFrame* render_frame,
134 blink::WebPageVisibilityState* override_state) override;
135 const void* CreatePPAPIInterface(const std::string& interface_name) override;
136 bool IsExternalPepperPlugin(const std::string& module_name) override;
137 blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
138 blink::WebSpeechSynthesizerClient* client) override;
139 bool ShouldReportDetailedMessageForSource(
140 const base::string16& source) const override;
141 bool ShouldEnableSiteIsolationPolicy() const override;
142 blink::WebWorkerPermissionClientProxy* CreateWorkerPermissionClientProxy(
143 content::RenderFrame* render_frame,
144 blink::WebFrame* frame) override;
145 bool AllowPepperMediaStreamAPI(const GURL& url) override;
146 void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) override;
147 bool IsPluginAllowedToUseDevChannelAPIs() override;
148 bool IsPluginAllowedToUseCompositorAPI(const GURL& url) override;
149 content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
150 content::RenderFrame* render_frame,
151 const std::string& mime_type,
152 const GURL& original_url) override;
154 #if defined(ENABLE_EXTENSIONS)
155 // Takes ownership.
156 void SetExtensionDispatcherForTest(
157 extensions::Dispatcher* extension_dispatcher);
158 extensions::Dispatcher* GetExtensionDispatcherForTest();
159 #endif
161 #if defined(ENABLE_SPELLCHECK)
162 // Sets a new |spellcheck|. Used for testing only.
163 // Takes ownership of |spellcheck|.
164 void SetSpellcheck(SpellCheck* spellcheck);
165 #endif
167 static blink::WebPlugin* CreatePlugin(
168 content::RenderFrame* render_frame,
169 blink::WebLocalFrame* frame,
170 const blink::WebPluginParams& params,
171 const ChromeViewHostMsg_GetPluginInfo_Output& output);
173 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
174 static bool IsExtensionOrSharedModuleWhitelisted(
175 const GURL& url, const std::set<std::string>& whitelist);
176 #endif
178 static bool WasWebRequestUsedBySomeExtensions();
180 private:
181 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction);
182 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest,
183 ShouldSuppressErrorPage);
185 #if defined(ENABLE_EXTENSIONS)
186 // Gets extension by the given origin, regardless of whether the extension
187 // is active in the current process.
188 const extensions::Extension* GetExtensionByOrigin(
189 const blink::WebSecurityOrigin& origin) const;
191 // Returns true if the frame is navigating to an URL either into or out of an
192 // extension app's extent.
193 bool CrossesExtensionExtents(blink::WebFrame* frame,
194 const GURL& new_url,
195 const extensions::ExtensionSet& extensions,
196 bool is_extension_url,
197 bool is_initial_navigation);
198 #endif
200 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type,
201 const content::WebPluginInfo& plugin);
203 #if !defined(DISABLE_NACL)
204 // Determines if a NaCl app is allowed, and modifies params to pass the app's
205 // permissions to the trusted NaCl plugin.
206 static bool IsNaClAllowed(const GURL& manifest_url,
207 const GURL& app_url,
208 bool is_nacl_unrestricted,
209 const extensions::Extension* extension,
210 blink::WebPluginParams* params);
211 #endif
213 scoped_ptr<ChromeRenderProcessObserver> chrome_observer_;
214 scoped_ptr<web_cache::WebCacheRenderProcessObserver> web_cache_observer_;
216 // TODO(thestig): Extract into a separate file if possible. Cleanup
217 // ENABLE_EXTENSIONS ifdefs in the .cc file as well.
218 #if defined(ENABLE_EXTENSIONS)
219 scoped_ptr<ChromeExtensionsDispatcherDelegate> extension_dispatcher_delegate_;
220 scoped_ptr<extensions::Dispatcher> extension_dispatcher_;
221 scoped_ptr<extensions::RendererPermissionsPolicyDelegate>
222 permissions_policy_delegate_;
223 #endif
225 scoped_ptr<network_hints::PrescientNetworkingDispatcher>
226 prescient_networking_dispatcher_;
227 scoped_ptr<password_manager::CredentialManagerClient>
228 credential_manager_client_;
229 #if defined(ENABLE_SPELLCHECK)
230 scoped_ptr<SpellCheck> spellcheck_;
231 #endif
232 scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
233 scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
234 scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_;
235 #if defined(ENABLE_WEBRTC)
236 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
237 #endif
238 scoped_ptr<SearchBouncer> search_bouncer_;
239 #if defined(ENABLE_PRINT_PREVIEW)
240 scoped_ptr<ChromePDFPrintClient> pdf_print_client_;
241 #endif
242 #if defined(ENABLE_PLUGINS)
243 std::set<std::string> allowed_compositor_origins_;
244 std::set<std::string> allowed_video_decode_origins_;
245 #endif
248 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_