Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 286793002: [DeviceLight] Add renderer+common parts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix jochen's comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_webkitplatformsupport_impl.h" 5 #include "content/renderer/renderer_webkitplatformsupport_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/logging.h" 10 #include "base/logging.h"
(...skipping 22 matching lines...) Expand all
33 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 33 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
34 #include "content/common/gpu/gpu_process_launch_causes.h" 34 #include "content/common/gpu/gpu_process_launch_causes.h"
35 #include "content/common/mime_registry_messages.h" 35 #include "content/common/mime_registry_messages.h"
36 #include "content/common/screen_orientation_messages.h" 36 #include "content/common/screen_orientation_messages.h"
37 #include "content/common/view_messages.h" 37 #include "content/common/view_messages.h"
38 #include "content/public/common/content_switches.h" 38 #include "content/public/common/content_switches.h"
39 #include "content/public/common/webplugininfo.h" 39 #include "content/public/common/webplugininfo.h"
40 #include "content/public/renderer/content_renderer_client.h" 40 #include "content/public/renderer/content_renderer_client.h"
41 #include "content/renderer/battery_status/battery_status_dispatcher.h" 41 #include "content/renderer/battery_status/battery_status_dispatcher.h"
42 #include "content/renderer/battery_status/fake_battery_status_dispatcher.h" 42 #include "content/renderer/battery_status/fake_battery_status_dispatcher.h"
43 #include "content/renderer/device_sensors/device_light_event_pump.h"
43 #include "content/renderer/device_sensors/device_motion_event_pump.h" 44 #include "content/renderer/device_sensors/device_motion_event_pump.h"
44 #include "content/renderer/device_sensors/device_orientation_event_pump.h" 45 #include "content/renderer/device_sensors/device_orientation_event_pump.h"
45 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" 46 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
46 #include "content/renderer/gamepad_shared_memory_reader.h" 47 #include "content/renderer/gamepad_shared_memory_reader.h"
47 #include "content/renderer/media/audio_decoder.h" 48 #include "content/renderer/media/audio_decoder.h"
48 #include "content/renderer/media/crypto/key_systems.h" 49 #include "content/renderer/media/crypto/key_systems.h"
49 #include "content/renderer/media/renderer_webaudiodevice_impl.h" 50 #include "content/renderer/media/renderer_webaudiodevice_impl.h"
50 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" 51 #include "content/renderer/media/renderer_webmidiaccessor_impl.h"
51 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" 52 #include "content/renderer/media/webcontentdecryptionmodule_impl.h"
52 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" 53 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
53 #include "content/renderer/render_thread_impl.h" 54 #include "content/renderer/render_thread_impl.h"
54 #include "content/renderer/renderer_clipboard_client.h" 55 #include "content/renderer/renderer_clipboard_client.h"
55 #include "content/renderer/screen_orientation/mock_screen_orientation_controller .h" 56 #include "content/renderer/screen_orientation/mock_screen_orientation_controller .h"
56 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" 57 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h"
57 #include "content/renderer/webclipboard_impl.h" 58 #include "content/renderer/webclipboard_impl.h"
58 #include "content/renderer/webgraphicscontext3d_provider_impl.h" 59 #include "content/renderer/webgraphicscontext3d_provider_impl.h"
59 #include "content/renderer/webpublicsuffixlist_impl.h" 60 #include "content/renderer/webpublicsuffixlist_impl.h"
60 #include "gpu/config/gpu_info.h" 61 #include "gpu/config/gpu_info.h"
61 #include "ipc/ipc_sync_message_filter.h" 62 #include "ipc/ipc_sync_message_filter.h"
62 #include "media/audio/audio_output_device.h" 63 #include "media/audio/audio_output_device.h"
63 #include "media/base/audio_hardware_config.h" 64 #include "media/base/audio_hardware_config.h"
64 #include "media/filters/stream_parser_factory.h" 65 #include "media/filters/stream_parser_factory.h"
65 #include "net/base/mime_util.h" 66 #include "net/base/mime_util.h"
66 #include "net/base/net_util.h" 67 #include "net/base/net_util.h"
67 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h" 68 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h"
68 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" 69 #include "third_party/WebKit/public/platform/WebBlobRegistry.h"
70 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h"
69 #include "third_party/WebKit/public/platform/WebDeviceMotionListener.h" 71 #include "third_party/WebKit/public/platform/WebDeviceMotionListener.h"
70 #include "third_party/WebKit/public/platform/WebDeviceOrientationListener.h" 72 #include "third_party/WebKit/public/platform/WebDeviceOrientationListener.h"
71 #include "third_party/WebKit/public/platform/WebFileInfo.h" 73 #include "third_party/WebKit/public/platform/WebFileInfo.h"
72 #include "third_party/WebKit/public/platform/WebGamepads.h" 74 #include "third_party/WebKit/public/platform/WebGamepads.h"
73 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" 75 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
74 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" 76 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h"
75 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" 77 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h"
76 #include "third_party/WebKit/public/platform/WebScreenOrientationListener.h" 78 #include "third_party/WebKit/public/platform/WebScreenOrientationListener.h"
77 #include "third_party/WebKit/public/platform/WebURL.h" 79 #include "third_party/WebKit/public/platform/WebURL.h"
78 #include "third_party/WebKit/public/platform/WebVector.h" 80 #include "third_party/WebKit/public/platform/WebVector.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 using blink::WebRTCPeerConnectionHandlerClient; 138 using blink::WebRTCPeerConnectionHandlerClient;
137 using blink::WebStorageNamespace; 139 using blink::WebStorageNamespace;
138 using blink::WebString; 140 using blink::WebString;
139 using blink::WebURL; 141 using blink::WebURL;
140 using blink::WebVector; 142 using blink::WebVector;
141 143
142 namespace content { 144 namespace content {
143 145
144 namespace { 146 namespace {
145 147
146 static bool g_sandbox_enabled = true; 148 bool g_sandbox_enabled = true;
147 static blink::WebGamepadListener* web_gamepad_listener = NULL; 149 blink::WebGamepadListener* web_gamepad_listener = NULL;
148 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = 150 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads =
149 LAZY_INSTANCE_INITIALIZER; 151 LAZY_INSTANCE_INITIALIZER;
152 double g_test_device_light_data = -1;
150 base::LazyInstance<blink::WebDeviceMotionData>::Leaky 153 base::LazyInstance<blink::WebDeviceMotionData>::Leaky
151 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; 154 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
152 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky 155 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
153 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; 156 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER;
154 base::LazyInstance<MockScreenOrientationController>::Leaky 157 base::LazyInstance<MockScreenOrientationController>::Leaky
155 g_test_screen_orientation_controller = LAZY_INSTANCE_INITIALIZER; 158 g_test_screen_orientation_controller = LAZY_INSTANCE_INITIALIZER;
156 base::LazyInstance<FakeBatteryStatusDispatcher>::Leaky 159 base::LazyInstance<FakeBatteryStatusDispatcher>::Leaky
157 g_test_battery_status_dispatcher = LAZY_INSTANCE_INITIALIZER; 160 g_test_battery_status_dispatcher = LAZY_INSTANCE_INITIALIZER;
158 161
159 } // namespace 162 } // namespace
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 //------------------------------------------------------------------------------ 1085 //------------------------------------------------------------------------------
1083 1086
1084 blink::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( 1087 blink::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode(
1085 const blink::WebString& host, 1088 const blink::WebString& host,
1086 const blink::WebString& languages) { 1089 const blink::WebString& languages) {
1087 return net::IDNToUnicode(host.utf8(), languages.utf8()); 1090 return net::IDNToUnicode(host.utf8(), languages.utf8());
1088 } 1091 }
1089 1092
1090 //------------------------------------------------------------------------------ 1093 //------------------------------------------------------------------------------
1091 1094
1095 void RendererWebKitPlatformSupportImpl::setDeviceLightListener(
1096 blink::WebDeviceLightListener* listener) {
1097 if (g_test_device_light_data == -1) {
dcheng 2014/06/13 17:01:34 Personally, I'd probably just make this check < 0,
riju_ 2014/06/16 10:46:30 Done.
1098 if (!device_light_event_pump_) {
1099 device_light_event_pump_.reset(new DeviceLightEventPump);
1100 device_light_event_pump_->Attach(RenderThreadImpl::current());
1101 }
1102 device_light_event_pump_->SetListener(listener);
1103 } else if (listener) {
1104 // Testing mode: just echo the test data to the listener.
1105 base::MessageLoopProxy::current()->PostTask(
1106 FROM_HERE,
1107 base::Bind(&blink::WebDeviceLightListener::didChangeDeviceLight,
1108 base::Unretained(listener),
1109 g_test_device_light_data));
1110 }
1111 }
1112
1113 // static
1114 void RendererWebKitPlatformSupportImpl::SetMockDeviceLightDataForTesting(
1115 double data) {
1116 g_test_device_light_data = data;
1117 }
1118
1119 //------------------------------------------------------------------------------
1120
1092 void RendererWebKitPlatformSupportImpl::setDeviceMotionListener( 1121 void RendererWebKitPlatformSupportImpl::setDeviceMotionListener(
1093 blink::WebDeviceMotionListener* listener) { 1122 blink::WebDeviceMotionListener* listener) {
1094 if (g_test_device_motion_data == 0) { 1123 if (g_test_device_motion_data == 0) {
1095 if (!device_motion_event_pump_) { 1124 if (!device_motion_event_pump_) {
1096 device_motion_event_pump_.reset(new DeviceMotionEventPump); 1125 device_motion_event_pump_.reset(new DeviceMotionEventPump);
1097 device_motion_event_pump_->Attach(RenderThreadImpl::current()); 1126 device_motion_event_pump_->Attach(RenderThreadImpl::current());
1098 } 1127 }
1099 device_motion_event_pump_->SetListener(listener); 1128 device_motion_event_pump_->SetListener(listener);
1100 } else if (listener) { 1129 } else if (listener) {
1101 // Testing mode: just echo the test data to the listener. 1130 // Testing mode: just echo the test data to the listener.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 battery_status_dispatcher_->SetListener(listener); 1282 battery_status_dispatcher_->SetListener(listener);
1254 } 1283 }
1255 1284
1256 // static 1285 // static
1257 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( 1286 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting(
1258 const blink::WebBatteryStatus& status) { 1287 const blink::WebBatteryStatus& status) {
1259 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status); 1288 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status);
1260 } 1289 }
1261 1290
1262 } // namespace content 1291 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698