| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/media/midi_dispatcher.h" | 5 #include "content/renderer/media/midi_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/public/common/service_registry.h" | |
| 9 #include "content/public/renderer/render_frame.h" | 8 #include "content/public/renderer/render_frame.h" |
| 9 #include "services/shell/public/cpp/interface_provider.h" |
| 10 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 10 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 11 #include "third_party/WebKit/public/platform/WebString.h" | 11 #include "third_party/WebKit/public/platform/WebString.h" |
| 12 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 12 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 13 #include "third_party/WebKit/public/web/modules/webmidi/WebMIDIOptions.h" | 13 #include "third_party/WebKit/public/web/modules/webmidi/WebMIDIOptions.h" |
| 14 #include "third_party/WebKit/public/web/modules/webmidi/WebMIDIPermissionRequest
.h" | 14 #include "third_party/WebKit/public/web/modules/webmidi/WebMIDIPermissionRequest
.h" |
| 15 | 15 |
| 16 using blink::WebMIDIPermissionRequest; | 16 using blink::WebMIDIPermissionRequest; |
| 17 using blink::WebMIDIOptions; | 17 using blink::WebMIDIOptions; |
| 18 using blink::WebSecurityOrigin; | 18 using blink::WebSecurityOrigin; |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 MidiDispatcher::MidiDispatcher(RenderFrame* render_frame) | 22 MidiDispatcher::MidiDispatcher(RenderFrame* render_frame) |
| 23 : RenderFrameObserver(render_frame) { | 23 : RenderFrameObserver(render_frame) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 MidiDispatcher::~MidiDispatcher() {} | 26 MidiDispatcher::~MidiDispatcher() {} |
| 27 | 27 |
| 28 void MidiDispatcher::OnDestruct() { | 28 void MidiDispatcher::OnDestruct() { |
| 29 delete this; | 29 delete this; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void MidiDispatcher::requestPermission(const WebMIDIPermissionRequest& request, | 32 void MidiDispatcher::requestPermission(const WebMIDIPermissionRequest& request, |
| 33 const WebMIDIOptions& options) { | 33 const WebMIDIOptions& options) { |
| 34 if (!permission_service_.get()) { | 34 if (!permission_service_.get()) |
| 35 render_frame()->GetServiceRegistry()->ConnectToRemoteService( | 35 render_frame()->GetRemoteInterfaces()->GetInterface(&permission_service_); |
| 36 mojo::GetProxy(&permission_service_)); | |
| 37 } | |
| 38 | 36 |
| 39 int permission_request_id = | 37 int permission_request_id = |
| 40 requests_.Add(new WebMIDIPermissionRequest(request)); | 38 requests_.Add(new WebMIDIPermissionRequest(request)); |
| 41 | 39 |
| 42 blink::mojom::PermissionName permission_name = | 40 blink::mojom::PermissionName permission_name = |
| 43 (options.sysex == WebMIDIOptions::SysexPermission::WithSysex) | 41 (options.sysex == WebMIDIOptions::SysexPermission::WithSysex) |
| 44 ? blink::mojom::PermissionName::MIDI_SYSEX | 42 ? blink::mojom::PermissionName::MIDI_SYSEX |
| 45 : blink::mojom::PermissionName::MIDI; | 43 : blink::mojom::PermissionName::MIDI; |
| 46 | 44 |
| 47 permission_service_->RequestPermission( | 45 permission_service_->RequestPermission( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 66 blink::mojom::PermissionStatus status) { | 64 blink::mojom::PermissionStatus status) { |
| 67 // |request| can be NULL when the request is canceled. | 65 // |request| can be NULL when the request is canceled. |
| 68 WebMIDIPermissionRequest* request = requests_.Lookup(request_id); | 66 WebMIDIPermissionRequest* request = requests_.Lookup(request_id); |
| 69 if (!request) | 67 if (!request) |
| 70 return; | 68 return; |
| 71 request->setIsAllowed(status == blink::mojom::PermissionStatus::GRANTED); | 69 request->setIsAllowed(status == blink::mojom::PermissionStatus::GRANTED); |
| 72 requests_.Remove(request_id); | 70 requests_.Remove(request_id); |
| 73 } | 71 } |
| 74 | 72 |
| 75 } // namespace content | 73 } // namespace content |
| OLD | NEW |