Added documentation to web_view.js/web_view_experimental.js regarding the webview...
[chromium-blink-merge.git] / chrome / renderer / chrome_content_renderer_client.h
blob71e07c54c466e6a0619900aa666a29ffed4cb8a2
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 <string>
9 #include <vector>
11 #if defined(ENABLE_PLUGINS)
12 #include <set>
13 #endif
15 #include "base/compiler_specific.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/strings/string16.h"
18 #include "content/public/renderer/content_renderer_client.h"
20 class ChromeRenderProcessObserver;
21 class PrescientNetworkingDispatcher;
22 class RendererNetPredictor;
23 class SearchBouncer;
24 #if defined(ENABLE_SPELLCHECK)
25 class SpellCheck;
26 class SpellCheckProvider;
27 #endif
29 struct ChromeViewHostMsg_GetPluginInfo_Output;
31 namespace content {
32 struct WebPluginInfo;
35 namespace extensions {
36 class Dispatcher;
37 class Extension;
38 class ExtensionSet;
39 class RendererPermissionsPolicyDelegate;
42 namespace prerender {
43 class PrerenderDispatcher;
46 namespace safe_browsing {
47 class PhishingClassifierFilter;
50 namespace visitedlink {
51 class VisitedLinkSlave;
54 namespace blink {
55 class WebSecurityOrigin;
58 #if defined(ENABLE_WEBRTC)
59 class WebRtcLoggingMessageFilter;
60 #endif
62 class ChromeContentRendererClient : public content::ContentRendererClient {
63 public:
64 ChromeContentRendererClient();
65 virtual ~ChromeContentRendererClient();
67 virtual void RenderThreadStarted() OVERRIDE;
68 virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE;
69 virtual void RenderViewCreated(content::RenderView* render_view) OVERRIDE;
70 virtual void SetNumberOfViews(int number_of_views) OVERRIDE;
71 virtual SkBitmap* GetSadPluginBitmap() OVERRIDE;
72 virtual SkBitmap* GetSadWebViewBitmap() OVERRIDE;
73 virtual std::string GetDefaultEncoding() OVERRIDE;
74 virtual bool OverrideCreatePlugin(
75 content::RenderFrame* render_frame,
76 blink::WebFrame* frame,
77 const blink::WebPluginParams& params,
78 blink::WebPlugin** plugin) OVERRIDE;
79 virtual blink::WebPlugin* CreatePluginReplacement(
80 content::RenderFrame* render_frame,
81 const base::FilePath& plugin_path) OVERRIDE;
82 virtual bool HasErrorPage(int http_status_code,
83 std::string* error_domain) OVERRIDE;
84 virtual bool ShouldSuppressErrorPage(content::RenderFrame* render_frame,
85 const GURL& url) OVERRIDE;
86 virtual void GetNavigationErrorStrings(
87 content::RenderView* render_view,
88 blink::WebFrame* frame,
89 const blink::WebURLRequest& failed_request,
90 const blink::WebURLError& error,
91 std::string* error_html,
92 base::string16* error_description) OVERRIDE;
93 virtual void DeferMediaLoad(content::RenderFrame* render_frame,
94 const base::Closure& closure) OVERRIDE;
95 virtual bool RunIdleHandlerWhenWidgetsHidden() OVERRIDE;
96 virtual bool AllowPopup() OVERRIDE;
97 virtual bool ShouldFork(blink::WebFrame* frame,
98 const GURL& url,
99 const std::string& http_method,
100 bool is_initial_navigation,
101 bool is_server_redirect,
102 bool* send_referrer) OVERRIDE;
103 virtual bool WillSendRequest(blink::WebFrame* frame,
104 content::PageTransition transition_type,
105 const GURL& url,
106 const GURL& first_party_for_cookies,
107 GURL* new_url) OVERRIDE;
108 virtual void DidCreateScriptContext(blink::WebFrame* frame,
109 v8::Handle<v8::Context> context,
110 int extension_group,
111 int world_id) OVERRIDE;
112 virtual void WillReleaseScriptContext(blink::WebFrame* frame,
113 v8::Handle<v8::Context> context,
114 int world_id) OVERRIDE;
115 virtual unsigned long long VisitedLinkHash(const char* canonical_url,
116 size_t length) OVERRIDE;
117 virtual bool IsLinkVisited(unsigned long long link_hash) OVERRIDE;
118 virtual blink::WebPrescientNetworking* GetPrescientNetworking() OVERRIDE;
119 virtual bool ShouldOverridePageVisibilityState(
120 const content::RenderFrame* render_frame,
121 blink::WebPageVisibilityState* override_state) OVERRIDE;
122 virtual bool AllowBrowserPlugin(
123 blink::WebPluginContainer* container) OVERRIDE;
124 virtual const void* CreatePPAPIInterface(
125 const std::string& interface_name) OVERRIDE;
126 virtual bool IsExternalPepperPlugin(const std::string& module_name) OVERRIDE;
127 virtual blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
128 blink::WebSpeechSynthesizerClient* client) OVERRIDE;
129 virtual bool ShouldReportDetailedMessageForSource(
130 const base::string16& source) const OVERRIDE;
131 virtual bool ShouldEnableSiteIsolationPolicy() const OVERRIDE;
132 virtual blink::WebWorkerPermissionClientProxy*
133 CreateWorkerPermissionClientProxy(content::RenderFrame* render_frame,
134 blink::WebFrame* frame) OVERRIDE;
135 virtual bool AllowPepperMediaStreamAPI(const GURL& url) OVERRIDE;
136 virtual void AddKeySystems(
137 std::vector<content::KeySystemInfo>* key_systems) OVERRIDE;
139 // For testing.
140 void SetExtensionDispatcher(extensions::Dispatcher* extension_dispatcher);
142 #if defined(ENABLE_SPELLCHECK)
143 // Sets a new |spellcheck|. Used for low-mem restart and testing only.
144 // Takes ownership of |spellcheck|.
145 void SetSpellcheck(SpellCheck* spellcheck);
146 #endif
148 // Called in low-memory conditions to dump the memory used by the spellchecker
149 // and start over.
150 void OnPurgeMemory();
152 static blink::WebPlugin* CreatePlugin(
153 content::RenderFrame* render_frame,
154 blink::WebFrame* frame,
155 const blink::WebPluginParams& params,
156 const ChromeViewHostMsg_GetPluginInfo_Output& output);
158 // TODO(mpcomplete): remove after we collect histogram data.
159 // http://crbug.com/100411
160 static bool IsAdblockInstalled();
161 static bool IsAdblockPlusInstalled();
162 static bool IsAdblockWithWebRequestInstalled();
163 static bool IsAdblockPlusWithWebRequestInstalled();
164 static bool IsOtherExtensionWithWebRequestInstalled();
166 private:
167 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction);
168 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest,
169 ShouldSuppressErrorPage);
171 // Gets extension by the given origin, regardless of whether the extension
172 // is active in the current process.
173 const extensions::Extension* GetExtensionByOrigin(
174 const blink::WebSecurityOrigin& origin) const;
176 // Returns true if the frame is navigating to an URL either into or out of an
177 // extension app's extent.
178 bool CrossesExtensionExtents(blink::WebFrame* frame,
179 const GURL& new_url,
180 const extensions::ExtensionSet& extensions,
181 bool is_extension_url,
182 bool is_initial_navigation);
184 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type,
185 const content::WebPluginInfo& plugin);
187 // Determines if a NaCl app is allowed, and modifies params to pass the app's
188 // permissions to the trusted NaCl plugin.
189 static bool IsNaClAllowed(const GURL& manifest_url,
190 const GURL& app_url,
191 bool is_nacl_unrestricted,
192 const extensions::Extension* extension,
193 blink::WebPluginParams* params);
195 scoped_ptr<ChromeRenderProcessObserver> chrome_observer_;
196 scoped_ptr<extensions::Dispatcher> extension_dispatcher_;
197 scoped_ptr<extensions::RendererPermissionsPolicyDelegate>
198 permissions_policy_delegate_;
199 scoped_ptr<PrescientNetworkingDispatcher> prescient_networking_dispatcher_;
200 scoped_ptr<RendererNetPredictor> net_predictor_;
201 #if defined(ENABLE_SPELLCHECK)
202 scoped_ptr<SpellCheck> spellcheck_;
203 #endif
204 scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
205 scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
206 scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_;
207 #if defined(ENABLE_WEBRTC)
208 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
209 #endif
210 scoped_ptr<SearchBouncer> search_bouncer_;
213 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_