Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / chrome / renderer / chrome_content_renderer_client.h
blob7a476c1acc62ae84a27767dd0127c5449e1a63c5
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 dns_prefetch {
38 class RendererNetPredictor;
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 void SetNumberOfViews(int number_of_views) override;
85 SkBitmap* GetSadPluginBitmap() override;
86 SkBitmap* GetSadWebViewBitmap() override;
87 bool OverrideCreatePlugin(content::RenderFrame* render_frame,
88 blink::WebLocalFrame* frame,
89 const blink::WebPluginParams& params,
90 blink::WebPlugin** plugin) override;
91 scoped_ptr<blink::WebPluginPlaceholder> CreatePluginPlaceholder(
92 content::RenderFrame* render_frame,
93 blink::WebLocalFrame* frame,
94 const blink::WebPluginParams& params) override;
95 blink::WebPlugin* CreatePluginReplacement(
96 content::RenderFrame* render_frame,
97 const base::FilePath& plugin_path) override;
98 bool HasErrorPage(int http_status_code, std::string* error_domain) override;
99 bool ShouldSuppressErrorPage(content::RenderFrame* render_frame,
100 const GURL& url) override;
101 void GetNavigationErrorStrings(content::RenderView* render_view,
102 blink::WebFrame* frame,
103 const blink::WebURLRequest& failed_request,
104 const blink::WebURLError& error,
105 std::string* error_html,
106 base::string16* error_description) override;
107 void DeferMediaLoad(content::RenderFrame* render_frame,
108 const base::Closure& closure) override;
109 bool RunIdleHandlerWhenWidgetsHidden() override;
110 bool AllowPopup() override;
111 bool ShouldFork(blink::WebFrame* frame,
112 const GURL& url,
113 const std::string& http_method,
114 bool is_initial_navigation,
115 bool is_server_redirect,
116 bool* send_referrer) override;
117 bool WillSendRequest(blink::WebFrame* frame,
118 ui::PageTransition transition_type,
119 const GURL& url,
120 const GURL& first_party_for_cookies,
121 GURL* new_url) override;
122 void DidCreateScriptContext(blink::WebFrame* frame,
123 v8::Handle<v8::Context> context,
124 int extension_group,
125 int world_id) override;
126 unsigned long long VisitedLinkHash(const char* canonical_url,
127 size_t length) override;
128 bool IsLinkVisited(unsigned long long link_hash) override;
129 blink::WebPrescientNetworking* GetPrescientNetworking() override;
130 bool ShouldOverridePageVisibilityState(
131 const content::RenderFrame* render_frame,
132 blink::WebPageVisibilityState* override_state) override;
133 const void* CreatePPAPIInterface(const std::string& interface_name) override;
134 bool IsExternalPepperPlugin(const std::string& module_name) override;
135 blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
136 blink::WebSpeechSynthesizerClient* client) override;
137 bool ShouldReportDetailedMessageForSource(
138 const base::string16& source) const override;
139 bool ShouldEnableSiteIsolationPolicy() const override;
140 blink::WebWorkerPermissionClientProxy* CreateWorkerPermissionClientProxy(
141 content::RenderFrame* render_frame,
142 blink::WebFrame* frame) override;
143 bool AllowPepperMediaStreamAPI(const GURL& url) override;
144 void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) override;
145 bool IsPluginAllowedToUseDevChannelAPIs() override;
146 bool IsPluginAllowedToUseCompositorAPI(const GURL& url) override;
147 bool IsPluginAllowedToUseVideoDecodeAPI(const GURL& url) override;
148 content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
149 content::RenderFrame* render_frame,
150 const std::string& mime_type,
151 const GURL& original_url) override;
153 #if defined(ENABLE_EXTENSIONS)
154 // Takes ownership.
155 void SetExtensionDispatcherForTest(
156 extensions::Dispatcher* extension_dispatcher);
157 extensions::Dispatcher* GetExtensionDispatcherForTest();
158 #endif
160 #if defined(ENABLE_SPELLCHECK)
161 // Sets a new |spellcheck|. Used for testing only.
162 // Takes ownership of |spellcheck|.
163 void SetSpellcheck(SpellCheck* spellcheck);
164 #endif
166 static blink::WebPlugin* CreatePlugin(
167 content::RenderFrame* render_frame,
168 blink::WebLocalFrame* frame,
169 const blink::WebPluginParams& params,
170 const ChromeViewHostMsg_GetPluginInfo_Output& output);
172 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
173 static bool IsExtensionOrSharedModuleWhitelisted(
174 const GURL& url, const std::set<std::string>& whitelist);
175 #endif
177 static bool WasWebRequestUsedBySomeExtensions();
179 private:
180 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction);
181 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest,
182 ShouldSuppressErrorPage);
184 #if defined(ENABLE_EXTENSIONS)
185 // Gets extension by the given origin, regardless of whether the extension
186 // is active in the current process.
187 const extensions::Extension* GetExtensionByOrigin(
188 const blink::WebSecurityOrigin& origin) const;
190 // Returns true if the frame is navigating to an URL either into or out of an
191 // extension app's extent.
192 bool CrossesExtensionExtents(blink::WebFrame* frame,
193 const GURL& new_url,
194 const extensions::ExtensionSet& extensions,
195 bool is_extension_url,
196 bool is_initial_navigation);
197 #endif
199 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type,
200 const content::WebPluginInfo& plugin);
202 #if !defined(DISABLE_NACL)
203 // Determines if a NaCl app is allowed, and modifies params to pass the app's
204 // permissions to the trusted NaCl plugin.
205 static bool IsNaClAllowed(const GURL& manifest_url,
206 const GURL& app_url,
207 bool is_nacl_unrestricted,
208 const extensions::Extension* extension,
209 blink::WebPluginParams* params);
210 #endif
212 scoped_ptr<ChromeRenderProcessObserver> chrome_observer_;
213 scoped_ptr<web_cache::WebCacheRenderProcessObserver> web_cache_observer_;
215 // TODO(thestig): Extract into a separate file if possible. Cleanup
216 // ENABLE_EXTENSIONS ifdefs in the .cc file as well.
217 #if defined(ENABLE_EXTENSIONS)
218 scoped_ptr<ChromeExtensionsDispatcherDelegate> extension_dispatcher_delegate_;
219 scoped_ptr<extensions::Dispatcher> extension_dispatcher_;
220 scoped_ptr<extensions::RendererPermissionsPolicyDelegate>
221 permissions_policy_delegate_;
222 #endif
224 scoped_ptr<PrescientNetworkingDispatcher> prescient_networking_dispatcher_;
225 scoped_ptr<dns_prefetch::RendererNetPredictor> net_predictor_;
226 scoped_ptr<password_manager::CredentialManagerClient>
227 credential_manager_client_;
228 #if defined(ENABLE_SPELLCHECK)
229 scoped_ptr<SpellCheck> spellcheck_;
230 #endif
231 scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
232 scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
233 scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_;
234 #if defined(ENABLE_WEBRTC)
235 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
236 #endif
237 scoped_ptr<SearchBouncer> search_bouncer_;
238 #if defined(ENABLE_PRINT_PREVIEW)
239 scoped_ptr<ChromePDFPrintClient> pdf_print_client_;
240 #endif
241 #if defined(ENABLE_PLUGINS)
242 std::set<std::string> allowed_compositor_origins_;
243 std::set<std::string> allowed_video_decode_origins_;
244 #endif
247 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_