| 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" | 8 #include "content/public/common/service_registry.h" |
| 9 #include "content/public/renderer/render_frame.h" | 9 #include "content/public/renderer/render_frame.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/modules/webmidi/WebMIDIOptions.h" | 12 #include "third_party/WebKit/public/web/modules/webmidi/WebMIDIOptions.h" |
| 13 #include "third_party/WebKit/public/web/modules/webmidi/WebMIDIPermissionRequest
.h" | 13 #include "third_party/WebKit/public/web/modules/webmidi/WebMIDIPermissionRequest
.h" |
| 14 | 14 |
| 15 using blink::WebMIDIPermissionRequest; | 15 using blink::WebMIDIPermissionRequest; |
| 16 using blink::WebMIDIOptions; | 16 using blink::WebMIDIOptions; |
| 17 using blink::WebSecurityOrigin; | 17 using blink::WebSecurityOrigin; |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 MidiDispatcher::MidiDispatcher(RenderFrame* render_frame) | 21 MidiDispatcher::MidiDispatcher(RenderFrame* render_frame) |
| 22 : RenderFrameObserver(render_frame) { | 22 : RenderFrameObserver(render_frame) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 MidiDispatcher::~MidiDispatcher() {} | 25 MidiDispatcher::~MidiDispatcher() {} |
| 26 | 26 |
| 27 void MidiDispatcher::OnDestruct() { |
| 28 delete this; |
| 29 } |
| 30 |
| 27 void MidiDispatcher::requestPermission(const WebMIDIPermissionRequest& request, | 31 void MidiDispatcher::requestPermission(const WebMIDIPermissionRequest& request, |
| 28 const WebMIDIOptions& options) { | 32 const WebMIDIOptions& options) { |
| 29 if (!permission_service_.get()) { | 33 if (!permission_service_.get()) { |
| 30 render_frame()->GetServiceRegistry()->ConnectToRemoteService( | 34 render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
| 31 mojo::GetProxy(&permission_service_)); | 35 mojo::GetProxy(&permission_service_)); |
| 32 } | 36 } |
| 33 | 37 |
| 34 int permission_request_id = | 38 int permission_request_id = |
| 35 requests_.Add(new WebMIDIPermissionRequest(request)); | 39 requests_.Add(new WebMIDIPermissionRequest(request)); |
| 36 | 40 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 60 blink::mojom::PermissionStatus status) { | 64 blink::mojom::PermissionStatus status) { |
| 61 // |request| can be NULL when the request is canceled. | 65 // |request| can be NULL when the request is canceled. |
| 62 WebMIDIPermissionRequest* request = requests_.Lookup(request_id); | 66 WebMIDIPermissionRequest* request = requests_.Lookup(request_id); |
| 63 if (!request) | 67 if (!request) |
| 64 return; | 68 return; |
| 65 request->setIsAllowed(status == blink::mojom::PermissionStatus::GRANTED); | 69 request->setIsAllowed(status == blink::mojom::PermissionStatus::GRANTED); |
| 66 requests_.Remove(request_id); | 70 requests_.Remove(request_id); |
| 67 } | 71 } |
| 68 | 72 |
| 69 } // namespace content | 73 } // namespace content |
| OLD | NEW |