| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/renderer_blink_platform_impl.h" | 5 #include "content/renderer/renderer_blink_platform_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 #if !defined(OS_ANDROID) && !defined(OS_WIN) | 205 #if !defined(OS_ANDROID) && !defined(OS_WIN) |
| 206 class RendererBlinkPlatformImpl::SandboxSupport | 206 class RendererBlinkPlatformImpl::SandboxSupport |
| 207 : public blink::WebSandboxSupport { | 207 : public blink::WebSandboxSupport { |
| 208 public: | 208 public: |
| 209 virtual ~SandboxSupport() {} | 209 virtual ~SandboxSupport() {} |
| 210 | 210 |
| 211 #if defined(OS_MACOSX) | 211 #if defined(OS_MACOSX) |
| 212 bool loadFont(NSFont* src_font, | 212 bool loadFont(NSFont* src_font, |
| 213 CGFontRef* container, | 213 CGFontRef* container, |
| 214 uint32* font_id) override; | 214 uint32_t* font_id) override; |
| 215 #elif defined(OS_POSIX) | 215 #elif defined(OS_POSIX) |
| 216 void getFallbackFontForCharacter( | 216 void getFallbackFontForCharacter( |
| 217 blink::WebUChar32 character, | 217 blink::WebUChar32 character, |
| 218 const char* preferred_locale, | 218 const char* preferred_locale, |
| 219 blink::WebFallbackFont* fallbackFont) override; | 219 blink::WebFallbackFont* fallbackFont) override; |
| 220 void getRenderStyleForStrike(const char* family, | 220 void getRenderStyleForStrike(const char* family, |
| 221 int sizeAndStyle, | 221 int sizeAndStyle, |
| 222 blink::WebFontRenderStyle* out) override; | 222 blink::WebFontRenderStyle* out) override; |
| 223 | 223 |
| 224 private: | 224 private: |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 WebMessagePortChannelImpl::CreatePair( | 380 WebMessagePortChannelImpl::CreatePair( |
| 381 default_task_runner_, channel1, channel2); | 381 default_task_runner_, channel1, channel2); |
| 382 } | 382 } |
| 383 | 383 |
| 384 blink::WebPrescientNetworking* | 384 blink::WebPrescientNetworking* |
| 385 RendererBlinkPlatformImpl::prescientNetworking() { | 385 RendererBlinkPlatformImpl::prescientNetworking() { |
| 386 return GetContentClient()->renderer()->GetPrescientNetworking(); | 386 return GetContentClient()->renderer()->GetPrescientNetworking(); |
| 387 } | 387 } |
| 388 | 388 |
| 389 void RendererBlinkPlatformImpl::cacheMetadata(const blink::WebURL& url, | 389 void RendererBlinkPlatformImpl::cacheMetadata(const blink::WebURL& url, |
| 390 int64 response_time, | 390 int64_t response_time, |
| 391 const char* data, | 391 const char* data, |
| 392 size_t size) { | 392 size_t size) { |
| 393 // Let the browser know we generated cacheable metadata for this resource. The | 393 // Let the browser know we generated cacheable metadata for this resource. The |
| 394 // browser may cache it and return it on subsequent responses to speed | 394 // browser may cache it and return it on subsequent responses to speed |
| 395 // the processing of this resource. | 395 // the processing of this resource. |
| 396 std::vector<char> copy(data, data + size); | 396 std::vector<char> copy(data, data + size); |
| 397 RenderThread::Get()->Send( | 397 RenderThread::Get()->Send( |
| 398 new RenderProcessHostMsg_DidGenerateCacheableMetadata( | 398 new RenderProcessHostMsg_DidGenerateCacheableMetadata( |
| 399 url, base::Time::FromInternalValue(response_time), copy)); | 399 url, base::Time::FromInternalValue(response_time), copy)); |
| 400 } | 400 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 UMA_HISTOGRAM_TIMES("RendererSyncIPC.ElapsedTime", delta); | 537 UMA_HISTOGRAM_TIMES("RendererSyncIPC.ElapsedTime", delta); |
| 538 return success; | 538 return success; |
| 539 } | 539 } |
| 540 | 540 |
| 541 //------------------------------------------------------------------------------ | 541 //------------------------------------------------------------------------------ |
| 542 | 542 |
| 543 #if defined(OS_MACOSX) | 543 #if defined(OS_MACOSX) |
| 544 | 544 |
| 545 bool RendererBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font, | 545 bool RendererBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font, |
| 546 CGFontRef* out, | 546 CGFontRef* out, |
| 547 uint32* font_id) { | 547 uint32_t* font_id) { |
| 548 uint32 font_data_size; | 548 uint32_t font_data_size; |
| 549 FontDescriptor src_font_descriptor(src_font); | 549 FontDescriptor src_font_descriptor(src_font); |
| 550 base::SharedMemoryHandle font_data; | 550 base::SharedMemoryHandle font_data; |
| 551 if (!RenderThread::Get()->Send(new RenderProcessHostMsg_LoadFont( | 551 if (!RenderThread::Get()->Send(new RenderProcessHostMsg_LoadFont( |
| 552 src_font_descriptor, &font_data_size, &font_data, font_id))) { | 552 src_font_descriptor, &font_data_size, &font_data, font_id))) { |
| 553 *out = NULL; | 553 *out = NULL; |
| 554 *font_id = 0; | 554 *font_id = 0; |
| 555 return false; | 555 return false; |
| 556 } | 556 } |
| 557 | 557 |
| 558 if (font_data_size == 0 || font_data == base::SharedMemory::NULLHandle() || | 558 if (font_data_size == 0 || font_data == base::SharedMemory::NULLHandle() || |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 } | 816 } |
| 817 | 817 |
| 818 //------------------------------------------------------------------------------ | 818 //------------------------------------------------------------------------------ |
| 819 | 819 |
| 820 blink::WebString RendererBlinkPlatformImpl::signedPublicKeyAndChallengeString( | 820 blink::WebString RendererBlinkPlatformImpl::signedPublicKeyAndChallengeString( |
| 821 unsigned key_size_index, | 821 unsigned key_size_index, |
| 822 const blink::WebString& challenge, | 822 const blink::WebString& challenge, |
| 823 const blink::WebURL& url) { | 823 const blink::WebURL& url) { |
| 824 std::string signed_public_key; | 824 std::string signed_public_key; |
| 825 RenderThread::Get()->Send(new RenderProcessHostMsg_Keygen( | 825 RenderThread::Get()->Send(new RenderProcessHostMsg_Keygen( |
| 826 static_cast<uint32>(key_size_index), | 826 static_cast<uint32_t>(key_size_index), challenge.utf8(), GURL(url), |
| 827 challenge.utf8(), | |
| 828 GURL(url), | |
| 829 &signed_public_key)); | 827 &signed_public_key)); |
| 830 return WebString::fromUTF8(signed_public_key); | 828 return WebString::fromUTF8(signed_public_key); |
| 831 } | 829 } |
| 832 | 830 |
| 833 //------------------------------------------------------------------------------ | 831 //------------------------------------------------------------------------------ |
| 834 | 832 |
| 835 void RendererBlinkPlatformImpl::screenColorProfile( | 833 void RendererBlinkPlatformImpl::screenColorProfile( |
| 836 WebVector<char>* to_profile) { | 834 WebVector<char>* to_profile) { |
| 837 #if defined(OS_WIN) | 835 #if defined(OS_WIN) |
| 838 // On Windows screen color profile is only available in the browser. | 836 // On Windows screen color profile is only available in the browser. |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 // static | 1109 // static |
| 1112 void RendererBlinkPlatformImpl::SetMockDeviceOrientationDataForTesting( | 1110 void RendererBlinkPlatformImpl::SetMockDeviceOrientationDataForTesting( |
| 1113 const blink::WebDeviceOrientationData& data) { | 1111 const blink::WebDeviceOrientationData& data) { |
| 1114 g_test_device_orientation_data.Get() = data; | 1112 g_test_device_orientation_data.Get() = data; |
| 1115 } | 1113 } |
| 1116 | 1114 |
| 1117 //------------------------------------------------------------------------------ | 1115 //------------------------------------------------------------------------------ |
| 1118 | 1116 |
| 1119 void RendererBlinkPlatformImpl::vibrate(unsigned int milliseconds) { | 1117 void RendererBlinkPlatformImpl::vibrate(unsigned int milliseconds) { |
| 1120 GetConnectedVibrationManagerService()->Vibrate( | 1118 GetConnectedVibrationManagerService()->Vibrate( |
| 1121 base::checked_cast<int64>(milliseconds)); | 1119 base::checked_cast<int64_t>(milliseconds)); |
| 1122 vibration_manager_.reset(); | 1120 vibration_manager_.reset(); |
| 1123 } | 1121 } |
| 1124 | 1122 |
| 1125 void RendererBlinkPlatformImpl::cancelVibration() { | 1123 void RendererBlinkPlatformImpl::cancelVibration() { |
| 1126 GetConnectedVibrationManagerService()->Cancel(); | 1124 GetConnectedVibrationManagerService()->Cancel(); |
| 1127 vibration_manager_.reset(); | 1125 vibration_manager_.reset(); |
| 1128 } | 1126 } |
| 1129 | 1127 |
| 1130 device::VibrationManagerPtr& | 1128 device::VibrationManagerPtr& |
| 1131 RendererBlinkPlatformImpl::GetConnectedVibrationManagerService() { | 1129 RendererBlinkPlatformImpl::GetConnectedVibrationManagerService() { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 static_cast<blink::WebBatteryStatusListener*>(listener))); | 1194 static_cast<blink::WebBatteryStatusListener*>(listener))); |
| 1197 } | 1195 } |
| 1198 return; | 1196 return; |
| 1199 } | 1197 } |
| 1200 | 1198 |
| 1201 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); | 1199 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); |
| 1202 if (!observer) { | 1200 if (!observer) { |
| 1203 observer = CreatePlatformEventObserverFromType(type); | 1201 observer = CreatePlatformEventObserverFromType(type); |
| 1204 if (!observer) | 1202 if (!observer) |
| 1205 return; | 1203 return; |
| 1206 platform_event_observers_.AddWithID(observer, static_cast<int32>(type)); | 1204 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type)); |
| 1207 } | 1205 } |
| 1208 observer->Start(listener); | 1206 observer->Start(listener); |
| 1209 | 1207 |
| 1210 // Device events (motion, orientation and light) expect to get an event fired | 1208 // Device events (motion, orientation and light) expect to get an event fired |
| 1211 // as soon as a listener is registered if a fake data was passed before. | 1209 // as soon as a listener is registered if a fake data was passed before. |
| 1212 // TODO(mlamouri,timvolodine): make those send mock values directly instead of | 1210 // TODO(mlamouri,timvolodine): make those send mock values directly instead of |
| 1213 // using this broken pattern. | 1211 // using this broken pattern. |
| 1214 if (RenderThreadImpl::current() && | 1212 if (RenderThreadImpl::current() && |
| 1215 RenderThreadImpl::current()->layout_test_mode() && | 1213 RenderThreadImpl::current()->layout_test_mode() && |
| 1216 (type == blink::WebPlatformEventTypeDeviceMotion || | 1214 (type == blink::WebPlatformEventTypeDeviceMotion || |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 //------------------------------------------------------------------------------ | 1286 //------------------------------------------------------------------------------ |
| 1289 | 1287 |
| 1290 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( | 1288 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( |
| 1291 const blink::WebBatteryStatus& status) { | 1289 const blink::WebBatteryStatus& status) { |
| 1292 if (!g_test_battery_status_listener) | 1290 if (!g_test_battery_status_listener) |
| 1293 return; | 1291 return; |
| 1294 g_test_battery_status_listener->updateBatteryStatus(status); | 1292 g_test_battery_status_listener->updateBatteryStatus(status); |
| 1295 } | 1293 } |
| 1296 | 1294 |
| 1297 } // namespace content | 1295 } // namespace content |
| OLD | NEW |