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

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

Issue 2116763002: Reland: Web MIDI: use mojom::blink::PermissionService directly to ask permission (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for second attempt Created 4 years, 5 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 | « content/renderer/media/midi_dispatcher.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/midi_dispatcher.cc
diff --git a/content/renderer/media/midi_dispatcher.cc b/content/renderer/media/midi_dispatcher.cc
deleted file mode 100644
index f870105dee791f045008c9d36cdd4e0eaf8d4372..0000000000000000000000000000000000000000
--- a/content/renderer/media/midi_dispatcher.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/renderer/media/midi_dispatcher.h"
-
-#include "base/bind.h"
-#include "content/public/renderer/render_frame.h"
-#include "services/shell/public/cpp/interface_provider.h"
-#include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
-#include "third_party/WebKit/public/platform/WebString.h"
-#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
-#include "third_party/WebKit/public/web/modules/webmidi/WebMIDIOptions.h"
-#include "third_party/WebKit/public/web/modules/webmidi/WebMIDIPermissionRequest.h"
-
-using blink::WebMIDIPermissionRequest;
-using blink::WebMIDIOptions;
-using blink::WebSecurityOrigin;
-
-namespace content {
-
-MidiDispatcher::MidiDispatcher(RenderFrame* render_frame)
- : RenderFrameObserver(render_frame) {
-}
-
-MidiDispatcher::~MidiDispatcher() {}
-
-void MidiDispatcher::OnDestruct() {
- delete this;
-}
-
-void MidiDispatcher::requestPermission(const WebMIDIPermissionRequest& request,
- const WebMIDIOptions& options) {
- if (!permission_service_.get())
- render_frame()->GetRemoteInterfaces()->GetInterface(&permission_service_);
-
- int permission_request_id =
- requests_.Add(new WebMIDIPermissionRequest(request));
-
- blink::mojom::PermissionName permission_name =
- (options.sysex == WebMIDIOptions::SysexPermission::WithSysex)
- ? blink::mojom::PermissionName::MIDI_SYSEX
- : blink::mojom::PermissionName::MIDI;
-
- permission_service_->RequestPermission(
- permission_name, request.getSecurityOrigin().toString().utf8(),
- blink::WebUserGestureIndicator::isProcessingUserGesture(),
- base::Bind(&MidiDispatcher::OnPermissionSet, base::Unretained(this),
- permission_request_id));
-}
-
-void MidiDispatcher::cancelPermissionRequest(
- const WebMIDIPermissionRequest& request) {
- for (Requests::iterator it(&requests_); !it.IsAtEnd(); it.Advance()) {
- WebMIDIPermissionRequest* value = it.GetCurrentValue();
- if (!value->equals(request))
- continue;
- requests_.Remove(it.GetCurrentKey());
- break;
- }
-}
-
-void MidiDispatcher::OnPermissionSet(int request_id,
- blink::mojom::PermissionStatus status) {
- // |request| can be NULL when the request is canceled.
- WebMIDIPermissionRequest* request = requests_.Lookup(request_id);
- if (!request)
- return;
- request->setIsAllowed(status == blink::mojom::PermissionStatus::GRANTED);
- requests_.Remove(request_id);
-}
-
-} // namespace content
« no previous file with comments | « content/renderer/media/midi_dispatcher.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698