Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "modules/permissions/PermissionUtils.h" | |
| 6 | |
| 7 #include "core/dom/Document.h" | |
| 8 #include "core/dom/ExecutionContext.h" | |
| 9 #include "core/frame/LocalFrame.h" | |
| 10 #include "public/platform/InterfaceProvider.h" | |
| 11 #include "public/platform/Platform.h" | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 using mojom::blink::PermissionDescriptor; | |
| 16 using mojom::blink::PermissionDescriptorPtr; | |
| 17 using mojom::blink::PermissionName; | |
| 18 | |
| 19 bool connectToPermissionService(ExecutionContext* executionContext, mojom::blink ::PermissionServiceRequest request) | |
| 20 { | |
| 21 InterfaceProvider* interfaceProvider = nullptr; | |
| 22 if (executionContext->isDocument()) { | |
| 23 Document* document = toDocument(executionContext); | |
| 24 if (document->frame()) | |
| 25 interfaceProvider = document->frame()->interfaceProvider(); | |
| 26 } else { | |
| 27 interfaceProvider = Platform::current()->interfaceProvider(); | |
|
haraken
2016/09/27 13:35:54
Is it worth distinguishing the interface providers
Reilly Grant (use Gerrit)
2016/09/28 05:22:51
Platform::interfaceProvider() returns services reg
| |
| 28 } | |
| 29 | |
| 30 if (interfaceProvider) | |
| 31 interfaceProvider->getInterface(std::move(request)); | |
| 32 return interfaceProvider; | |
| 33 } | |
| 34 | |
| 35 PermissionDescriptorPtr createPermissionDescriptor(PermissionName name) | |
| 36 { | |
| 37 auto descriptor = PermissionDescriptor::New(); | |
| 38 descriptor->name = name; | |
| 39 return descriptor; | |
| 40 } | |
| 41 | |
| 42 PermissionDescriptorPtr createMidiPermissionDescriptor(bool sysex) | |
| 43 { | |
| 44 auto descriptor = createPermissionDescriptor(mojom::blink::PermissionName::M IDI); | |
| 45 auto midiExtension = mojom::blink::MidiPermissionDescriptor::New(); | |
| 46 midiExtension->sysex = sysex; | |
| 47 descriptor->extension = mojom::blink::PermissionDescriptorExtension::New(); | |
| 48 descriptor->extension->set_midi(std::move(midiExtension)); | |
| 49 return descriptor; | |
| 50 } | |
| 51 | |
| 52 } // namespace blink | |
| OLD | NEW |