Debian Codegraph @

samples/chromium-sample/src/chrome_content_renderer_client.h

raw symbols SCIP
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.
4
5 #ifndef CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_
6 #define CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_
7
8 #include <stddef.h>
9
10 #include <map>
11 #include <memory>
12 #include <set>
13 #include <string>
14 #include <vector>
15
16 #include "base/compiler_specific.h"
17 #include "base/gtest_prod_util.h"
18 #include "base/strings/string16.h"
19 #include "content/public/renderer/content_renderer_client.h"
20 #include "ipc/ipc_channel_proxy.h"
21 #include "v8/include/v8.h"
22
23 class ChromeRenderThreadObserver;
24 #if defined(ENABLE_PRINT_PREVIEW)
25 class ChromePDFPrintClient;
26 #endif
27 class PrescientNetworkingDispatcher;
28 #if defined(ENABLE_SPELLCHECK)
29 class SpellCheck;
30 class SpellCheckProvider;
31 #endif
32
33 struct ChromeViewHostMsg_GetPluginInfo_Output;
34
35 namespace content {
36 class BrowserPluginDelegate;
37 struct WebPluginInfo;
38 }
39
40 namespace network_hints {
41 class PrescientNetworkingDispatcher;
42 }
43
44 namespace extensions {
45 class Dispatcher;
46 class Extension;
47 }
48
49 namespace prerender {
50 class PrerenderDispatcher;
51 }
52
53 namespace safe_browsing {
54 class PhishingClassifierFilter;
55 }
56
57 namespace visitedlink {
58 class VisitedLinkSlave;
59 }
60
61 namespace web_cache {
62 class WebCacheImpl;
63 }
64
65 namespace blink {
66 class WebSecurityOrigin;
67 }
68
69 #if defined(ENABLE_WEBRTC)
70 class WebRtcLoggingMessageFilter;
71 #endif
72
73 class ChromeContentRendererClient : public content::ContentRendererClient {
74 public:
75 ChromeContentRendererClient();
76 ~ChromeContentRendererClient() override;
77
78 void RenderThreadStarted() override;
79 void RenderFrameCreated(content::RenderFrame* render_frame) override;
80 void RenderViewCreated(content::RenderView* render_view) override;
81 SkBitmap* GetSadPluginBitmap() override;
82 SkBitmap* GetSadWebViewBitmap() override;
83 bool OverrideCreatePlugin(content::RenderFrame* render_frame,
84 blink::WebLocalFrame* frame,
85 const blink::WebPluginParams& params,
86 blink::WebPlugin** plugin) override;
87 blink::WebPlugin* CreatePluginReplacement(
88 content::RenderFrame* render_frame,
89 const base::FilePath& plugin_path) override;
90 bool HasErrorPage(int http_status_code, std::string* error_domain) override;
91 bool ShouldSuppressErrorPage(content::RenderFrame* render_frame,
92 const GURL& url) override;
93 void GetNavigationErrorStrings(content::RenderFrame* render_frame,
94 const blink::WebURLRequest& failed_request,
95 const blink::WebURLError& error,
96 std::string* error_html,
97 base::string16* error_description) override;
98 void DeferMediaLoad(content::RenderFrame* render_frame,
99 bool has_played_media_before,
100 const base::Closure& closure) override;
101 bool RunIdleHandlerWhenWidgetsHidden() override;
102 bool AllowTimerSuspensionWhenProcessBackgrounded() override;
103 bool AllowPopup() override;
104 bool ShouldFork(blink::WebLocalFrame* frame,
105 const GURL& url,
106 const std::string& http_method,
107 bool is_initial_navigation,
108 bool is_server_redirect,
109 bool* send_referrer) override;
110 bool WillSendRequest(blink::WebFrame* frame,
111 ui::PageTransition transition_type,
112 const GURL& url,
113 const GURL& first_party_for_cookies,
114 GURL* new_url) override;
115 unsigned long long VisitedLinkHash(const char* canonical_url,
116 size_t length) override;
117 bool IsLinkVisited(unsigned long long link_hash) override;
118 blink::WebPrescientNetworking* GetPrescientNetworking() override;
119 bool ShouldOverridePageVisibilityState(
120 const content::RenderFrame* render_frame,
121 blink::WebPageVisibilityState* override_state) override;
122 bool IsExternalPepperPlugin(const std::string& module_name) override;
123 blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
124 blink::WebSpeechSynthesizerClient* client) override;
125 bool ShouldReportDetailedMessageForSource(
126 const base::string16& source) const override;
127 bool ShouldGatherSiteIsolationStats() const override;
128 blink::WebWorkerContentSettingsClientProxy*
129 CreateWorkerContentSettingsClientProxy(content::RenderFrame* render_frame,
130 blink::WebFrame* frame) override;
131 bool AllowPepperMediaStreamAPI(const GURL& url) override;
132 void AddSupportedKeySystems(
133 std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems)
134 override;
135 bool IsPluginAllowedToUseDevChannelAPIs() override;
136 bool IsPluginAllowedToUseCameraDeviceAPI(const GURL& url) override;
137 bool IsPluginAllowedToUseCompositorAPI(const GURL& url) override;
138 content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
139 content::RenderFrame* render_frame,
140 const std::string& mime_type,
141 const GURL& original_url) override;
142 void RecordRappor(const std::string& metric,
143 const std::string& sample) override;
144 void RecordRapporURL(const std::string& metric, const GURL& url) override;
145 std::unique_ptr<blink::WebAppBannerClient> CreateAppBannerClient(
146 content::RenderFrame* render_frame) override;
147 void AddImageContextMenuProperties(
148 const blink::WebURLResponse& response,
149 std::map<std::string, std::string>* properties) override;
150 void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
151 void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
152 void DidInitializeServiceWorkerContextOnWorkerThread(
153 v8::Local<v8::Context> context,
154 const GURL& url) override;
155 void WillDestroyServiceWorkerContextOnWorkerThread(
156 v8::Local<v8::Context> context,
157 const GURL& url) override;
158 bool ShouldEnforceWebRTCRoutingPreferences() override;
159
160 #if defined(ENABLE_SPELLCHECK)
161 // Sets a new |spellcheck|. Used for testing only.
162 // Takes ownership of |spellcheck|.
163 void SetSpellcheck(SpellCheck* spellcheck);
164 #endif
165
166 #if defined(ENABLE_PLUGINS)
167 static blink::WebPlugin* CreatePlugin(
168 content::RenderFrame* render_frame,
169 blink::WebLocalFrame* frame,
170 const blink::WebPluginParams& params,
171 const ChromeViewHostMsg_GetPluginInfo_Output& output);
172 #endif
173
174 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
175 static bool IsExtensionOrSharedModuleWhitelisted(
176 const GURL& url, const std::set<std::string>& whitelist);
177 #endif
178
179 private:
180 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction);
181 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest,
182 ShouldSuppressErrorPage);
183
184 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type,
185 const content::WebPluginInfo& plugin);
186
187 // Time at which this object was created. This is very close to the time at
188 // which the RendererMain function was entered.
189 base::TimeTicks main_entry_time_;
190
191 #if !defined(DISABLE_NACL)
192 // Determines if a NaCl app is allowed, and modifies params to pass the app's
193 // permissions to the trusted NaCl plugin.
194 static bool IsNaClAllowed(const GURL& manifest_url,
195 const GURL& app_url,
196 bool is_nacl_unrestricted,
197 const extensions::Extension* extension,
198 blink::WebPluginParams* params);
199 #endif
200
201 std::unique_ptr<ChromeRenderThreadObserver> chrome_observer_;
202 std::unique_ptr<web_cache::WebCacheImpl> web_cache_impl_;
203
204 std::unique_ptr<network_hints::PrescientNetworkingDispatcher>
205 prescient_networking_dispatcher_;
206
207 #if defined(ENABLE_SPELLCHECK)
208 std::unique_ptr<SpellCheck> spellcheck_;
209 #endif
210 std::unique_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
211 std::unique_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
212 std::unique_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_;
213 #if defined(ENABLE_WEBRTC)
214 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
215 #endif
216 #if defined(ENABLE_PRINT_PREVIEW)
217 std::unique_ptr<ChromePDFPrintClient> pdf_print_client_;
218 #endif
219 #if defined(ENABLE_PLUGINS)
220 std::set<std::string> allowed_camera_device_origins_;
221 std::set<std::string> allowed_compositor_origins_;
222 #endif
223 };
224
225 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_