Re-enable blink_perf.canvas on Windows
[chromium-blink-merge.git] / content / renderer / renderer_blink_platform_impl.cc
blob0e9864fdc6feb887fb8e3637c9baea5be4aac70a
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 #include "content/renderer/renderer_blink_platform_impl.h"
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "base/lazy_instance.h"
10 #include "base/logging.h"
11 #include "base/memory/shared_memory.h"
12 #include "base/message_loop/message_loop_proxy.h"
13 #include "base/metrics/histogram.h"
14 #include "base/numerics/safe_conversions.h"
15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/utf_string_conversions.h"
17 #include "cc/blink/context_provider_web_context.h"
18 #include "components/scheduler/child/web_scheduler_impl.h"
19 #include "components/scheduler/renderer/renderer_scheduler.h"
20 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h"
21 #include "content/child/database_util.h"
22 #include "content/child/file_info_util.h"
23 #include "content/child/fileapi/webfilesystem_impl.h"
24 #include "content/child/indexed_db/webidbfactory_impl.h"
25 #include "content/child/npapi/npobject_util.h"
26 #include "content/child/quota_dispatcher.h"
27 #include "content/child/quota_message_filter.h"
28 #include "content/child/simple_webmimeregistry_impl.h"
29 #include "content/child/thread_safe_sender.h"
30 #include "content/child/web_database_observer_impl.h"
31 #include "content/child/webblobregistry_impl.h"
32 #include "content/child/webfileutilities_impl.h"
33 #include "content/child/webmessageportchannel_impl.h"
34 #include "content/common/file_utilities_messages.h"
35 #include "content/common/gpu/client/context_provider_command_buffer.h"
36 #include "content/common/gpu/client/gpu_channel_host.h"
37 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
38 #include "content/common/gpu/gpu_process_launch_causes.h"
39 #include "content/common/mime_registry_messages.h"
40 #include "content/common/view_messages.h"
41 #include "content/public/common/content_switches.h"
42 #include "content/public/common/service_registry.h"
43 #include "content/public/common/webplugininfo.h"
44 #include "content/public/renderer/content_renderer_client.h"
45 #include "content/renderer/battery_status/battery_status_dispatcher.h"
46 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h"
47 #include "content/renderer/device_sensors/device_light_event_pump.h"
48 #include "content/renderer/device_sensors/device_motion_event_pump.h"
49 #include "content/renderer/device_sensors/device_orientation_event_pump.h"
50 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
51 #include "content/renderer/gamepad_shared_memory_reader.h"
52 #include "content/renderer/media/audio_decoder.h"
53 #include "content/renderer/media/renderer_webaudiodevice_impl.h"
54 #include "content/renderer/media/renderer_webmidiaccessor_impl.h"
55 #include "content/renderer/render_thread_impl.h"
56 #include "content/renderer/renderer_clipboard_delegate.h"
57 #include "content/renderer/screen_orientation/screen_orientation_observer.h"
58 #include "content/renderer/webclipboard_impl.h"
59 #include "content/renderer/webgraphicscontext3d_provider_impl.h"
60 #include "content/renderer/webpublicsuffixlist_impl.h"
61 #include "gpu/config/gpu_info.h"
62 #include "ipc/ipc_sync_message_filter.h"
63 #include "media/audio/audio_output_device.h"
64 #include "media/base/audio_hardware_config.h"
65 #include "media/base/key_systems.h"
66 #include "media/blink/webcontentdecryptionmodule_impl.h"
67 #include "media/filters/stream_parser_factory.h"
68 #include "net/base/mime_util.h"
69 #include "net/base/net_util.h"
70 #include "storage/common/database/database_identifier.h"
71 #include "storage/common/quota/quota_types.h"
72 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h"
73 #include "third_party/WebKit/public/platform/WebBlobRegistry.h"
74 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h"
75 #include "third_party/WebKit/public/platform/WebFileInfo.h"
76 #include "third_party/WebKit/public/platform/WebGamepads.h"
77 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
78 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h"
79 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h"
80 #include "third_party/WebKit/public/platform/WebURL.h"
81 #include "third_party/WebKit/public/platform/WebVector.h"
82 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDeviceMotionListener.h"
83 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDeviceOrientationListener.h"
84 #include "ui/gfx/color_profile.h"
85 #include "url/gurl.h"
87 #if defined(OS_ANDROID)
88 #include "content/renderer/android/synchronous_compositor_factory.h"
89 #include "content/renderer/media/android/audio_decoder_android.h"
90 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h"
91 #endif
93 #if defined(OS_MACOSX)
94 #include "content/common/mac/font_descriptor.h"
95 #include "content/common/mac/font_loader.h"
96 #include "content/renderer/webscrollbarbehavior_impl_mac.h"
97 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h"
98 #endif
100 #if defined(OS_POSIX)
101 #include "base/file_descriptor_posix.h"
102 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
103 #include <map>
104 #include <string>
106 #include "base/synchronization/lock.h"
107 #include "content/common/child_process_sandbox_support_impl_linux.h"
108 #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h"
109 #include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h"
110 #include "third_party/icu/source/common/unicode/utf16.h"
111 #endif
112 #endif
114 #if defined(OS_WIN)
115 #include "content/common/child_process_messages.h"
116 #endif
118 #if defined(USE_AURA)
119 #include "content/renderer/webscrollbarbehavior_impl_gtkoraura.h"
120 #elif !defined(OS_MACOSX)
121 #include "third_party/WebKit/public/platform/WebScrollbarBehavior.h"
122 #define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior
123 #endif
125 #if defined(ENABLE_WEBRTC)
126 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
127 #endif
129 using blink::Platform;
130 using blink::WebAudioDevice;
131 using blink::WebBlobRegistry;
132 using blink::WebDatabaseObserver;
133 using blink::WebFileInfo;
134 using blink::WebFileSystem;
135 using blink::WebGamepad;
136 using blink::WebGamepads;
137 using blink::WebIDBFactory;
138 using blink::WebMIDIAccessor;
139 using blink::WebMediaStreamCenter;
140 using blink::WebMediaStreamCenterClient;
141 using blink::WebMimeRegistry;
142 using blink::WebRTCPeerConnectionHandler;
143 using blink::WebRTCPeerConnectionHandlerClient;
144 using blink::WebStorageNamespace;
145 using blink::WebString;
146 using blink::WebURL;
147 using blink::WebVector;
149 namespace content {
151 namespace {
153 bool g_sandbox_enabled = true;
154 double g_test_device_light_data = -1;
155 base::LazyInstance<blink::WebDeviceMotionData>::Leaky
156 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
157 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
158 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER;
159 // Set in startListening() when running layout tests, unset in stopListening(),
160 // not owned by us.
161 blink::WebBatteryStatusListener* g_test_battery_status_listener = nullptr;
163 } // namespace
165 //------------------------------------------------------------------------------
167 class RendererBlinkPlatformImpl::MimeRegistry
168 : public SimpleWebMimeRegistryImpl {
169 public:
170 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType(
171 const blink::WebString& mime_type,
172 const blink::WebString& codecs,
173 const blink::WebString& key_system);
174 virtual bool supportsMediaSourceMIMEType(const blink::WebString& mime_type,
175 const blink::WebString& codecs);
176 virtual blink::WebString mimeTypeForExtension(
177 const blink::WebString& file_extension);
178 virtual blink::WebString mimeTypeFromFile(
179 const blink::WebString& file_path);
182 class RendererBlinkPlatformImpl::FileUtilities : public WebFileUtilitiesImpl {
183 public:
184 explicit FileUtilities(ThreadSafeSender* sender)
185 : thread_safe_sender_(sender) {}
186 virtual bool getFileInfo(const WebString& path, WebFileInfo& result);
187 private:
188 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const;
189 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
192 #if !defined(OS_ANDROID) && !defined(OS_WIN)
193 class RendererBlinkPlatformImpl::SandboxSupport
194 : public blink::WebSandboxSupport {
195 public:
196 virtual ~SandboxSupport() {}
198 #if defined(OS_MACOSX)
199 virtual bool loadFont(
200 NSFont* src_font,
201 CGFontRef* container,
202 uint32* font_id);
203 #elif defined(OS_POSIX)
204 virtual void getFallbackFontForCharacter(
205 blink::WebUChar32 character,
206 const char* preferred_locale,
207 blink::WebFallbackFont* fallbackFont);
208 virtual void getRenderStyleForStrike(
209 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out);
211 private:
212 // WebKit likes to ask us for the correct font family to use for a set of
213 // unicode code points. It needs this information frequently so we cache it
214 // here.
215 base::Lock unicode_font_families_mutex_;
216 std::map<int32_t, blink::WebFallbackFont> unicode_font_families_;
217 #endif
219 #endif // !defined(OS_ANDROID) && !defined(OS_WIN)
221 //------------------------------------------------------------------------------
223 RendererBlinkPlatformImpl::RendererBlinkPlatformImpl(
224 scheduler::RendererScheduler* renderer_scheduler)
225 : BlinkPlatformImpl(renderer_scheduler->DefaultTaskRunner()),
226 main_thread_(
227 new scheduler::WebThreadImplForRendererScheduler(renderer_scheduler)),
228 clipboard_delegate_(new RendererClipboardDelegate),
229 clipboard_(new WebClipboardImpl(clipboard_delegate_.get())),
230 mime_registry_(new RendererBlinkPlatformImpl::MimeRegistry),
231 sudden_termination_disables_(0),
232 plugin_refresh_allowed_(true),
233 default_task_runner_(renderer_scheduler->DefaultTaskRunner()),
234 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl) {
235 #if !defined(OS_ANDROID) && !defined(OS_WIN)
236 if (g_sandbox_enabled && sandboxEnabled()) {
237 sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport);
238 } else {
239 DVLOG(1) << "Disabling sandbox support for testing.";
241 #endif
243 // ChildThread may not exist in some tests.
244 if (ChildThreadImpl::current()) {
245 sync_message_filter_ = ChildThreadImpl::current()->sync_message_filter();
246 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender();
247 quota_message_filter_ = ChildThreadImpl::current()->quota_message_filter();
248 blob_registry_.reset(new WebBlobRegistryImpl(thread_safe_sender_.get()));
249 web_idb_factory_.reset(new WebIDBFactoryImpl(thread_safe_sender_.get()));
250 web_database_observer_impl_.reset(
251 new WebDatabaseObserverImpl(sync_message_filter_.get()));
255 RendererBlinkPlatformImpl::~RendererBlinkPlatformImpl() {
256 WebFileSystemImpl::DeleteThreadSpecificInstance();
259 //------------------------------------------------------------------------------
261 blink::WebThread* RendererBlinkPlatformImpl::currentThread() {
262 if (main_thread_->isCurrentThread())
263 return main_thread_.get();
264 return BlinkPlatformImpl::currentThread();
267 blink::WebClipboard* RendererBlinkPlatformImpl::clipboard() {
268 blink::WebClipboard* clipboard =
269 GetContentClient()->renderer()->OverrideWebClipboard();
270 if (clipboard)
271 return clipboard;
272 return clipboard_.get();
275 blink::WebMimeRegistry* RendererBlinkPlatformImpl::mimeRegistry() {
276 return mime_registry_.get();
279 blink::WebFileUtilities* RendererBlinkPlatformImpl::fileUtilities() {
280 if (!file_utilities_) {
281 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get()));
282 file_utilities_->set_sandbox_enabled(sandboxEnabled());
284 return file_utilities_.get();
287 blink::WebSandboxSupport* RendererBlinkPlatformImpl::sandboxSupport() {
288 #if defined(OS_ANDROID) || defined(OS_WIN)
289 // These platforms do not require sandbox support.
290 return NULL;
291 #else
292 return sandbox_support_.get();
293 #endif
296 blink::WebCookieJar* RendererBlinkPlatformImpl::cookieJar() {
297 NOTREACHED() << "Use WebFrameClient::cookieJar() instead!";
298 return NULL;
301 blink::WebThemeEngine* RendererBlinkPlatformImpl::themeEngine() {
302 blink::WebThemeEngine* theme_engine =
303 GetContentClient()->renderer()->OverrideThemeEngine();
304 if (theme_engine)
305 return theme_engine;
306 return BlinkPlatformImpl::themeEngine();
309 bool RendererBlinkPlatformImpl::sandboxEnabled() {
310 // As explained in Platform.h, this function is used to decide
311 // whether to allow file system operations to come out of WebKit or not.
312 // Even if the sandbox is disabled, there's no reason why the code should
313 // act any differently...unless we're in single process mode. In which
314 // case, we have no other choice. Platform.h discourages using
315 // this switch unless absolutely necessary, so hopefully we won't end up
316 // with too many code paths being different in single-process mode.
317 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
318 switches::kSingleProcess);
321 unsigned long long RendererBlinkPlatformImpl::visitedLinkHash(
322 const char* canonical_url,
323 size_t length) {
324 return GetContentClient()->renderer()->VisitedLinkHash(canonical_url, length);
327 bool RendererBlinkPlatformImpl::isLinkVisited(unsigned long long link_hash) {
328 return GetContentClient()->renderer()->IsLinkVisited(link_hash);
331 void RendererBlinkPlatformImpl::createMessageChannel(
332 blink::WebMessagePortChannel** channel1,
333 blink::WebMessagePortChannel** channel2) {
334 WebMessagePortChannelImpl::CreatePair(
335 default_task_runner_, channel1, channel2);
338 blink::WebPrescientNetworking*
339 RendererBlinkPlatformImpl::prescientNetworking() {
340 return GetContentClient()->renderer()->GetPrescientNetworking();
343 void RendererBlinkPlatformImpl::cacheMetadata(const blink::WebURL& url,
344 int64 response_time,
345 const char* data,
346 size_t size) {
347 // Let the browser know we generated cacheable metadata for this resource. The
348 // browser may cache it and return it on subsequent responses to speed
349 // the processing of this resource.
350 std::vector<char> copy(data, data + size);
351 RenderThread::Get()->Send(new ViewHostMsg_DidGenerateCacheableMetadata(
352 url, base::Time::FromInternalValue(response_time), copy));
355 WebString RendererBlinkPlatformImpl::defaultLocale() {
356 return base::ASCIIToUTF16(RenderThread::Get()->GetLocale());
359 void RendererBlinkPlatformImpl::suddenTerminationChanged(bool enabled) {
360 if (enabled) {
361 // We should not get more enables than disables, but we want it to be a
362 // non-fatal error if it does happen.
363 DCHECK_GT(sudden_termination_disables_, 0);
364 sudden_termination_disables_ = std::max(sudden_termination_disables_ - 1,
366 if (sudden_termination_disables_ != 0)
367 return;
368 } else {
369 sudden_termination_disables_++;
370 if (sudden_termination_disables_ != 1)
371 return;
374 RenderThread* thread = RenderThread::Get();
375 if (thread) // NULL in unittests.
376 thread->Send(new ViewHostMsg_SuddenTerminationChanged(enabled));
379 WebStorageNamespace* RendererBlinkPlatformImpl::createLocalStorageNamespace() {
380 return new WebStorageNamespaceImpl();
384 //------------------------------------------------------------------------------
386 WebIDBFactory* RendererBlinkPlatformImpl::idbFactory() {
387 return web_idb_factory_.get();
390 //------------------------------------------------------------------------------
392 blink::WebServiceWorkerCacheStorage* RendererBlinkPlatformImpl::cacheStorage(
393 const WebString& origin_identifier) {
394 const GURL origin =
395 storage::GetOriginFromIdentifier(origin_identifier.utf8());
396 return new WebServiceWorkerCacheStorageImpl(thread_safe_sender_.get(),
397 origin);
400 //------------------------------------------------------------------------------
402 WebFileSystem* RendererBlinkPlatformImpl::fileSystem() {
403 return WebFileSystemImpl::ThreadSpecificInstance(default_task_runner_);
406 //------------------------------------------------------------------------------
408 WebMimeRegistry::SupportsType
409 RendererBlinkPlatformImpl::MimeRegistry::supportsMediaMIMEType(
410 const WebString& mime_type,
411 const WebString& codecs,
412 const WebString& key_system) {
413 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
414 // Not supporting the container is a flat-out no.
415 if (!net::IsSupportedMediaMimeType(mime_type_ascii))
416 return IsNotSupported;
418 if (!key_system.isEmpty()) {
419 // Check whether the key system is supported with the mime_type and codecs.
421 // Chromium only supports ASCII parameters.
422 if (!base::IsStringASCII(key_system))
423 return IsNotSupported;
425 std::string key_system_ascii =
426 media::GetUnprefixedKeySystemName(base::UTF16ToASCII(key_system));
427 std::vector<std::string> strict_codecs;
428 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, true);
430 if (!media::PrefixedIsSupportedKeySystemWithMediaMimeType(
431 mime_type_ascii, strict_codecs, key_system_ascii)) {
432 return IsNotSupported;
435 // Continue processing the mime_type and codecs.
438 // Check list of strict codecs to see if it is supported.
439 if (net::IsStrictMediaMimeType(mime_type_ascii)) {
440 // Check if the codecs are a perfect match.
441 std::vector<std::string> strict_codecs;
442 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false);
443 return static_cast<WebMimeRegistry::SupportsType> (
444 net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs));
447 // If we don't recognize the codec, it's possible we support it.
448 std::vector<std::string> parsed_codecs;
449 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true);
450 if (!net::AreSupportedMediaCodecs(parsed_codecs))
451 return MayBeSupported;
453 // Otherwise we have a perfect match.
454 return IsSupported;
457 bool RendererBlinkPlatformImpl::MimeRegistry::supportsMediaSourceMIMEType(
458 const blink::WebString& mime_type,
459 const WebString& codecs) {
460 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
461 std::vector<std::string> parsed_codec_ids;
462 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false);
463 if (mime_type_ascii.empty())
464 return false;
465 return media::StreamParserFactory::IsTypeSupported(
466 mime_type_ascii, parsed_codec_ids);
469 WebString RendererBlinkPlatformImpl::MimeRegistry::mimeTypeForExtension(
470 const WebString& file_extension) {
471 if (IsPluginProcess())
472 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension);
474 // The sandbox restricts our access to the registry, so we need to proxy
475 // these calls over to the browser process.
476 std::string mime_type;
477 RenderThread::Get()->Send(
478 new MimeRegistryMsg_GetMimeTypeFromExtension(
479 base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type));
480 return base::ASCIIToUTF16(mime_type);
483 WebString RendererBlinkPlatformImpl::MimeRegistry::mimeTypeFromFile(
484 const WebString& file_path) {
485 if (IsPluginProcess())
486 return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path);
488 // The sandbox restricts our access to the registry, so we need to proxy
489 // these calls over to the browser process.
490 std::string mime_type;
491 RenderThread::Get()->Send(new MimeRegistryMsg_GetMimeTypeFromFile(
492 base::FilePath::FromUTF16Unsafe(file_path),
493 &mime_type));
494 return base::ASCIIToUTF16(mime_type);
497 //------------------------------------------------------------------------------
499 bool RendererBlinkPlatformImpl::FileUtilities::getFileInfo(
500 const WebString& path,
501 WebFileInfo& web_file_info) {
502 base::File::Info file_info;
503 base::File::Error status = base::File::FILE_ERROR_MAX;
504 if (!SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileInfo(
505 base::FilePath::FromUTF16Unsafe(path), &file_info, &status)) ||
506 status != base::File::FILE_OK) {
507 return false;
509 FileInfoToWebFileInfo(file_info, &web_file_info);
510 web_file_info.platformPath = path;
511 return true;
514 bool RendererBlinkPlatformImpl::FileUtilities::SendSyncMessageFromAnyThread(
515 IPC::SyncMessage* msg) const {
516 base::TimeTicks begin = base::TimeTicks::Now();
517 const bool success = thread_safe_sender_->Send(msg);
518 base::TimeDelta delta = base::TimeTicks::Now() - begin;
519 UMA_HISTOGRAM_TIMES("RendererSyncIPC.ElapsedTime", delta);
520 return success;
523 //------------------------------------------------------------------------------
525 #if defined(OS_MACOSX)
527 bool RendererBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font,
528 CGFontRef* out,
529 uint32* font_id) {
530 uint32 font_data_size;
531 FontDescriptor src_font_descriptor(src_font);
532 base::SharedMemoryHandle font_data;
533 if (!RenderThread::Get()->Send(new ViewHostMsg_LoadFont(
534 src_font_descriptor, &font_data_size, &font_data, font_id))) {
535 *out = NULL;
536 *font_id = 0;
537 return false;
540 if (font_data_size == 0 || font_data == base::SharedMemory::NULLHandle() ||
541 *font_id == 0) {
542 LOG(ERROR) << "Bad response from ViewHostMsg_LoadFont() for " <<
543 src_font_descriptor.font_name;
544 *out = NULL;
545 *font_id = 0;
546 return false;
549 // TODO(jeremy): Need to call back into WebKit to make sure that the font
550 // isn't already activated, based on the font id. If it's already
551 // activated, don't reactivate it here - crbug.com/72727 .
553 return FontLoader::CGFontRefFromBuffer(font_data, font_data_size, out);
556 #elif defined(OS_POSIX) && !defined(OS_ANDROID)
558 void RendererBlinkPlatformImpl::SandboxSupport::getFallbackFontForCharacter(
559 blink::WebUChar32 character,
560 const char* preferred_locale,
561 blink::WebFallbackFont* fallbackFont) {
562 base::AutoLock lock(unicode_font_families_mutex_);
563 const std::map<int32_t, blink::WebFallbackFont>::const_iterator iter =
564 unicode_font_families_.find(character);
565 if (iter != unicode_font_families_.end()) {
566 fallbackFont->name = iter->second.name;
567 fallbackFont->filename = iter->second.filename;
568 fallbackFont->fontconfigInterfaceId = iter->second.fontconfigInterfaceId;
569 fallbackFont->ttcIndex = iter->second.ttcIndex;
570 fallbackFont->isBold = iter->second.isBold;
571 fallbackFont->isItalic = iter->second.isItalic;
572 return;
575 GetFallbackFontForCharacter(character, preferred_locale, fallbackFont);
576 unicode_font_families_.insert(std::make_pair(character, *fallbackFont));
579 void RendererBlinkPlatformImpl::SandboxSupport::getRenderStyleForStrike(
580 const char* family,
581 int sizeAndStyle,
582 blink::WebFontRenderStyle* out) {
583 GetRenderStyleForStrike(family, sizeAndStyle, out);
586 #endif
588 //------------------------------------------------------------------------------
590 Platform::FileHandle RendererBlinkPlatformImpl::databaseOpenFile(
591 const WebString& vfs_file_name,
592 int desired_flags) {
593 return DatabaseUtil::DatabaseOpenFile(
594 vfs_file_name, desired_flags, sync_message_filter_.get());
597 int RendererBlinkPlatformImpl::databaseDeleteFile(
598 const WebString& vfs_file_name,
599 bool sync_dir) {
600 return DatabaseUtil::DatabaseDeleteFile(
601 vfs_file_name, sync_dir, sync_message_filter_.get());
604 long RendererBlinkPlatformImpl::databaseGetFileAttributes(
605 const WebString& vfs_file_name) {
606 return DatabaseUtil::DatabaseGetFileAttributes(vfs_file_name,
607 sync_message_filter_.get());
610 long long RendererBlinkPlatformImpl::databaseGetFileSize(
611 const WebString& vfs_file_name) {
612 return DatabaseUtil::DatabaseGetFileSize(vfs_file_name,
613 sync_message_filter_.get());
616 long long RendererBlinkPlatformImpl::databaseGetSpaceAvailableForOrigin(
617 const WebString& origin_identifier) {
618 return DatabaseUtil::DatabaseGetSpaceAvailable(origin_identifier,
619 sync_message_filter_.get());
622 bool RendererBlinkPlatformImpl::databaseSetFileSize(
623 const WebString& vfs_file_name, long long size) {
624 return DatabaseUtil::DatabaseSetFileSize(
625 vfs_file_name, size, sync_message_filter_.get());
628 bool RendererBlinkPlatformImpl::canAccelerate2dCanvas() {
629 RenderThreadImpl* thread = RenderThreadImpl::current();
630 GpuChannelHost* host = thread->EstablishGpuChannelSync(
631 CAUSE_FOR_GPU_LAUNCH_CANVAS_2D);
632 if (!host)
633 return false;
635 return host->gpu_info().SupportsAccelerated2dCanvas();
638 bool RendererBlinkPlatformImpl::isThreadedCompositingEnabled() {
639 RenderThreadImpl* thread = RenderThreadImpl::current();
640 // thread can be NULL in tests.
641 return thread && thread->compositor_message_loop_proxy().get();
644 double RendererBlinkPlatformImpl::audioHardwareSampleRate() {
645 RenderThreadImpl* thread = RenderThreadImpl::current();
646 return thread->GetAudioHardwareConfig()->GetOutputSampleRate();
649 size_t RendererBlinkPlatformImpl::audioHardwareBufferSize() {
650 RenderThreadImpl* thread = RenderThreadImpl::current();
651 return thread->GetAudioHardwareConfig()->GetOutputBufferSize();
654 unsigned RendererBlinkPlatformImpl::audioHardwareOutputChannels() {
655 RenderThreadImpl* thread = RenderThreadImpl::current();
656 return thread->GetAudioHardwareConfig()->GetOutputChannels();
659 WebDatabaseObserver* RendererBlinkPlatformImpl::databaseObserver() {
660 return web_database_observer_impl_.get();
663 WebAudioDevice* RendererBlinkPlatformImpl::createAudioDevice(
664 size_t buffer_size,
665 unsigned input_channels,
666 unsigned channels,
667 double sample_rate,
668 WebAudioDevice::RenderCallback* callback,
669 const blink::WebString& input_device_id) {
670 // Use a mock for testing.
671 blink::WebAudioDevice* mock_device =
672 GetContentClient()->renderer()->OverrideCreateAudioDevice(sample_rate);
673 if (mock_device)
674 return mock_device;
676 // The |channels| does not exactly identify the channel layout of the
677 // device. The switch statement below assigns a best guess to the channel
678 // layout based on number of channels.
679 // TODO(crogers): WebKit should give the channel layout instead of the hard
680 // channel count.
681 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED;
682 switch (channels) {
683 case 1:
684 layout = media::CHANNEL_LAYOUT_MONO;
685 break;
686 case 2:
687 layout = media::CHANNEL_LAYOUT_STEREO;
688 break;
689 case 3:
690 layout = media::CHANNEL_LAYOUT_2_1;
691 break;
692 case 4:
693 layout = media::CHANNEL_LAYOUT_4_0;
694 break;
695 case 5:
696 layout = media::CHANNEL_LAYOUT_5_0;
697 break;
698 case 6:
699 layout = media::CHANNEL_LAYOUT_5_1;
700 break;
701 case 7:
702 layout = media::CHANNEL_LAYOUT_7_0;
703 break;
704 case 8:
705 layout = media::CHANNEL_LAYOUT_7_1;
706 break;
707 default:
708 layout = media::CHANNEL_LAYOUT_STEREO;
711 int session_id = 0;
712 if (input_device_id.isNull() ||
713 !base::StringToInt(base::UTF16ToUTF8(input_device_id), &session_id)) {
714 if (input_channels > 0)
715 DLOG(WARNING) << "createAudioDevice(): request for audio input ignored";
717 input_channels = 0;
720 media::AudioParameters params(
721 media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
722 layout, static_cast<int>(sample_rate), 16, buffer_size,
723 media::AudioParameters::NO_EFFECTS);
725 return new RendererWebAudioDeviceImpl(params, callback, session_id);
728 #if defined(OS_ANDROID)
729 bool RendererBlinkPlatformImpl::loadAudioResource(
730 blink::WebAudioBus* destination_bus,
731 const char* audio_file_data,
732 size_t data_size) {
733 return DecodeAudioFileData(destination_bus,
734 audio_file_data,
735 data_size,
736 thread_safe_sender_);
738 #else
739 bool RendererBlinkPlatformImpl::loadAudioResource(
740 blink::WebAudioBus* destination_bus,
741 const char* audio_file_data,
742 size_t data_size) {
743 return DecodeAudioFileData(
744 destination_bus, audio_file_data, data_size);
746 #endif // defined(OS_ANDROID)
748 //------------------------------------------------------------------------------
750 blink::WebMIDIAccessor* RendererBlinkPlatformImpl::createMIDIAccessor(
751 blink::WebMIDIAccessorClient* client) {
752 blink::WebMIDIAccessor* accessor =
753 GetContentClient()->renderer()->OverrideCreateMIDIAccessor(client);
754 if (accessor)
755 return accessor;
757 return new RendererWebMIDIAccessorImpl(client);
760 void RendererBlinkPlatformImpl::getPluginList(
761 bool refresh,
762 blink::WebPluginListBuilder* builder) {
763 #if defined(ENABLE_PLUGINS)
764 std::vector<WebPluginInfo> plugins;
765 if (!plugin_refresh_allowed_)
766 refresh = false;
767 RenderThread::Get()->Send(
768 new ViewHostMsg_GetPlugins(refresh, &plugins));
769 for (size_t i = 0; i < plugins.size(); ++i) {
770 const WebPluginInfo& plugin = plugins[i];
772 builder->addPlugin(
773 plugin.name, plugin.desc,
774 plugin.path.BaseName().AsUTF16Unsafe());
776 for (size_t j = 0; j < plugin.mime_types.size(); ++j) {
777 const WebPluginMimeType& mime_type = plugin.mime_types[j];
779 builder->addMediaTypeToLastPlugin(
780 WebString::fromUTF8(mime_type.mime_type), mime_type.description);
782 for (size_t k = 0; k < mime_type.file_extensions.size(); ++k) {
783 builder->addFileExtensionToLastMediaType(
784 WebString::fromUTF8(mime_type.file_extensions[k]));
788 #endif
791 //------------------------------------------------------------------------------
793 blink::WebPublicSuffixList* RendererBlinkPlatformImpl::publicSuffixList() {
794 return &public_suffix_list_;
797 //------------------------------------------------------------------------------
799 blink::WebString RendererBlinkPlatformImpl::signedPublicKeyAndChallengeString(
800 unsigned key_size_index,
801 const blink::WebString& challenge,
802 const blink::WebURL& url) {
803 std::string signed_public_key;
804 RenderThread::Get()->Send(new ViewHostMsg_Keygen(
805 static_cast<uint32>(key_size_index),
806 challenge.utf8(),
807 GURL(url),
808 &signed_public_key));
809 return WebString::fromUTF8(signed_public_key);
812 //------------------------------------------------------------------------------
814 void RendererBlinkPlatformImpl::screenColorProfile(
815 WebVector<char>* to_profile) {
816 #if defined(OS_WIN)
817 // On Windows screen color profile is only available in the browser.
818 std::vector<char> profile;
819 // This Send() can be called from any impl-side thread. Use a thread
820 // safe send to avoid crashing trying to access RenderThread::Get(),
821 // which is not accessible from arbitrary threads.
822 thread_safe_sender_->Send(
823 new ViewHostMsg_GetMonitorColorProfile(&profile));
824 *to_profile = profile;
825 #else
826 // On other platforms, the primary monitor color profile can be read
827 // directly.
828 gfx::ColorProfile profile;
829 *to_profile = profile.profile();
830 #endif
833 //------------------------------------------------------------------------------
835 blink::WebScrollbarBehavior* RendererBlinkPlatformImpl::scrollbarBehavior() {
836 return web_scrollbar_behavior_.get();
839 //------------------------------------------------------------------------------
841 WebBlobRegistry* RendererBlinkPlatformImpl::blobRegistry() {
842 // blob_registry_ can be NULL when running some tests.
843 return blob_registry_.get();
846 //------------------------------------------------------------------------------
848 void RendererBlinkPlatformImpl::sampleGamepads(WebGamepads& gamepads) {
849 PlatformEventObserverBase* observer =
850 platform_event_observers_.Lookup(blink::WebPlatformEventGamepad);
851 if (!observer)
852 return;
853 static_cast<RendererGamepadProvider*>(observer)->SampleGamepads(gamepads);
856 //------------------------------------------------------------------------------
858 WebRTCPeerConnectionHandler*
859 RendererBlinkPlatformImpl::createRTCPeerConnectionHandler(
860 WebRTCPeerConnectionHandlerClient* client) {
861 RenderThreadImpl* render_thread = RenderThreadImpl::current();
862 DCHECK(render_thread);
863 if (!render_thread)
864 return NULL;
866 #if defined(ENABLE_WEBRTC)
867 WebRTCPeerConnectionHandler* peer_connection_handler =
868 GetContentClient()->renderer()->OverrideCreateWebRTCPeerConnectionHandler(
869 client);
870 if (peer_connection_handler)
871 return peer_connection_handler;
873 PeerConnectionDependencyFactory* rtc_dependency_factory =
874 render_thread->GetPeerConnectionDependencyFactory();
875 return rtc_dependency_factory->CreateRTCPeerConnectionHandler(client);
876 #else
877 return NULL;
878 #endif // defined(ENABLE_WEBRTC)
881 //------------------------------------------------------------------------------
883 WebMediaStreamCenter* RendererBlinkPlatformImpl::createMediaStreamCenter(
884 WebMediaStreamCenterClient* client) {
885 RenderThreadImpl* render_thread = RenderThreadImpl::current();
886 DCHECK(render_thread);
887 if (!render_thread)
888 return NULL;
889 return render_thread->CreateMediaStreamCenter(client);
892 // static
893 bool RendererBlinkPlatformImpl::SetSandboxEnabledForTesting(bool enable) {
894 bool was_enabled = g_sandbox_enabled;
895 g_sandbox_enabled = enable;
896 return was_enabled;
899 //------------------------------------------------------------------------------
901 blink::WebSpeechSynthesizer* RendererBlinkPlatformImpl::createSpeechSynthesizer(
902 blink::WebSpeechSynthesizerClient* client) {
903 return GetContentClient()->renderer()->OverrideSpeechSynthesizer(client);
906 //------------------------------------------------------------------------------
908 bool RendererBlinkPlatformImpl::processMemorySizesInBytes(
909 size_t* private_bytes,
910 size_t* shared_bytes) {
911 content::RenderThread::Get()->Send(
912 new ViewHostMsg_GetProcessMemorySizes(private_bytes, shared_bytes));
913 return true;
916 //------------------------------------------------------------------------------
918 blink::WebGraphicsContext3D*
919 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D(
920 const blink::WebGraphicsContext3D::Attributes& attributes) {
921 return createOffscreenGraphicsContext3D(attributes, NULL);
924 blink::WebGraphicsContext3D*
925 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D(
926 const blink::WebGraphicsContext3D::Attributes& attributes,
927 blink::WebGraphicsContext3D* share_context) {
928 return createOffscreenGraphicsContext3D(attributes, share_context, NULL);
931 blink::WebGraphicsContext3D*
932 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D(
933 const blink::WebGraphicsContext3D::Attributes& attributes,
934 blink::WebGraphicsContext3D* share_context,
935 blink::WebGLInfo* gl_info) {
936 if (!RenderThreadImpl::current())
937 return NULL;
939 #if defined(OS_ANDROID)
940 if (SynchronousCompositorFactory* factory =
941 SynchronousCompositorFactory::GetInstance()) {
942 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl>
943 in_process_context(
944 factory->CreateOffscreenGraphicsContext3D(attributes));
945 if (!in_process_context ||
946 !in_process_context->InitializeOnCurrentThread())
947 return NULL;
948 return in_process_context.release();
950 #endif
952 scoped_refptr<GpuChannelHost> gpu_channel_host(
953 RenderThreadImpl::current()->EstablishGpuChannelSync(
954 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
956 if (gpu_channel_host.get() && gl_info) {
957 const gpu::GPUInfo& gpu_info = gpu_channel_host->gpu_info();
958 switch (gpu_info.context_info_state) {
959 case gpu::kCollectInfoSuccess:
960 case gpu::kCollectInfoNonFatalFailure:
961 gl_info->vendorInfo.assign(
962 blink::WebString::fromUTF8(gpu_info.gl_vendor));
963 gl_info->rendererInfo.assign(
964 blink::WebString::fromUTF8(gpu_info.gl_renderer));
965 gl_info->driverVersion.assign(
966 blink::WebString::fromUTF8(gpu_info.driver_version));
967 gl_info->vendorId = gpu_info.gpu.vendor_id;
968 gl_info->deviceId = gpu_info.gpu.device_id;
969 break;
970 case gpu::kCollectInfoFatalFailure:
971 case gpu::kCollectInfoNone:
972 gl_info->contextInfoCollectionFailure.assign(blink::WebString::fromUTF8(
973 "GPUInfoCollectionFailure: GPU initialization Failed. GPU "
974 "Info not Collected."));
975 break;
976 default:
977 NOTREACHED();
981 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
982 bool lose_context_when_out_of_memory = false;
983 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
984 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
985 gpu_channel_host.get(),
986 attributes,
987 lose_context_when_out_of_memory,
988 GURL(attributes.topDocumentURL),
989 limits,
990 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context)));
992 // Most likely the GPU process exited and the attempt to reconnect to it
993 // failed. Need to try to restore the context again later.
994 if (!context || !context->InitializeOnCurrentThread())
995 return NULL;
996 return context.release();
999 //------------------------------------------------------------------------------
1001 blink::WebGraphicsContext3DProvider*
1002 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() {
1003 scoped_refptr<cc_blink::ContextProviderWebContext> provider =
1004 RenderThreadImpl::current()->SharedMainThreadContextProvider();
1005 if (!provider.get())
1006 return NULL;
1007 return new WebGraphicsContext3DProviderImpl(provider);
1010 //------------------------------------------------------------------------------
1012 blink::WebCompositorSupport* RendererBlinkPlatformImpl::compositorSupport() {
1013 return &compositor_support_;
1016 //------------------------------------------------------------------------------
1018 blink::WebString RendererBlinkPlatformImpl::convertIDNToUnicode(
1019 const blink::WebString& host,
1020 const blink::WebString& languages) {
1021 return net::IDNToUnicode(host.utf8(), languages.utf8());
1024 //------------------------------------------------------------------------------
1026 void RendererBlinkPlatformImpl::recordRappor(const char* metric,
1027 const blink::WebString& sample) {
1028 GetContentClient()->renderer()->RecordRappor(metric, sample.utf8());
1031 void RendererBlinkPlatformImpl::recordRapporURL(const char* metric,
1032 const blink::WebURL& url) {
1033 GetContentClient()->renderer()->RecordRapporURL(metric, url);
1036 //------------------------------------------------------------------------------
1038 // static
1039 void RendererBlinkPlatformImpl::SetMockDeviceLightDataForTesting(double data) {
1040 g_test_device_light_data = data;
1043 //------------------------------------------------------------------------------
1045 // static
1046 void RendererBlinkPlatformImpl::SetMockDeviceMotionDataForTesting(
1047 const blink::WebDeviceMotionData& data) {
1048 g_test_device_motion_data.Get() = data;
1051 //------------------------------------------------------------------------------
1053 // static
1054 void RendererBlinkPlatformImpl::SetMockDeviceOrientationDataForTesting(
1055 const blink::WebDeviceOrientationData& data) {
1056 g_test_device_orientation_data.Get() = data;
1059 //------------------------------------------------------------------------------
1061 void RendererBlinkPlatformImpl::vibrate(unsigned int milliseconds) {
1062 GetConnectedVibrationManagerService()->Vibrate(
1063 base::checked_cast<int64>(milliseconds));
1064 vibration_manager_.reset();
1067 void RendererBlinkPlatformImpl::cancelVibration() {
1068 GetConnectedVibrationManagerService()->Cancel();
1069 vibration_manager_.reset();
1072 device::VibrationManagerPtr&
1073 RendererBlinkPlatformImpl::GetConnectedVibrationManagerService() {
1074 if (!vibration_manager_) {
1075 RenderThread::Get()->GetServiceRegistry()
1076 ->ConnectToRemoteService(&vibration_manager_);
1078 return vibration_manager_;
1081 //------------------------------------------------------------------------------
1083 // static
1084 PlatformEventObserverBase*
1085 RendererBlinkPlatformImpl::CreatePlatformEventObserverFromType(
1086 blink::WebPlatformEventType type) {
1087 RenderThread* thread = RenderThreadImpl::current();
1089 // When running layout tests, those observers should not listen to the actual
1090 // hardware changes. In order to make that happen, they will receive a null
1091 // thread.
1092 if (thread && RenderThreadImpl::current()->layout_test_mode())
1093 thread = NULL;
1095 switch (type) {
1096 case blink::WebPlatformEventDeviceMotion:
1097 return new DeviceMotionEventPump(thread);
1098 case blink::WebPlatformEventDeviceOrientation:
1099 return new DeviceOrientationEventPump(thread);
1100 case blink::WebPlatformEventDeviceLight:
1101 return new DeviceLightEventPump(thread);
1102 case blink::WebPlatformEventGamepad:
1103 return new GamepadSharedMemoryReader(thread);
1104 case blink::WebPlatformEventScreenOrientation:
1105 return new ScreenOrientationObserver();
1106 default:
1107 // A default statement is required to prevent compilation errors when
1108 // Blink adds a new type.
1109 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with "
1110 "unknown type.";
1113 return NULL;
1116 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting(
1117 blink::WebPlatformEventType type,
1118 scoped_ptr<PlatformEventObserverBase> observer) {
1119 DCHECK(type != blink::WebPlatformEventBattery);
1121 if (platform_event_observers_.Lookup(type))
1122 platform_event_observers_.Remove(type);
1123 platform_event_observers_.AddWithID(observer.release(), type);
1126 void RendererBlinkPlatformImpl::startListening(
1127 blink::WebPlatformEventType type,
1128 blink::WebPlatformEventListener* listener) {
1129 if (type == blink::WebPlatformEventBattery) {
1130 if (RenderThreadImpl::current() &&
1131 RenderThreadImpl::current()->layout_test_mode()) {
1132 g_test_battery_status_listener =
1133 static_cast<blink::WebBatteryStatusListener*>(listener);
1134 } else {
1135 battery_status_dispatcher_.reset(new BatteryStatusDispatcher(
1136 static_cast<blink::WebBatteryStatusListener*>(listener)));
1138 return;
1141 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1142 if (!observer) {
1143 observer = CreatePlatformEventObserverFromType(type);
1144 if (!observer)
1145 return;
1146 platform_event_observers_.AddWithID(observer, static_cast<int32>(type));
1148 observer->Start(listener);
1150 // Device events (motion, orientation and light) expect to get an event fired
1151 // as soon as a listener is registered if a fake data was passed before.
1152 // TODO(mlamouri,timvolodine): make those send mock values directly instead of
1153 // using this broken pattern.
1154 if (RenderThreadImpl::current() &&
1155 RenderThreadImpl::current()->layout_test_mode() &&
1156 (type == blink::WebPlatformEventDeviceMotion ||
1157 type == blink::WebPlatformEventDeviceOrientation ||
1158 type == blink::WebPlatformEventDeviceLight)) {
1159 SendFakeDeviceEventDataForTesting(type);
1163 void RendererBlinkPlatformImpl::SendFakeDeviceEventDataForTesting(
1164 blink::WebPlatformEventType type) {
1165 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1166 CHECK(observer);
1168 void* data = 0;
1170 switch (type) {
1171 case blink::WebPlatformEventDeviceMotion:
1172 if (!(g_test_device_motion_data == 0))
1173 data = &g_test_device_motion_data.Get();
1174 break;
1175 case blink::WebPlatformEventDeviceOrientation:
1176 if (!(g_test_device_orientation_data == 0))
1177 data = &g_test_device_orientation_data.Get();
1178 break;
1179 case blink::WebPlatformEventDeviceLight:
1180 if (g_test_device_light_data >= 0)
1181 data = &g_test_device_light_data;
1182 break;
1183 default:
1184 NOTREACHED();
1185 break;
1188 if (!data)
1189 return;
1191 base::MessageLoopProxy::current()->PostTask(
1192 FROM_HERE,
1193 base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting,
1194 base::Unretained(observer), data));
1197 void RendererBlinkPlatformImpl::stopListening(
1198 blink::WebPlatformEventType type) {
1199 if (type == blink::WebPlatformEventBattery) {
1200 g_test_battery_status_listener = nullptr;
1201 battery_status_dispatcher_.reset();
1202 return;
1205 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1206 if (!observer)
1207 return;
1208 observer->Stop();
1211 //------------------------------------------------------------------------------
1213 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota(
1214 const blink::WebURL& storage_partition,
1215 blink::WebStorageQuotaType type,
1216 blink::WebStorageQuotaCallbacks callbacks) {
1217 if (!thread_safe_sender_.get() || !quota_message_filter_.get())
1218 return;
1219 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(),
1220 quota_message_filter_.get())
1221 ->QueryStorageUsageAndQuota(
1222 storage_partition,
1223 static_cast<storage::StorageType>(type),
1224 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
1227 //------------------------------------------------------------------------------
1229 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting(
1230 const blink::WebBatteryStatus& status) {
1231 if (!g_test_battery_status_listener)
1232 return;
1233 g_test_battery_status_listener->updateBatteryStatus(status);
1236 } // namespace content