tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

MIDIPermissionRequest.h (1732B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_MIDIPermissionRequest_h
      8 #define mozilla_dom_MIDIPermissionRequest_h
      9 
     10 #include "mozilla/dom/Promise.h"
     11 #include "nsContentPermissionHelper.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 struct MIDIOptions;
     16 
     17 /**
     18 * Handles permission dialog management when requesting MIDI permissions.
     19 */
     20 class MIDIPermissionRequest final : public ContentPermissionRequestBase,
     21                                    public nsIRunnable {
     22 public:
     23  MIDIPermissionRequest(nsPIDOMWindowInner* aWindow, Promise* aPromise,
     24                        const MIDIOptions& aOptions);
     25 
     26  NS_DECL_ISUPPORTS_INHERITED
     27  NS_DECL_NSIRUNNABLE
     28  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MIDIPermissionRequest,
     29                                           ContentPermissionRequestBase)
     30  // nsIContentPermissionRequest
     31  NS_IMETHOD Cancel(void) override;
     32  NS_IMETHOD Allow(JS::Handle<JS::Value> choices) override;
     33  NS_IMETHOD GetTypes(nsIArray** aTypes) override;
     34 
     35 private:
     36  ~MIDIPermissionRequest() = default;
     37  nsresult DoPrompt();
     38  void CancelWithRandomizedDelay();
     39 
     40  // If we're canceling on a timer, we need to hold a strong ref while it's
     41  // outstanding.
     42  nsCOMPtr<nsITimer> mCancelTimer;
     43 
     44  // Promise for returning MIDIAccess on request success
     45  RefPtr<Promise> mPromise;
     46  // True if sysex permissions should be requested
     47  bool mNeedsSysex;
     48 };
     49 
     50 }  // namespace mozilla::dom
     51 
     52 #endif  // mozilla_dom_MIDIPermissionRequest_h