Commit 6814dc1a authored by reillyg@chromium.org's avatar reillyg@chromium.org

Add USBConnectionEvent to webusb module.

This is the object passed to onconnected and ondisconnected event
handlers connected to navigator.usb.

BUG=492204

Review URL: https://codereview.chromium.org/1307483002

git-svn-id: svn://svn.chromium.org/blink/trunk@200935 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 03c21ed1
......@@ -5503,6 +5503,9 @@ interface USBConfiguration
getter configurationValue
getter interfaces
method constructor
interface USBConnectionEvent
getter device
method constructor
interface USBDevice
getter configurations
getter deviceClass
......
......@@ -294,6 +294,7 @@
'webusb/USBAlternateInterface.idl',
'webusb/USBEndpoint.idl',
'webusb/USBConfiguration.idl',
'webusb/USBConnectionEvent.idl',
'webusb/USBDevice.idl',
'webusb/USBInterface.idl',
],
......@@ -474,6 +475,7 @@
'webmidi/MIDIMessageEventInit.idl',
'webmidi/MIDIOptions.idl',
'websockets/CloseEventInit.idl',
'webusb/USBConnectionEventInit.idl',
'webusb/USBDeviceRequestOptions.idl',
'webusb/USBDeviceFilter.idl',
],
......@@ -615,6 +617,8 @@
'<(blink_modules_output_dir)/webmidi/MIDIOptions.h',
'<(blink_modules_output_dir)/websockets/CloseEventInit.cpp',
'<(blink_modules_output_dir)/websockets/CloseEventInit.h',
'<(blink_modules_output_dir)/webusb/USBConnectionEventInit.cpp',
'<(blink_modules_output_dir)/webusb/USBConnectionEventInit.h',
'<(blink_modules_output_dir)/webusb/USBDeviceFilter.cpp',
'<(blink_modules_output_dir)/webusb/USBDeviceFilter.h',
'<(blink_modules_output_dir)/webusb/USBDeviceRequestOptions.cpp',
......@@ -1711,6 +1715,8 @@
'webusb/USBAlternateInterface.h',
'webusb/USBConfiguration.cpp',
'webusb/USBConfiguration.h',
'webusb/USBConnectionEvent.cpp',
'webusb/USBConnectionEvent.h',
'webusb/USBController.cpp',
'webusb/USBController.h',
'webusb/USBDevice.cpp',
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "modules/webusb/USBConnectionEvent.h"
#include "modules/webusb/USBConnectionEventInit.h"
#include "modules/webusb/USBDevice.h"
namespace blink {
USBConnectionEvent* USBConnectionEvent::create(const AtomicString& type, const USBConnectionEventInit& initializer)
{
return new USBConnectionEvent(type, initializer);
}
USBConnectionEvent* USBConnectionEvent::create(const AtomicString& type, USBDevice* device)
{
return new USBConnectionEvent(type, device);
}
USBConnectionEvent::USBConnectionEvent(const AtomicString& type, const USBConnectionEventInit& initializer)
: Event(type, initializer)
, m_device(nullptr)
{
if (initializer.hasDevice())
m_device = initializer.device();
}
USBConnectionEvent::USBConnectionEvent(const AtomicString& type, USBDevice* device)
: Event(type, false, false)
, m_device(device)
{
}
DEFINE_TRACE(USBConnectionEvent)
{
visitor->trace(m_device);
Event::trace(visitor);
}
} // namespace blink
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef USBConnectionEvent_h
#define USBConnectionEvent_h
#include "modules/EventModules.h"
#include "platform/heap/Handle.h"
namespace blink {
class USBConnectionEventInit;
class USBDevice;
class USBConnectionEvent final : public Event {
DEFINE_WRAPPERTYPEINFO();
public:
static USBConnectionEvent* create(const AtomicString& type, const USBConnectionEventInit&);
static USBConnectionEvent* create(const AtomicString& type, USBDevice*);
USBConnectionEvent(const AtomicString& type, const USBConnectionEventInit&);
USBConnectionEvent(const AtomicString& type, USBDevice*);
USBDevice* device() const { return m_device; }
DECLARE_VIRTUAL_TRACE();
private:
PersistentWillBeMember<USBDevice> m_device;
};
} // namespace blink
#endif // USBConnectionEvent_h
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// http://reillyeon.github.io/webusb/#events
[
Constructor(DOMString type, optional USBConnectionEventInit eventInitDict),
RuntimeEnabled=WebUSB,
] interface USBConnectionEvent : Event {
readonly attribute USBDevice device;
};
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// http://reillyeon.github.io/webusb/#events
dictionary USBConnectionEventInit : EventInit {
USBDevice device;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment