WebView: set version number in JNI initialization
[chromium-blink-merge.git] / chrome / renderer / chrome_content_renderer_client.h
blob428c567d921ee9c5c0ab6090d3e9e91145fb791a
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;
48 class ResourceRequestPolicy;
51 namespace prerender {
52 class PrerenderDispatcher;
55 namespace safe_browsing {
56 class PhishingClassifierFilter;
59 namespace visitedlink {
60 class VisitedLinkSlave;
63 namespace web_cache {
64 class WebCacheRenderProcessObserver;
67 namespace blink {
68 class WebSecurityOrigin;
71 namespace password_manager {
72 class CredentialManagerClient;
75 #if defined(ENABLE_WEBRTC)
76 class WebRtcLoggingMessageFilter;
77 #endif
79 class ChromeContentRendererClient : public content::ContentRendererClient {
80 public:
81 ChromeContentRendererClient();
82 ~ChromeContentRendererClient() override;
84 void RenderThreadStarted() override;
85 void RenderFrameCreated(content::RenderFrame* render_frame) override;
86 void RenderViewCreated(content::RenderView* render_view) override;
87 SkBitmap* GetSadPluginBitmap() override;
88 SkBitmap* GetSadWebViewBitmap() override;
89 bool OverrideCreatePlugin(content::RenderFrame* render_frame,
90 blink::WebLocalFrame* frame,
91 const blink::WebPluginParams& params,
92 blink::WebPlugin** plugin) override;
93 blink::WebPlugin* CreatePluginReplacement(
94 content::RenderFrame* render_frame,
95 const base::FilePath& plugin_path) override;
96 bool HasErrorPage(int http_status_code, std::string* error_domain) override;
97 bool ShouldSuppressErrorPage(content::RenderFrame* render_frame,
98 const GURL& url) override;
99 void GetNavigationErrorStrings(content::RenderView* render_view,
100 blink::WebFrame* frame,
101 const blink::WebURLRequest& failed_request,
102 const blink::WebURLError& error,
103 std::string* error_html,
104 base::string16* error_description) override;
105 void DeferMediaLoad(content::RenderFrame* render_frame,
106 bool has_played_media_before,
107 const base::Closure& closure) override;
108 bool RunIdleHandlerWhenWidgetsHidden() override;
109 bool AllowTimerSuspensionWhenProcessBackgrounded() 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;
156 void DidInitializeServiceWorkerContextOnWorkerThread(
157 v8::Local<v8::Context> context,
158 const GURL& url) override;
159 void WillDestroyServiceWorkerContextOnWorkerThread(
160 v8::Local<v8::Context> context,
161 const GURL& url) override;
162 #if defined(ENABLE_EXTENSIONS)
163 // Takes ownership.
164 void SetExtensionDispatcherForTest(
165 extensions::Dispatcher* extension_dispatcher);
166 extensions::Dispatcher* GetExtensionDispatcherForTest();
167 #endif
169 #if defined(ENABLE_SPELLCHECK)
170 // Sets a new |spellcheck|. Used for testing only.
171 // Takes ownership of |spellcheck|.
172 void SetSpellcheck(SpellCheck* spellcheck);
173 #endif
175 #if defined(ENABLE_PLUGINS)
176 static blink::WebPlugin* CreatePlugin(
177 content::RenderFrame* render_frame,
178 blink::WebLocalFrame* frame,
179 const blink::WebPluginParams& params,
180 const ChromeViewHostMsg_GetPluginInfo_Output& output);
181 #endif
183 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
184 static bool IsExtensionOrSharedModuleWhitelisted(
185 const GURL& url, const std::set<std::string>& whitelist);
186 #endif
188 static bool WasWebRequestUsedBySomeExtensions();
190 private:
191 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction);
192 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest,
193 ShouldSuppressErrorPage);
195 #if defined(ENABLE_EXTENSIONS)
196 // Gets extension by the given origin, regardless of whether the extension
197 // is active in the current process.
198 const extensions::Extension* GetExtensionByOrigin(
199 const blink::WebSecurityOrigin& origin) const;
201 // Returns true if the frame is navigating to an URL either into or out of an
202 // extension app's extent.
203 bool CrossesExtensionExtents(blink::WebLocalFrame* frame,
204 const GURL& new_url,
205 bool is_extension_url,
206 bool is_initial_navigation);
207 #endif
209 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type,
210 const content::WebPluginInfo& plugin);
212 #if !defined(DISABLE_NACL)
213 // Determines if a NaCl app is allowed, and modifies params to pass the app's
214 // permissions to the trusted NaCl plugin.
215 static bool IsNaClAllowed(const GURL& manifest_url,
216 const GURL& app_url,
217 bool is_nacl_unrestricted,
218 const extensions::Extension* extension,
219 blink::WebPluginParams* params);
220 #endif
222 scoped_ptr<ChromeRenderProcessObserver> chrome_observer_;
223 scoped_ptr<web_cache::WebCacheRenderProcessObserver> web_cache_observer_;
225 // TODO(thestig): Extract into a separate file if possible. Cleanup
226 // ENABLE_EXTENSIONS ifdefs in the .cc file as well.
227 #if defined(ENABLE_EXTENSIONS)
228 scoped_ptr<ChromeExtensionsDispatcherDelegate> extension_dispatcher_delegate_;
229 scoped_ptr<extensions::Dispatcher> extension_dispatcher_;
230 scoped_ptr<extensions::RendererPermissionsPolicyDelegate>
231 permissions_policy_delegate_;
232 scoped_ptr<extensions::ExtensionsGuestViewContainerDispatcher>
233 guest_view_container_dispatcher_;
234 scoped_ptr<extensions::ResourceRequestPolicy> resource_request_policy_;
235 #endif
237 scoped_ptr<network_hints::PrescientNetworkingDispatcher>
238 prescient_networking_dispatcher_;
239 scoped_ptr<password_manager::CredentialManagerClient>
240 credential_manager_client_;
241 #if defined(ENABLE_SPELLCHECK)
242 scoped_ptr<SpellCheck> spellcheck_;
243 #endif
244 scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
245 scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
246 scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_;
247 #if defined(ENABLE_WEBRTC)
248 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
249 #endif
250 #if defined(ENABLE_PRINT_PREVIEW)
251 scoped_ptr<ChromePDFPrintClient> pdf_print_client_;
252 #endif
253 #if defined(ENABLE_PLUGINS)
254 std::set<std::string> allowed_camera_device_origins_;
255 std::set<std::string> allowed_compositor_origins_;
256 #endif
259 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_