1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
content / public / renderer / content_renderer_client.cc [blame]
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/renderer/content_renderer_client.h"
#include <string_view>
#include "base/command_line.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "build/chromecast_buildflags.h"
#include "content/public/common/content_switches.h"
#include "media/base/demuxer.h"
#include "media/base/renderer_factory.h"
#include "third_party/blink/public/common/security/protocol_handler_security_level.h"
#include "third_party/blink/public/platform/web_audio_device.h"
#include "third_party/blink/public/platform/web_prescient_networking.h"
#include "ui/gfx/icc_profile.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "v8/include/v8-initialization.h"
namespace content {
void ContentRendererClient::SetUpWebAssemblyTrapHandler() {
constexpr bool use_v8_trap_handler =
#if BUILDFLAG(IS_WIN)
// On Windows we use the default trap handler provided by V8.
true
#elif BUILDFLAG(IS_MAC)
// On macOS, Crashpad uses exception ports to handle signals in a
// different process. As we cannot just pass a callback to this other
// process, we ask V8 to install its own signal handler to deal with
// WebAssembly traps.
true
#else
// The trap handler is set as the first chance handler for Crashpad's
// signal handler.
false
#endif
;
v8::V8::EnableWebAssemblyTrapHandler(use_v8_trap_handler);
}
SkBitmap* ContentRendererClient::GetSadPluginBitmap() {
return nullptr;
}
SkBitmap* ContentRendererClient::GetSadWebViewBitmap() {
return nullptr;
}
bool ContentRendererClient::IsPluginHandledExternally(
RenderFrame* embedder_frame,
const blink::WebElement& owner_element,
const GURL& original_url,
const std::string& original_mime_type) {
return false;
}
bool ContentRendererClient::IsDomStorageDisabled() const {
return false;
}
v8::Local<v8::Object> ContentRendererClient::GetScriptableObject(
const blink::WebElement& plugin_element,
v8::Isolate* isolate) {
return v8::Local<v8::Object>();
}
bool ContentRendererClient::OverrideCreatePlugin(
RenderFrame* render_frame,
const blink::WebPluginParams& params,
blink::WebPlugin** plugin) {
return false;
}
blink::WebPlugin* ContentRendererClient::CreatePluginReplacement(
RenderFrame* render_frame,
const base::FilePath& plugin_path) {
return nullptr;
}
void ContentRendererClient::PrepareErrorPageForHttpStatusError(
content::RenderFrame* render_frame,
const blink::WebURLError& error,
const std::string& http_method,
int http_status,
mojom::AlternativeErrorPageOverrideInfoPtr alternative_error_page_info,
std::string* error_html) {
PrepareErrorPage(render_frame, error, http_method,
std::move(alternative_error_page_info), error_html);
}
bool ContentRendererClient::DeferMediaLoad(RenderFrame* render_frame,
bool has_played_media_before,
base::OnceClosure closure) {
std::move(closure).Run();
return false;
}
std::unique_ptr<media::Demuxer> ContentRendererClient::OverrideDemuxerForUrl(
RenderFrame* render_frame,
const GURL& url,
scoped_refptr<base::SequencedTaskRunner> task_runner) {
return nullptr;
}
std::unique_ptr<blink::WebSocketHandshakeThrottleProvider>
ContentRendererClient::CreateWebSocketHandshakeThrottleProvider() {
return nullptr;
}
bool ContentRendererClient::ShouldUseCodeCacheWithHashing(
const blink::WebURL& request_url) const {
return true;
}
void ContentRendererClient::PostIOThreadCreated(
base::SingleThreadTaskRunner* io_thread_task_runner) {}
void ContentRendererClient::PostCompositorThreadCreated(
base::SingleThreadTaskRunner* compositor_thread_task_runner) {}
bool ContentRendererClient::RunIdleHandlerWhenWidgetsHidden() {
return true;
}
bool ContentRendererClient::AllowPopup() {
return false;
}
bool ContentRendererClient::ShouldNotifyServiceWorkerOnWebSocketActivity(
v8::Local<v8::Context> context) {
return false;
}
blink::ProtocolHandlerSecurityLevel
ContentRendererClient::GetProtocolHandlerSecurityLevel(
const url::Origin& origin) {
return blink::ProtocolHandlerSecurityLevel::kStrict;
}
#if BUILDFLAG(IS_ANDROID)
bool ContentRendererClient::HandleNavigation(
RenderFrame* render_frame,
blink::WebFrame* frame,
const blink::WebURLRequest& request,
blink::WebNavigationType type,
blink::WebNavigationPolicy default_policy,
bool is_redirect) {
return false;
}
#endif
void ContentRendererClient::WillSendRequest(
blink::WebLocalFrame* frame,
ui::PageTransition transition_type,
const blink::WebURL& upstream_url,
const blink::WebURL& target_url,
const net::SiteForCookies& site_for_cookies,
const url::Origin* initiator_origin,
GURL* new_url) {}
bool ContentRendererClient::IsPrefetchOnly(RenderFrame* render_frame) {
return false;
}
uint64_t ContentRendererClient::VisitedLinkHash(
std::string_view canonical_url) {
return 0;
}
uint64_t ContentRendererClient::PartitionedVisitedLinkFingerprint(
std::string_view canonical_link_url,
const net::SchemefulSite& top_level_site,
const url::Origin& frame_origin) {
// Return the null-fingerprint value.
return 0;
}
bool ContentRendererClient::IsLinkVisited(uint64_t link_hash) {
return false;
}
void ContentRendererClient::AddOrUpdateVisitedLinkSalt(
const url::Origin& origin,
uint64_t salt) {}
std::unique_ptr<blink::WebPrescientNetworking>
ContentRendererClient::CreatePrescientNetworking(RenderFrame* render_frame) {
return nullptr;
}
bool ContentRendererClient::IsExternalPepperPlugin(
const std::string& module_name) {
return false;
}
bool ContentRendererClient::IsOriginIsolatedPepperPlugin(
const base::FilePath& plugin_path) {
// Hosting plugins in-process is inherently incompatible with attempting to
// process-isolate plugins from different origins.
auto* cmdline = base::CommandLine::ForCurrentProcess();
if (cmdline->HasSwitch(switches::kPpapiInProcess))
return false;
return true;
}
std::unique_ptr<media::KeySystemSupportRegistration>
ContentRendererClient::GetSupportedKeySystems(
RenderFrame* render_frame,
media::GetSupportedKeySystemsCB cb) {
std::move(cb).Run({});
return nullptr;
}
bool ContentRendererClient::IsSupportedAudioType(const media::AudioType& type) {
// Defer to media's default support.
return ::media::IsDefaultSupportedAudioType(type);
}
bool ContentRendererClient::IsSupportedVideoType(const media::VideoType& type) {
// Defer to media's default support.
return ::media::IsDefaultSupportedVideoType(type);
}
media::ExternalMemoryAllocator* ContentRendererClient::GetMediaAllocator() {
return nullptr;
}
bool ContentRendererClient::IsSupportedBitstreamAudioCodec(
media::AudioCodec codec) {
switch (codec) {
#if BUILDFLAG(ENABLE_PLATFORM_AC3_EAC3_AUDIO)
case media::AudioCodec::kAC3:
case media::AudioCodec::kEAC3:
return true;
#endif // BUILDFLAG(ENABLE_PLATFORM_AC3_EAC3_AUDIO)
#if BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
case media::AudioCodec::kDTS:
case media::AudioCodec::kDTSXP2:
return true;
#endif // BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
default:
return false;
}
}
bool ContentRendererClient::ShouldReportDetailedMessageForSource(
const std::u16string& source) {
return false;
}
std::unique_ptr<blink::WebContentSettingsClient>
ContentRendererClient::CreateWorkerContentSettingsClient(
RenderFrame* render_frame) {
return nullptr;
}
#if !BUILDFLAG(IS_ANDROID)
std::unique_ptr<media::SpeechRecognitionClient>
ContentRendererClient::CreateSpeechRecognitionClient(
RenderFrame* render_frame) {
return nullptr;
}
#endif
bool ContentRendererClient::IsPluginAllowedToUseCameraDeviceAPI(
const GURL& url) {
return false;
}
bool ContentRendererClient::AllowScriptExtensionForServiceWorker(
const url::Origin& script_origin) {
return false;
}
bool ContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() {
return true;
}
GURL ContentRendererClient::OverrideFlashEmbedWithHTML(const GURL& url) {
return GURL();
}
bool ContentRendererClient::IsIdleMediaSuspendEnabled() {
return true;
}
std::unique_ptr<blink::URLLoaderThrottleProvider>
ContentRendererClient::CreateURLLoaderThrottleProvider(
blink::URLLoaderThrottleProviderType provider_type) {
return nullptr;
}
blink::WebFrame* ContentRendererClient::FindFrame(
blink::WebLocalFrame* relative_to_frame,
const std::string& name) {
return nullptr;
}
bool ContentRendererClient::IsSafeRedirectTarget(const GURL& from_url,
const GURL& to_url) {
return true;
}
void ContentRendererClient::DidSetUserAgent(const std::string& user_agent) {}
std::optional<::media::AudioRendererAlgorithmParameters>
ContentRendererClient::GetAudioRendererAlgorithmParameters(
media::AudioParameters audio_parameters) {
return std::nullopt;
}
void ContentRendererClient::AppendContentSecurityPolicy(
const blink::WebURL& url,
blink::WebVector<blink::WebContentSecurityPolicyHeader>* csp) {}
std::unique_ptr<media::RendererFactory>
ContentRendererClient::GetBaseRendererFactory(
content::RenderFrame* render_frame,
media::MediaLog* media_log,
media::DecoderFactory* decoder_factory,
base::RepeatingCallback<media::GpuVideoAcceleratorFactories*()>
get_gpu_factories_cb,
int element_id) {
return nullptr;
}
#if BUILDFLAG(ENABLE_CAST_RECEIVER)
std::unique_ptr<cast_streaming::ResourceProvider>
ContentRendererClient::CreateCastStreamingResourceProvider() {
return nullptr;
}
#endif
std::unique_ptr<blink::WebLinkPreviewTriggerer>
ContentRendererClient::CreateLinkPreviewTriggerer() {
return nullptr;
}
} // namespace content