Create an initial chrome://supervised-user-internals page
[chromium-blink-merge.git] / chrome / renderer / chrome_content_renderer_client.h
blobcd1f3df60c2eca280c94e5d38d32a257430f294b
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 <map>
9 #include <set>
10 #include <string>
11 #include <vector>
13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string16.h"
16 #include "content/public/renderer/content_renderer_client.h"
17 #include "ipc/ipc_channel_proxy.h"
19 class ChromeExtensionsDispatcherDelegate;
20 class ChromeRenderProcessObserver;
21 #if defined(ENABLE_PRINT_PREVIEW)
22 class ChromePDFPrintClient;
23 #endif
24 class PrescientNetworkingDispatcher;
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 ExtensionsGuestViewContainerDispatcher;
46 class RendererPermissionsPolicyDelegate;
49 namespace prerender {
50 class PrerenderDispatcher;
53 namespace safe_browsing {
54 class PhishingClassifierFilter;
57 namespace visitedlink {
58 class VisitedLinkSlave;
61 namespace web_cache {
62 class WebCacheRenderProcessObserver;
65 namespace blink {
66 class WebSecurityOrigin;
69 namespace password_manager {
70 class CredentialManagerClient;
73 #if defined(ENABLE_WEBRTC)
74 class WebRtcLoggingMessageFilter;
75 #endif
77 class ChromeContentRendererClient : public content::ContentRendererClient {
78 public:
79 ChromeContentRendererClient();
80 ~ChromeContentRendererClient() override;
82 void RenderThreadStarted() override;
83 void RenderFrameCreated(content::RenderFrame* render_frame) override;
84 void RenderViewCreated(content::RenderView* render_view) 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::WebLocalFrame* 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 unsigned long long VisitedLinkHash(const char* canonical_url,
123 size_t length) override;
124 bool IsLinkVisited(unsigned long long link_hash) override;
125 blink::WebPrescientNetworking* GetPrescientNetworking() override;
126 bool ShouldOverridePageVisibilityState(
127 const content::RenderFrame* render_frame,
128 blink::WebPageVisibilityState* override_state) override;
129 const void* CreatePPAPIInterface(const std::string& interface_name) override;
130 bool IsExternalPepperPlugin(const std::string& module_name) override;
131 blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
132 blink::WebSpeechSynthesizerClient* client) override;
133 bool ShouldReportDetailedMessageForSource(
134 const base::string16& source) const override;
135 bool ShouldGatherSiteIsolationStats() const override;
136 blink::WebWorkerContentSettingsClientProxy*
137 CreateWorkerContentSettingsClientProxy(content::RenderFrame* render_frame,
138 blink::WebFrame* frame) override;
139 bool AllowPepperMediaStreamAPI(const GURL& url) override;
140 void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) override;
141 bool IsPluginAllowedToUseDevChannelAPIs() override;
142 bool IsPluginAllowedToUseCameraDeviceAPI(const GURL& url) override;
143 bool IsPluginAllowedToUseCompositorAPI(const GURL& url) override;
144 content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
145 content::RenderFrame* render_frame,
146 const std::string& mime_type,
147 const GURL& original_url) override;
148 void RecordRappor(const std::string& metric,
149 const std::string& sample) override;
150 void RecordRapporURL(const std::string& metric, const GURL& url) override;
151 scoped_ptr<blink::WebAppBannerClient> CreateAppBannerClient(
152 content::RenderFrame* render_frame) override;
153 void AddImageContextMenuProperties(
154 const blink::WebURLResponse& response,
155 std::map<std::string, std::string>* properties) override;
157 #if defined(ENABLE_EXTENSIONS)
158 // Takes ownership.
159 void SetExtensionDispatcherForTest(
160 extensions::Dispatcher* extension_dispatcher);
161 extensions::Dispatcher* GetExtensionDispatcherForTest();
162 #endif
164 #if defined(ENABLE_SPELLCHECK)
165 // Sets a new |spellcheck|. Used for testing only.
166 // Takes ownership of |spellcheck|.
167 void SetSpellcheck(SpellCheck* spellcheck);
168 #endif
170 #if defined(ENABLE_PLUGINS)
171 static blink::WebPlugin* CreatePlugin(
172 content::RenderFrame* render_frame,
173 blink::WebLocalFrame* frame,
174 const blink::WebPluginParams& params,
175 const ChromeViewHostMsg_GetPluginInfo_Output& output);
176 #endif
178 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
179 static bool IsExtensionOrSharedModuleWhitelisted(
180 const GURL& url, const std::set<std::string>& whitelist);
181 #endif
183 static bool WasWebRequestUsedBySomeExtensions();
185 private:
186 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction);
187 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest,
188 ShouldSuppressErrorPage);
190 #if defined(ENABLE_EXTENSIONS)
191 // Gets extension by the given origin, regardless of whether the extension
192 // is active in the current process.
193 const extensions::Extension* GetExtensionByOrigin(
194 const blink::WebSecurityOrigin& origin) const;
196 // Returns true if the frame is navigating to an URL either into or out of an
197 // extension app's extent.
198 bool CrossesExtensionExtents(blink::WebLocalFrame* frame,
199 const GURL& new_url,
200 const extensions::ExtensionSet& extensions,
201 bool is_extension_url,
202 bool is_initial_navigation);
203 #endif
205 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type,
206 const content::WebPluginInfo& plugin);
208 #if !defined(DISABLE_NACL)
209 // Determines if a NaCl app is allowed, and modifies params to pass the app's
210 // permissions to the trusted NaCl plugin.
211 static bool IsNaClAllowed(const GURL& manifest_url,
212 const GURL& app_url,
213 bool is_nacl_unrestricted,
214 const extensions::Extension* extension,
215 blink::WebPluginParams* params);
216 #endif
218 scoped_ptr<ChromeRenderProcessObserver> chrome_observer_;
219 scoped_ptr<web_cache::WebCacheRenderProcessObserver> web_cache_observer_;
221 // TODO(thestig): Extract into a separate file if possible. Cleanup
222 // ENABLE_EXTENSIONS ifdefs in the .cc file as well.
223 #if defined(ENABLE_EXTENSIONS)
224 scoped_ptr<ChromeExtensionsDispatcherDelegate> extension_dispatcher_delegate_;
225 scoped_ptr<extensions::Dispatcher> extension_dispatcher_;
226 scoped_ptr<extensions::RendererPermissionsPolicyDelegate>
227 permissions_policy_delegate_;
228 scoped_ptr<extensions::ExtensionsGuestViewContainerDispatcher>
229 guest_view_container_dispatcher_;
230 #endif
232 scoped_ptr<network_hints::PrescientNetworkingDispatcher>
233 prescient_networking_dispatcher_;
234 scoped_ptr<password_manager::CredentialManagerClient>
235 credential_manager_client_;
236 #if defined(ENABLE_SPELLCHECK)
237 scoped_ptr<SpellCheck> spellcheck_;
238 #endif
239 scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
240 scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
241 scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_;
242 #if defined(ENABLE_WEBRTC)
243 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
244 #endif
245 #if defined(ENABLE_PRINT_PREVIEW)
246 scoped_ptr<ChromePDFPrintClient> pdf_print_client_;
247 #endif
248 #if defined(ENABLE_PLUGINS)
249 std::set<std::string> allowed_camera_device_origins_;
250 std::set<std::string> allowed_compositor_origins_;
251 #endif
254 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_