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

Side by Side Diff: content/renderer/media/midi_dispatcher.cc

Issue 1602703005: Web MIDI: Ask permissions of the content layer always (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review #10 and #11, rebase PS will follow Created 4 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 unified diff | Download patch
OLDNEW
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"
11 #include "third_party/WebKit/public/web/WebMIDIOptions.h"
11 #include "third_party/WebKit/public/web/WebMIDIPermissionRequest.h" 12 #include "third_party/WebKit/public/web/WebMIDIPermissionRequest.h"
12 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 13 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
13 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" 14 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
14 15
15 using blink::WebMIDIPermissionRequest; 16 using blink::WebMIDIPermissionRequest;
17 using blink::WebMIDIOptions;
16 using blink::WebSecurityOrigin; 18 using blink::WebSecurityOrigin;
17 19
18 namespace content { 20 namespace content {
19 21
20 MidiDispatcher::MidiDispatcher(RenderFrame* render_frame) 22 MidiDispatcher::MidiDispatcher(RenderFrame* render_frame)
21 : RenderFrameObserver(render_frame) { 23 : RenderFrameObserver(render_frame) {
22 } 24 }
23 25
24 MidiDispatcher::~MidiDispatcher() {} 26 MidiDispatcher::~MidiDispatcher() {}
25 27
26 void MidiDispatcher::requestSysexPermission( 28 void MidiDispatcher::requestPermission(const WebMIDIPermissionRequest& request,
27 const WebMIDIPermissionRequest& request) { 29 const WebMIDIOptions& options) {
28 if (!permission_service_.get()) { 30 if (!permission_service_.get()) {
29 render_frame()->GetServiceRegistry()->ConnectToRemoteService( 31 render_frame()->GetServiceRegistry()->ConnectToRemoteService(
30 mojo::GetProxy(&permission_service_)); 32 mojo::GetProxy(&permission_service_));
31 } 33 }
32 34
33 int permission_request_id = 35 int permission_request_id =
34 requests_.Add(new WebMIDIPermissionRequest(request)); 36 requests_.Add(new WebMIDIPermissionRequest(request));
35 37
38 PermissionName permission_name =
Takashi Toyoshima 2016/01/26 08:08:03 Oops, I mistakenly merge this change into this pat
39 (options.sysex == WebMIDIOptions::SysexPermission::WithSysex)
40 ? PERMISSION_NAME_MIDI_SYSEX
41 : PERMISSION_NAME_MIDI;
42
36 permission_service_->RequestPermission( 43 permission_service_->RequestPermission(
37 PERMISSION_NAME_MIDI_SYSEX, 44 permission_name, request.securityOrigin().toString().utf8(),
38 request.securityOrigin().toString().utf8(),
39 blink::WebUserGestureIndicator::isProcessingUserGesture(), 45 blink::WebUserGestureIndicator::isProcessingUserGesture(),
40 base::Bind(&MidiDispatcher::OnSysExPermissionSet, 46 base::Bind(&MidiDispatcher::OnPermissionSet, base::Unretained(this),
41 base::Unretained(this),
42 permission_request_id)); 47 permission_request_id));
43 } 48 }
44 49
45 void MidiDispatcher::cancelSysexPermissionRequest( 50 void MidiDispatcher::cancelPermissionRequest(
46 const WebMIDIPermissionRequest& request) { 51 const WebMIDIPermissionRequest& request) {
47 for (Requests::iterator it(&requests_); !it.IsAtEnd(); it.Advance()) { 52 for (Requests::iterator it(&requests_); !it.IsAtEnd(); it.Advance()) {
48 WebMIDIPermissionRequest* value = it.GetCurrentValue(); 53 WebMIDIPermissionRequest* value = it.GetCurrentValue();
49 if (!value->equals(request)) 54 if (!value->equals(request))
50 continue; 55 continue;
51 requests_.Remove(it.GetCurrentKey()); 56 requests_.Remove(it.GetCurrentKey());
52 break; 57 break;
53 } 58 }
54 } 59 }
55 60
56 void MidiDispatcher::OnSysExPermissionSet(int request_id, 61 void MidiDispatcher::OnPermissionSet(int request_id, PermissionStatus status) {
57 PermissionStatus status) {
58 // |request| can be NULL when the request is canceled. 62 // |request| can be NULL when the request is canceled.
59 WebMIDIPermissionRequest* request = requests_.Lookup(request_id); 63 WebMIDIPermissionRequest* request = requests_.Lookup(request_id);
60 if (!request) 64 if (!request)
61 return; 65 return;
62 request->setIsAllowed(status == PERMISSION_STATUS_GRANTED); 66 request->setIsAllowed(status == PERMISSION_STATUS_GRANTED);
63 requests_.Remove(request_id); 67 requests_.Remove(request_id);
64 } 68 }
65 69
66 } // namespace content 70 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/midi_dispatcher.h ('k') | content/shell/browser/layout_test/layout_test_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698