[Media Router] Add integration tests and e2e tests for media router and presentation...
[chromium-blink-merge.git] / chrome / renderer / chrome_content_renderer_client.h
blob2ad953de3372dedccd5c5c9bfc6e932d60b759d7
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 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 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 const base::Closure& closure) override;
110 bool RunIdleHandlerWhenWidgetsHidden() override;
111 bool AllowPopup() override;
112 bool ShouldFork(blink::WebLocalFrame* frame,
113 const GURL& url,
114 const std::string& http_method,
115 bool is_initial_navigation,
116 bool is_server_redirect,
117 bool* send_referrer) override;
118 bool WillSendRequest(blink::WebFrame* frame,
119 ui::PageTransition transition_type,
120 const GURL& url,
121 const GURL& first_party_for_cookies,
122 GURL* new_url) override;
123 unsigned long long VisitedLinkHash(const char* canonical_url,
124 size_t length) override;
125 bool IsLinkVisited(unsigned long long link_hash) override;
126 blink::WebPrescientNetworking* GetPrescientNetworking() override;
127 bool ShouldOverridePageVisibilityState(
128 const content::RenderFrame* render_frame,
129 blink::WebPageVisibilityState* override_state) override;
130 const void* CreatePPAPIInterface(const std::string& interface_name) override;
131 bool IsExternalPepperPlugin(const std::string& module_name) override;
132 blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
133 blink::WebSpeechSynthesizerClient* client) override;
134 bool ShouldReportDetailedMessageForSource(
135 const base::string16& source) const override;
136 bool ShouldGatherSiteIsolationStats() const override;
137 blink::WebWorkerContentSettingsClientProxy*
138 CreateWorkerContentSettingsClientProxy(content::RenderFrame* render_frame,
139 blink::WebFrame* frame) override;
140 bool AllowPepperMediaStreamAPI(const GURL& url) override;
141 void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) override;
142 bool IsPluginAllowedToUseDevChannelAPIs() override;
143 bool IsPluginAllowedToUseCameraDeviceAPI(const GURL& url) override;
144 bool IsPluginAllowedToUseCompositorAPI(const GURL& url) override;
145 content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
146 content::RenderFrame* render_frame,
147 const std::string& mime_type,
148 const GURL& original_url) override;
149 void RecordRappor(const std::string& metric,
150 const std::string& sample) override;
151 void RecordRapporURL(const std::string& metric, const GURL& url) override;
152 scoped_ptr<blink::WebAppBannerClient> CreateAppBannerClient(
153 content::RenderFrame* render_frame) override;
154 void AddImageContextMenuProperties(
155 const blink::WebURLResponse& response,
156 std::map<std::string, std::string>* properties) override;
158 #if defined(ENABLE_EXTENSIONS)
159 // Takes ownership.
160 void SetExtensionDispatcherForTest(
161 extensions::Dispatcher* extension_dispatcher);
162 extensions::Dispatcher* GetExtensionDispatcherForTest();
163 #endif
165 #if defined(ENABLE_SPELLCHECK)
166 // Sets a new |spellcheck|. Used for testing only.
167 // Takes ownership of |spellcheck|.
168 void SetSpellcheck(SpellCheck* spellcheck);
169 #endif
171 #if defined(ENABLE_PLUGINS)
172 static blink::WebPlugin* CreatePlugin(
173 content::RenderFrame* render_frame,
174 blink::WebLocalFrame* frame,
175 const blink::WebPluginParams& params,
176 const ChromeViewHostMsg_GetPluginInfo_Output& output);
177 #endif
179 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
180 static bool IsExtensionOrSharedModuleWhitelisted(
181 const GURL& url, const std::set<std::string>& whitelist);
182 #endif
184 static bool WasWebRequestUsedBySomeExtensions();
186 private:
187 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction);
188 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest,
189 ShouldSuppressErrorPage);
191 #if defined(ENABLE_EXTENSIONS)
192 // Gets extension by the given origin, regardless of whether the extension
193 // is active in the current process.
194 const extensions::Extension* GetExtensionByOrigin(
195 const blink::WebSecurityOrigin& origin) const;
197 // Returns true if the frame is navigating to an URL either into or out of an
198 // extension app's extent.
199 bool CrossesExtensionExtents(blink::WebLocalFrame* frame,
200 const GURL& new_url,
201 const extensions::ExtensionSet& extensions,
202 bool is_extension_url,
203 bool is_initial_navigation);
204 #endif
206 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type,
207 const content::WebPluginInfo& plugin);
209 #if !defined(DISABLE_NACL)
210 // Determines if a NaCl app is allowed, and modifies params to pass the app's
211 // permissions to the trusted NaCl plugin.
212 static bool IsNaClAllowed(const GURL& manifest_url,
213 const GURL& app_url,
214 bool is_nacl_unrestricted,
215 const extensions::Extension* extension,
216 blink::WebPluginParams* params);
217 #endif
219 scoped_ptr<ChromeRenderProcessObserver> chrome_observer_;
220 scoped_ptr<web_cache::WebCacheRenderProcessObserver> web_cache_observer_;
222 // TODO(thestig): Extract into a separate file if possible. Cleanup
223 // ENABLE_EXTENSIONS ifdefs in the .cc file as well.
224 #if defined(ENABLE_EXTENSIONS)
225 scoped_ptr<ChromeExtensionsDispatcherDelegate> extension_dispatcher_delegate_;
226 scoped_ptr<extensions::Dispatcher> extension_dispatcher_;
227 scoped_ptr<extensions::RendererPermissionsPolicyDelegate>
228 permissions_policy_delegate_;
229 scoped_ptr<extensions::ExtensionsGuestViewContainerDispatcher>
230 guest_view_container_dispatcher_;
231 #endif
233 scoped_ptr<network_hints::PrescientNetworkingDispatcher>
234 prescient_networking_dispatcher_;
235 scoped_ptr<password_manager::CredentialManagerClient>
236 credential_manager_client_;
237 #if defined(ENABLE_SPELLCHECK)
238 scoped_ptr<SpellCheck> spellcheck_;
239 #endif
240 scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
241 scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
242 scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_;
243 #if defined(ENABLE_WEBRTC)
244 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
245 #endif
246 scoped_ptr<SearchBouncer> search_bouncer_;
247 #if defined(ENABLE_PRINT_PREVIEW)
248 scoped_ptr<ChromePDFPrintClient> pdf_print_client_;
249 #endif
250 #if defined(ENABLE_PLUGINS)
251 std::set<std::string> allowed_camera_device_origins_;
252 std::set<std::string> allowed_compositor_origins_;
253 #endif
256 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_