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

Side by Side Diff: Source/core/frame/DOMWindow.cpp

Issue 200783002: Gamepad API: add support for gamepadconnected and gamepaddisconnected events (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 #include "platform/graphics/media/MediaPlayer.h" 98 #include "platform/graphics/media/MediaPlayer.h"
99 #include "platform/weborigin/KURL.h" 99 #include "platform/weborigin/KURL.h"
100 #include "platform/weborigin/SecurityOrigin.h" 100 #include "platform/weborigin/SecurityOrigin.h"
101 #include "platform/weborigin/SecurityPolicy.h" 101 #include "platform/weborigin/SecurityPolicy.h"
102 #include "public/platform/Platform.h" 102 #include "public/platform/Platform.h"
103 #include "wtf/MainThread.h" 103 #include "wtf/MainThread.h"
104 #include "wtf/MathExtras.h" 104 #include "wtf/MathExtras.h"
105 #include "wtf/text/WTFString.h" 105 #include "wtf/text/WTFString.h"
106 #include <algorithm> 106 #include <algorithm>
107 107
108 // FIXME: this is a layering vilation.
Inactive 2014/03/14 19:46:08 Yes, we don't want that :)
kbalazs 2014/03/14 23:51:27 Done.
109 #include "modules/gamepad/NavigatorGamepad.h"
110
108 using std::min; 111 using std::min;
109 using std::max; 112 using std::max;
110 113
111 namespace WebCore { 114 namespace WebCore {
112 115
113 class PostMessageTimer FINAL : public SuspendableTimer { 116 class PostMessageTimer FINAL : public SuspendableTimer {
114 public: 117 public:
115 PostMessageTimer(DOMWindow& window, PassRefPtr<SerializedScriptValue> messag e, const String& sourceOrigin, PassRefPtr<DOMWindow> source, PassOwnPtr<MessageP ortChannelArray> channels, SecurityOrigin* targetOrigin, PassRefPtr<ScriptCallSt ack> stackTrace) 118 PostMessageTimer(DOMWindow& window, PassRefPtr<SerializedScriptValue> messag e, const String& sourceOrigin, PassRefPtr<DOMWindow> source, PassOwnPtr<MessageP ortChannelArray> channels, SecurityOrigin* targetOrigin, PassRefPtr<ScriptCallSt ack> stackTrace)
116 : SuspendableTimer(window.document()) 119 : SuspendableTimer(window.document())
117 , m_window(window) 120 , m_window(window)
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered ); 1514 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered );
1512 if (allowsBeforeUnloadListeners(this)) { 1515 if (allowsBeforeUnloadListeners(this)) {
1513 // This is confusingly named. It doesn't actually add the listener. It just increments a count 1516 // This is confusingly named. It doesn't actually add the listener. It just increments a count
1514 // so that we know we have listeners registered for the purposes of determining if we can 1517 // so that we know we have listeners registered for the purposes of determining if we can
1515 // fast terminate the renderer process. 1518 // fast terminate the renderer process.
1516 addBeforeUnloadEventListener(this); 1519 addBeforeUnloadEventListener(this);
1517 } else { 1520 } else {
1518 // Subframes return false from allowsBeforeUnloadListeners. 1521 // Subframes return false from allowsBeforeUnloadListeners.
1519 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered); 1522 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered);
1520 } 1523 }
1524 } else if (eventType == EventTypeNames::gamepadconnected || eventType == Eve ntTypeNames::gamepaddisconnected) {
sof 2014/03/14 20:52:43 Just above these special cases, DOMWindow observer
kbalazs 2014/03/14 23:51:27 Wonderful, thanks. Together with FrameLoaderClient
1525 // If an event listener is added for gamepad events sample the gamepads once to start monitoring gamepad state.
1526 // FIXME: we need to instantiate NavigatorGamepad here so that it can li sten to the events.
1527 // Otherwise it would only be created when js calls getGamepads() or web kitGetGamepads() and we cannot assume that
1528 // it will happen before a gamepad is connected. But this is a layering violation because NavigatorGamepad lives
1529 // in modules.
1530 NavigatorGamepad::getGamepads(navigator());
Inactive 2014/03/14 19:46:08 You should probably take a look at FrameLoaderClie
kbalazs 2014/03/14 23:51:27 Done.
1521 } 1531 }
1522 1532
1523 return true; 1533 return true;
1524 } 1534 }
1525 1535
1526 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener * listener, bool useCapture) 1536 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener * listener, bool useCapture)
1527 { 1537 {
1528 if (!EventTarget::removeEventListener(eventType, listener, useCapture)) 1538 if (!EventTarget::removeEventListener(eventType, listener, useCapture))
1529 return false; 1539 return false;
1530 1540
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>: :lifecycleNotifier()); 1824 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>: :lifecycleNotifier());
1815 } 1825 }
1816 1826
1817 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() 1827 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier()
1818 { 1828 {
1819 return DOMWindowLifecycleNotifier::create(this); 1829 return DOMWindowLifecycleNotifier::create(this);
1820 } 1830 }
1821 1831
1822 1832
1823 } // namespace WebCore 1833 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698