Update broken references to image assets
[chromium-blink-merge.git] / chrome / renderer / chrome_content_renderer_client.h
blob385fdbc7df4a33ed95bd215e12508d1bc96f334e
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"
18 #include "v8/include/v8.h"
20 class ChromeExtensionsDispatcherDelegate;
21 class ChromeRenderProcessObserver;
22 #if defined(ENABLE_PRINT_PREVIEW)
23 class ChromePDFPrintClient;
24 #endif
25 class PrescientNetworkingDispatcher;
26 #if defined(ENABLE_SPELLCHECK)
27 class SpellCheck;
28 class SpellCheckProvider;
29 #endif
31 struct ChromeViewHostMsg_GetPluginInfo_Output;
33 namespace content {
34 class BrowserPluginDelegate;
35 struct WebPluginInfo;
38 namespace network_hints {
39 class PrescientNetworkingDispatcher;
42 namespace extensions {
43 class Dispatcher;
44 class Extension;
45 class ExtensionSet;
46 class ExtensionsGuestViewContainerDispatcher;
47 class RendererPermissionsPolicyDelegate;
50 namespace prerender {
51 class PrerenderDispatcher;
54 namespace safe_browsing {
55 class PhishingClassifierFilter;
58 namespace visitedlink {
59 class VisitedLinkSlave;
62 namespace web_cache {
63 class WebCacheRenderProcessObserver;
66 namespace blink {
67 class WebSecurityOrigin;
70 namespace password_manager {
71 class CredentialManagerClient;
74 #if defined(ENABLE_WEBRTC)
75 class WebRtcLoggingMessageFilter;
76 #endif
78 class ChromeContentRendererClient : public content::ContentRendererClient {
79 public:
80 ChromeContentRendererClient();
81 ~ChromeContentRendererClient() override;
83 void RenderThreadStarted() override;
84 void RenderFrameCreated(content::RenderFrame* render_frame) override;
85 void RenderViewCreated(content::RenderView* render_view) override;
86 SkBitmap* GetSadPluginBitmap() override;
87 SkBitmap* GetSadWebViewBitmap() override;
88 bool OverrideCreatePlugin(content::RenderFrame* render_frame,
89 blink::WebLocalFrame* frame,
90 const blink::WebPluginParams& params,
91 blink::WebPlugin** plugin) override;
92 scoped_ptr<blink::WebPluginPlaceholder> CreatePluginPlaceholder(
93 content::RenderFrame* render_frame,
94 blink::WebLocalFrame* frame,
95 const blink::WebPluginParams& params) override;
96 blink::WebPlugin* CreatePluginReplacement(
97 content::RenderFrame* render_frame,
98 const base::FilePath& plugin_path) override;
99 bool HasErrorPage(int http_status_code, std::string* error_domain) override;
100 bool ShouldSuppressErrorPage(content::RenderFrame* render_frame,
101 const GURL& url) override;
102 void GetNavigationErrorStrings(content::RenderView* render_view,
103 blink::WebFrame* frame,
104 const blink::WebURLRequest& failed_request,
105 const blink::WebURLError& error,
106 std::string* error_html,
107 base::string16* error_description) override;
108 void DeferMediaLoad(content::RenderFrame* render_frame,
109 bool has_played_media_before,
110 const base::Closure& closure) override;
111 bool RunIdleHandlerWhenWidgetsHidden() override;
112 bool AllowPopup() override;
113 bool ShouldFork(blink::WebLocalFrame* frame,
114 const GURL& url,
115 const std::string& http_method,
116 bool is_initial_navigation,
117 bool is_server_redirect,
118 bool* send_referrer) override;
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 unsigned long long VisitedLinkHash(const char* canonical_url,
125 size_t length) override;
126 bool IsLinkVisited(unsigned long long link_hash) override;
127 blink::WebPrescientNetworking* GetPrescientNetworking() override;
128 bool ShouldOverridePageVisibilityState(
129 const content::RenderFrame* render_frame,
130 blink::WebPageVisibilityState* override_state) override;
131 const void* CreatePPAPIInterface(const std::string& interface_name) override;
132 bool IsExternalPepperPlugin(const std::string& module_name) override;
133 blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
134 blink::WebSpeechSynthesizerClient* client) override;
135 bool ShouldReportDetailedMessageForSource(
136 const base::string16& source) const override;
137 bool ShouldGatherSiteIsolationStats() const override;
138 blink::WebWorkerContentSettingsClientProxy*
139 CreateWorkerContentSettingsClientProxy(content::RenderFrame* render_frame,
140 blink::WebFrame* frame) override;
141 bool AllowPepperMediaStreamAPI(const GURL& url) override;
142 void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) override;
143 bool IsPluginAllowedToUseDevChannelAPIs() override;
144 bool IsPluginAllowedToUseCameraDeviceAPI(const GURL& url) override;
145 bool IsPluginAllowedToUseCompositorAPI(const GURL& url) override;
146 content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
147 content::RenderFrame* render_frame,
148 const std::string& mime_type,
149 const GURL& original_url) override;
150 void RecordRappor(const std::string& metric,
151 const std::string& sample) override;
152 void RecordRapporURL(const std::string& metric, const GURL& url) override;
153 scoped_ptr<blink::WebAppBannerClient> CreateAppBannerClient(
154 content::RenderFrame* render_frame) override;
155 void AddImageContextMenuProperties(
156 const blink::WebURLResponse& response,
157 std::map<std::string, std::string>* properties) override;
158 void DidInitializeServiceWorkerContextOnWorkerThread(
159 v8::Local<v8::Context> context,
160 const GURL& url) override;
161 #if defined(ENABLE_EXTENSIONS)
162 // Takes ownership.
163 void SetExtensionDispatcherForTest(
164 extensions::Dispatcher* extension_dispatcher);
165 extensions::Dispatcher* GetExtensionDispatcherForTest();
166 #endif
168 #if defined(ENABLE_SPELLCHECK)
169 // Sets a new |spellcheck|. Used for testing only.
170 // Takes ownership of |spellcheck|.
171 void SetSpellcheck(SpellCheck* spellcheck);
172 #endif
174 #if defined(ENABLE_PLUGINS)
175 static blink::WebPlugin* CreatePlugin(
176 content::RenderFrame* render_frame,
177 blink::WebLocalFrame* frame,
178 const blink::WebPluginParams& params,
179 const ChromeViewHostMsg_GetPluginInfo_Output& output);
180 #endif
182 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
183 static bool IsExtensionOrSharedModuleWhitelisted(
184 const GURL& url, const std::set<std::string>& whitelist);
185 #endif
187 static bool WasWebRequestUsedBySomeExtensions();
189 private:
190 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction);
191 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest,
192 ShouldSuppressErrorPage);
194 #if defined(ENABLE_EXTENSIONS)
195 // Gets extension by the given origin, regardless of whether the extension
196 // is active in the current process.
197 const extensions::Extension* GetExtensionByOrigin(
198 const blink::WebSecurityOrigin& origin) const;
200 // Returns true if the frame is navigating to an URL either into or out of an
201 // extension app's extent.
202 bool CrossesExtensionExtents(blink::WebLocalFrame* frame,
203 const GURL& new_url,
204 bool is_extension_url,
205 bool is_initial_navigation);
206 #endif
208 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type,
209 const content::WebPluginInfo& plugin);
211 #if !defined(DISABLE_NACL)
212 // Determines if a NaCl app is allowed, and modifies params to pass the app's
213 // permissions to the trusted NaCl plugin.
214 static bool IsNaClAllowed(const GURL& manifest_url,
215 const GURL& app_url,
216 bool is_nacl_unrestricted,
217 const extensions::Extension* extension,
218 blink::WebPluginParams* params);
219 #endif
221 scoped_ptr<ChromeRenderProcessObserver> chrome_observer_;
222 scoped_ptr<web_cache::WebCacheRenderProcessObserver> web_cache_observer_;
224 // TODO(thestig): Extract into a separate file if possible. Cleanup
225 // ENABLE_EXTENSIONS ifdefs in the .cc file as well.
226 #if defined(ENABLE_EXTENSIONS)
227 scoped_ptr<ChromeExtensionsDispatcherDelegate> extension_dispatcher_delegate_;
228 scoped_ptr<extensions::Dispatcher> extension_dispatcher_;
229 scoped_ptr<extensions::RendererPermissionsPolicyDelegate>
230 permissions_policy_delegate_;
231 scoped_ptr<extensions::ExtensionsGuestViewContainerDispatcher>
232 guest_view_container_dispatcher_;
233 #endif
235 scoped_ptr<network_hints::PrescientNetworkingDispatcher>
236 prescient_networking_dispatcher_;
237 scoped_ptr<password_manager::CredentialManagerClient>
238 credential_manager_client_;
239 #if defined(ENABLE_SPELLCHECK)
240 scoped_ptr<SpellCheck> spellcheck_;
241 #endif
242 scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
243 scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
244 scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_;
245 #if defined(ENABLE_WEBRTC)
246 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
247 #endif
248 #if defined(ENABLE_PRINT_PREVIEW)
249 scoped_ptr<ChromePDFPrintClient> pdf_print_client_;
250 #endif
251 #if defined(ENABLE_PLUGINS)
252 std::set<std::string> allowed_camera_device_origins_;
253 std::set<std::string> allowed_compositor_origins_;
254 #endif
257 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_