tor-browser

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

RegisterBindings.cpp (1442B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      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 #include "ChromeWorkerScope.h"
      8 #include "WorkerPrivate.h"
      9 #include "jsapi.h"
     10 #include "mozilla/dom/DebuggerNotificationObserverBinding.h"
     11 #include "mozilla/dom/RegisterWorkerBindings.h"
     12 #include "mozilla/dom/RegisterWorkerDebuggerBindings.h"
     13 
     14 using namespace mozilla::dom;
     15 
     16 bool WorkerPrivate::RegisterBindings(JSContext* aCx,
     17                                     JS::Handle<JSObject*> aGlobal) {
     18  // Init Web IDL bindings
     19  if (!RegisterWorkerBindings(aCx, aGlobal)) {
     20    return false;
     21  }
     22 
     23  if (IsChromeWorker()) {
     24    if (!DefineChromeWorkerFunctions(aCx, aGlobal)) {
     25      return false;
     26    }
     27  }
     28 
     29  return true;
     30 }
     31 
     32 bool WorkerPrivate::RegisterDebuggerBindings(JSContext* aCx,
     33                                             JS::Handle<JSObject*> aGlobal) {
     34  // Init Web IDL bindings
     35  if (!RegisterWorkerDebuggerBindings(aCx, aGlobal)) {
     36    return false;
     37  }
     38 
     39  if (!ChromeUtils_Binding::CreateAndDefineOnGlobal(aCx) ||
     40      !DebuggerNotificationObserver_Binding::CreateAndDefineOnGlobal(aCx)) {
     41    return false;
     42  }
     43 
     44  if (!JS_DefineDebuggerObject(aCx, aGlobal)) {
     45    return false;
     46  }
     47 
     48  return true;
     49 }