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

Unified Diff: content/renderer/media/midi_message_filter.cc

Issue 664853003: Web MIDI: notify JavaScript of device connection events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ports.notify
Patch Set: rebase and address comments Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/midi_message_filter.cc
diff --git a/content/renderer/media/midi_message_filter.cc b/content/renderer/media/midi_message_filter.cc
index 258d04d615aee60f892f2e2a72a49a3377b8c206..1f866ad59ffac1366da04f4b1aa5386dd43471a9 100644
--- a/content/renderer/media/midi_message_filter.cc
+++ b/content/renderer/media/midi_message_filter.cc
@@ -230,8 +230,9 @@ void MidiMessageFilter::HandleClientAdded(media::MidiResult result) {
for (blink::WebMIDIAccessorClient* client : clients_waiting_session_queue_) {
if (result == media::MIDI_OK) {
// Add the client's input and output ports.
- const bool active = true;
for (const auto& info : inputs_) {
+ // TODO(toyoshim): Update blink to support complete MIDIPortState.
+ const bool active = info.state != media::MIDI_PORT_DISCONNECTED;
client->didAddInputPort(
base::UTF8ToUTF16(info.id),
base::UTF8ToUTF16(info.manufacturer),
@@ -241,6 +242,8 @@ void MidiMessageFilter::HandleClientAdded(media::MidiResult result) {
}
for (const auto& info : outputs_) {
+ // TODO(toyoshim): Update blink to support complete MIDIPortState.
+ const bool active = info.state != media::MIDI_PORT_DISCONNECTED;
client->didAddOutputPort(
base::UTF8ToUTF16(info.id),
base::UTF8ToUTF16(info.manufacturer),
@@ -258,13 +261,27 @@ void MidiMessageFilter::HandleClientAdded(media::MidiResult result) {
void MidiMessageFilter::HandleAddInputPort(media::MidiPortInfo info) {
DCHECK(main_message_loop_->BelongsToCurrentThread());
inputs_.push_back(info);
- // TODO(toyoshim): Notify to clients that were already added.
+ const base::string16 id = base::UTF8ToUTF16(info.id);
+ const base::string16 manufacturer = base::UTF8ToUTF16(info.manufacturer);
+ const base::string16 name = base::UTF8ToUTF16(info.name);
+ const base::string16 version = base::UTF8ToUTF16(info.version);
+ // TODO(toyoshim): Update blink to support complete MIDIPortState.
+ const bool active = info.state != media::MIDI_PORT_DISCONNECTED;
+ for (auto client : clients_)
+ client->didAddInputPort(id, manufacturer, name, version, active);
}
void MidiMessageFilter::HandleAddOutputPort(media::MidiPortInfo info) {
DCHECK(main_message_loop_->BelongsToCurrentThread());
outputs_.push_back(info);
- // TODO(toyoshim): Notify to clients that were already added.
+ const base::string16 id = base::UTF8ToUTF16(info.id);
+ const base::string16 manufacturer = base::UTF8ToUTF16(info.manufacturer);
+ const base::string16 name = base::UTF8ToUTF16(info.name);
+ const base::string16 version = base::UTF8ToUTF16(info.version);
+ // TODO(toyoshim): Update blink to support complete MIDIPortState.
+ const bool active = info.state != media::MIDI_PORT_DISCONNECTED;
+ for (auto client : clients_)
+ client->didAddOutputPort(id, manufacturer, name, version, active);
}
void MidiMessageFilter::HandleDataReceived(uint32 port,
@@ -289,14 +306,20 @@ void MidiMessageFilter::HandleSetInputPortState(uint32 port,
media::MidiPortState state) {
DCHECK(main_message_loop_->BelongsToCurrentThread());
inputs_[port].state = state;
- // TODO(toyoshim): Notify to all clients.
+ // TODO(toyoshim): Update blink to support complete MIDIPortState.
+ const bool active = state != media::MIDI_PORT_DISCONNECTED;
+ for (auto client : clients_)
+ client->didSetInputPortState(port, active);
}
void MidiMessageFilter::HandleSetOutputPortState(uint32 port,
media::MidiPortState state) {
DCHECK(main_message_loop_->BelongsToCurrentThread());
outputs_[port].state = state;
- // TODO(toyoshim): Notify to all clients.
+ // TODO(toyoshim): Update blink to support complete MIDIPortState.
+ const bool active = state != media::MIDI_PORT_DISCONNECTED;
+ for (auto client : clients_)
+ client->didSetOutputPortState(port, active);
}
} // namespace content
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698