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

Side by Side Diff: Source/modules/gamepad/NavigatorGamepad.cpp

Issue 582363002: Remove Gamepad runtime flag (status=stable) for blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 17 matching lines...) Expand all
28 28
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/frame/LocalDOMWindow.h" 30 #include "core/frame/LocalDOMWindow.h"
31 #include "core/frame/LocalFrame.h" 31 #include "core/frame/LocalFrame.h"
32 #include "core/frame/Navigator.h" 32 #include "core/frame/Navigator.h"
33 #include "core/page/Page.h" 33 #include "core/page/Page.h"
34 #include "modules/gamepad/GamepadDispatcher.h" 34 #include "modules/gamepad/GamepadDispatcher.h"
35 #include "modules/gamepad/GamepadEvent.h" 35 #include "modules/gamepad/GamepadEvent.h"
36 #include "modules/gamepad/GamepadList.h" 36 #include "modules/gamepad/GamepadList.h"
37 #include "modules/gamepad/WebKitGamepadList.h" 37 #include "modules/gamepad/WebKitGamepadList.h"
38 #include "platform/RuntimeEnabledFeatures.h"
39 38
40 namespace blink { 39 namespace blink {
41 40
42 template<typename T> 41 template<typename T>
43 static void sampleGamepad(unsigned index, T& gamepad, const WebGamepad& webGamep ad) 42 static void sampleGamepad(unsigned index, T& gamepad, const WebGamepad& webGamep ad)
44 { 43 {
45 gamepad.setId(webGamepad.id); 44 gamepad.setId(webGamepad.id);
46 gamepad.setIndex(index); 45 gamepad.setIndex(index);
47 gamepad.setConnected(webGamepad.connected); 46 gamepad.setConnected(webGamepad.connected);
48 gamepad.setTimestamp(webGamepad.timestamp); 47 gamepad.setTimestamp(webGamepad.timestamp);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 return false; 220 return false;
222 } 221 }
223 222
224 static bool isGamepadEvent(const AtomicString& eventType) 223 static bool isGamepadEvent(const AtomicString& eventType)
225 { 224 {
226 return eventType == EventTypeNames::gamepadconnected || eventType == EventTy peNames::gamepaddisconnected; 225 return eventType == EventTypeNames::gamepadconnected || eventType == EventTy peNames::gamepaddisconnected;
227 } 226 }
228 227
229 void NavigatorGamepad::didAddEventListener(LocalDOMWindow*, const AtomicString& eventType) 228 void NavigatorGamepad::didAddEventListener(LocalDOMWindow*, const AtomicString& eventType)
230 { 229 {
231 if (RuntimeEnabledFeatures::gamepadEnabled() && isGamepadEvent(eventType)) { 230 if (isGamepadEvent(eventType)) {
232 if (page() && page()->visibilityState() == PageVisibilityStateVisible) 231 if (page() && page()->visibilityState() == PageVisibilityStateVisible)
233 startUpdating(); 232 startUpdating();
234 m_hasEventListener = true; 233 m_hasEventListener = true;
235 } 234 }
236 } 235 }
237 236
238 void NavigatorGamepad::didRemoveEventListener(LocalDOMWindow* window, const Atom icString& eventType) 237 void NavigatorGamepad::didRemoveEventListener(LocalDOMWindow* window, const Atom icString& eventType)
239 { 238 {
240 if (isGamepadEvent(eventType) 239 if (isGamepadEvent(eventType)
241 && !window->hasEventListeners(EventTypeNames::gamepadconnected) 240 && !window->hasEventListeners(EventTypeNames::gamepadconnected)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { 287 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) {
289 m_pendingEvents.append(newGamepad); 288 m_pendingEvents.append(newGamepad);
290 } 289 }
291 } 290 }
292 291
293 if (!m_pendingEvents.isEmpty()) 292 if (!m_pendingEvents.isEmpty())
294 m_dispatchOneEventRunner.runAsync(); 293 m_dispatchOneEventRunner.runAsync();
295 } 294 }
296 295
297 } // namespace blink 296 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/modules/gamepad/NavigatorGamepad.idl » ('j') | Source/web/FrameLoaderClientImpl.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698