Enable gaia services for enterprise autotests.
[chromium-blink-merge.git] / chrome / renderer / chrome_content_renderer_client.h
blobf8cfbb030c73fbd96dc9ebfad2d7f91a899394f2
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_FULL_PRINTING)
21 class ChromePDFPrintClient;
22 #endif
23 class PrescientNetworkingDispatcher;
24 class RendererNetPredictor;
25 class SearchBouncer;
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 extensions {
39 class Dispatcher;
40 class Extension;
41 class ExtensionSet;
42 class RendererPermissionsPolicyDelegate;
45 namespace prerender {
46 class PrerenderDispatcher;
49 namespace safe_browsing {
50 class PhishingClassifierFilter;
53 namespace visitedlink {
54 class VisitedLinkSlave;
57 namespace web_cache {
58 class WebCacheRenderProcessObserver;
61 namespace blink {
62 class WebSecurityOrigin;
65 namespace password_manager {
66 class CredentialManagerClient;
69 #if defined(ENABLE_WEBRTC)
70 class WebRtcLoggingMessageFilter;
71 #endif
73 class ChromeContentRendererClient : public content::ContentRendererClient {
74 public:
75 ChromeContentRendererClient();
76 virtual ~ChromeContentRendererClient();
78 virtual void RenderThreadStarted() OVERRIDE;
79 virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE;
80 virtual void RenderViewCreated(content::RenderView* render_view) OVERRIDE;
81 virtual void SetNumberOfViews(int number_of_views) OVERRIDE;
82 virtual SkBitmap* GetSadPluginBitmap() OVERRIDE;
83 virtual SkBitmap* GetSadWebViewBitmap() OVERRIDE;
84 virtual std::string GetDefaultEncoding() OVERRIDE;
85 virtual bool OverrideCreatePlugin(
86 content::RenderFrame* render_frame,
87 blink::WebLocalFrame* frame,
88 const blink::WebPluginParams& params,
89 blink::WebPlugin** plugin) OVERRIDE;
90 virtual blink::WebPlugin* CreatePluginReplacement(
91 content::RenderFrame* render_frame,
92 const base::FilePath& plugin_path) OVERRIDE;
93 virtual bool HasErrorPage(int http_status_code,
94 std::string* error_domain) OVERRIDE;
95 virtual bool ShouldSuppressErrorPage(content::RenderFrame* render_frame,
96 const GURL& url) OVERRIDE;
97 virtual void GetNavigationErrorStrings(
98 content::RenderView* render_view,
99 blink::WebFrame* frame,
100 const blink::WebURLRequest& failed_request,
101 const blink::WebURLError& error,
102 std::string* error_html,
103 base::string16* error_description) OVERRIDE;
104 virtual void DeferMediaLoad(content::RenderFrame* render_frame,
105 const base::Closure& closure) OVERRIDE;
106 virtual bool RunIdleHandlerWhenWidgetsHidden() OVERRIDE;
107 virtual bool AllowPopup() OVERRIDE;
108 virtual bool ShouldFork(blink::WebFrame* frame,
109 const GURL& url,
110 const std::string& http_method,
111 bool is_initial_navigation,
112 bool is_server_redirect,
113 bool* send_referrer) OVERRIDE;
114 virtual bool WillSendRequest(blink::WebFrame* frame,
115 ui::PageTransition transition_type,
116 const GURL& url,
117 const GURL& first_party_for_cookies,
118 GURL* new_url) OVERRIDE;
119 virtual void DidCreateScriptContext(blink::WebFrame* frame,
120 v8::Handle<v8::Context> context,
121 int extension_group,
122 int world_id) OVERRIDE;
123 virtual unsigned long long VisitedLinkHash(const char* canonical_url,
124 size_t length) OVERRIDE;
125 virtual bool IsLinkVisited(unsigned long long link_hash) OVERRIDE;
126 virtual blink::WebPrescientNetworking* GetPrescientNetworking() OVERRIDE;
127 virtual bool ShouldOverridePageVisibilityState(
128 const content::RenderFrame* render_frame,
129 blink::WebPageVisibilityState* override_state) OVERRIDE;
130 virtual const void* CreatePPAPIInterface(
131 const std::string& interface_name) OVERRIDE;
132 virtual bool IsExternalPepperPlugin(const std::string& module_name) OVERRIDE;
133 virtual blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
134 blink::WebSpeechSynthesizerClient* client) OVERRIDE;
135 virtual bool ShouldReportDetailedMessageForSource(
136 const base::string16& source) const OVERRIDE;
137 virtual bool ShouldEnableSiteIsolationPolicy() const OVERRIDE;
138 virtual blink::WebWorkerPermissionClientProxy*
139 CreateWorkerPermissionClientProxy(content::RenderFrame* render_frame,
140 blink::WebFrame* frame) OVERRIDE;
141 virtual bool AllowPepperMediaStreamAPI(const GURL& url) OVERRIDE;
142 virtual void AddKeySystems(
143 std::vector<content::KeySystemInfo>* key_systems) OVERRIDE;
144 virtual bool IsPluginAllowedToUseDevChannelAPIs() OVERRIDE;
145 virtual bool IsPluginAllowedToUseCompositorAPI(const GURL& url) OVERRIDE;
146 virtual bool IsPluginAllowedToUseVideoDecodeAPI(const GURL& url) OVERRIDE;
147 virtual content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
148 content::RenderFrame* render_frame,
149 const std::string& mime_type) OVERRIDE;
151 #if defined(ENABLE_EXTENSIONS)
152 // Takes ownership.
153 void SetExtensionDispatcherForTest(
154 extensions::Dispatcher* extension_dispatcher);
155 extensions::Dispatcher* GetExtensionDispatcherForTest();
156 #endif
158 #if defined(ENABLE_SPELLCHECK)
159 // Sets a new |spellcheck|. Used for testing only.
160 // Takes ownership of |spellcheck|.
161 void SetSpellcheck(SpellCheck* spellcheck);
162 #endif
164 static blink::WebPlugin* CreatePlugin(
165 content::RenderFrame* render_frame,
166 blink::WebLocalFrame* frame,
167 const blink::WebPluginParams& params,
168 const ChromeViewHostMsg_GetPluginInfo_Output& output);
170 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
171 static bool IsExtensionOrSharedModuleWhitelisted(
172 const GURL& url, const std::set<std::string>& whitelist);
173 #endif
175 static bool WasWebRequestUsedBySomeExtensions();
177 private:
178 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction);
179 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest,
180 ShouldSuppressErrorPage);
182 #if defined(ENABLE_EXTENSIONS)
183 // Gets extension by the given origin, regardless of whether the extension
184 // is active in the current process.
185 const extensions::Extension* GetExtensionByOrigin(
186 const blink::WebSecurityOrigin& origin) const;
188 // Returns true if the frame is navigating to an URL either into or out of an
189 // extension app's extent.
190 bool CrossesExtensionExtents(blink::WebFrame* frame,
191 const GURL& new_url,
192 const extensions::ExtensionSet& extensions,
193 bool is_extension_url,
194 bool is_initial_navigation);
195 #endif
197 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type,
198 const content::WebPluginInfo& plugin);
200 // Determines if a NaCl app is allowed, and modifies params to pass the app's
201 // permissions to the trusted NaCl plugin.
202 static bool IsNaClAllowed(const GURL& manifest_url,
203 const GURL& app_url,
204 bool is_nacl_unrestricted,
205 const extensions::Extension* extension,
206 blink::WebPluginParams* params);
208 scoped_ptr<ChromeRenderProcessObserver> chrome_observer_;
209 scoped_ptr<web_cache::WebCacheRenderProcessObserver> web_cache_observer_;
211 // TODO(thestig): Extract into a separate file if possible. Cleanup
212 // ENABLE_EXTENSIONS ifdefs in the .cc file as well.
213 #if defined(ENABLE_EXTENSIONS)
214 scoped_ptr<ChromeExtensionsDispatcherDelegate> extension_dispatcher_delegate_;
215 scoped_ptr<extensions::Dispatcher> extension_dispatcher_;
216 scoped_ptr<extensions::RendererPermissionsPolicyDelegate>
217 permissions_policy_delegate_;
218 #endif
220 scoped_ptr<PrescientNetworkingDispatcher> prescient_networking_dispatcher_;
221 scoped_ptr<RendererNetPredictor> net_predictor_;
222 scoped_ptr<password_manager::CredentialManagerClient>
223 credential_manager_client_;
224 #if defined(ENABLE_SPELLCHECK)
225 scoped_ptr<SpellCheck> spellcheck_;
226 #endif
227 scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
228 scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
229 scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_;
230 #if defined(ENABLE_WEBRTC)
231 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
232 #endif
233 scoped_ptr<SearchBouncer> search_bouncer_;
234 #if defined(ENABLE_FULL_PRINTING)
235 scoped_ptr<ChromePDFPrintClient> pdf_print_client_;
236 #endif
237 #if defined(ENABLE_PLUGINS)
238 std::set<std::string> allowed_compositor_origins_;
239 std::set<std::string> allowed_video_decode_origins_;
240 #endif
243 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_