| 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/WebString.h" | 10 #include "third_party/WebKit/public/platform/WebString.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 const WebMIDIPermissionRequest& request) { | 27 const WebMIDIPermissionRequest& request) { |
| 28 if (!permission_service_.get()) { | 28 if (!permission_service_.get()) { |
| 29 render_frame()->GetServiceRegistry()->ConnectToRemoteService( | 29 render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
| 30 mojo::GetProxy(&permission_service_)); | 30 mojo::GetProxy(&permission_service_)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 int permission_request_id = | 33 int permission_request_id = |
| 34 requests_.Add(new WebMIDIPermissionRequest(request)); | 34 requests_.Add(new WebMIDIPermissionRequest(request)); |
| 35 | 35 |
| 36 permission_service_->RequestPermission( | 36 permission_service_->RequestPermission( |
| 37 PERMISSION_NAME_MIDI_SYSEX, | 37 permission::NAME_MIDI_SYSEX, request.securityOrigin().toString().utf8(), |
| 38 request.securityOrigin().toString().utf8(), | |
| 39 blink::WebUserGestureIndicator::isProcessingUserGesture(), | 38 blink::WebUserGestureIndicator::isProcessingUserGesture(), |
| 40 base::Bind(&MidiDispatcher::OnSysExPermissionSet, | 39 base::Bind(&MidiDispatcher::OnSysExPermissionSet, base::Unretained(this), |
| 41 base::Unretained(this), | |
| 42 permission_request_id)); | 40 permission_request_id)); |
| 43 } | 41 } |
| 44 | 42 |
| 45 void MidiDispatcher::cancelSysexPermissionRequest( | 43 void MidiDispatcher::cancelSysexPermissionRequest( |
| 46 const WebMIDIPermissionRequest& request) { | 44 const WebMIDIPermissionRequest& request) { |
| 47 for (Requests::iterator it(&requests_); !it.IsAtEnd(); it.Advance()) { | 45 for (Requests::iterator it(&requests_); !it.IsAtEnd(); it.Advance()) { |
| 48 WebMIDIPermissionRequest* value = it.GetCurrentValue(); | 46 WebMIDIPermissionRequest* value = it.GetCurrentValue(); |
| 49 if (!value->equals(request)) | 47 if (!value->equals(request)) |
| 50 continue; | 48 continue; |
| 51 requests_.Remove(it.GetCurrentKey()); | 49 requests_.Remove(it.GetCurrentKey()); |
| 52 break; | 50 break; |
| 53 } | 51 } |
| 54 } | 52 } |
| 55 | 53 |
| 56 void MidiDispatcher::OnSysExPermissionSet(int request_id, | 54 void MidiDispatcher::OnSysExPermissionSet(int request_id, |
| 57 PermissionStatus status) { | 55 permission::Status status) { |
| 58 // |request| can be NULL when the request is canceled. | 56 // |request| can be NULL when the request is canceled. |
| 59 WebMIDIPermissionRequest* request = requests_.Lookup(request_id); | 57 WebMIDIPermissionRequest* request = requests_.Lookup(request_id); |
| 60 if (!request) | 58 if (!request) |
| 61 return; | 59 return; |
| 62 request->setIsAllowed(status == PERMISSION_STATUS_GRANTED); | 60 request->setIsAllowed(status == permission::STATUS_GRANTED); |
| 63 requests_.Remove(request_id); | 61 requests_.Remove(request_id); |
| 64 } | 62 } |
| 65 | 63 |
| 66 } // namespace content | 64 } // namespace content |
| OLD | NEW |