tor-browser

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

MessageManagerGlobal.cpp (1565B)


      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
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "mozilla/dom/MessageManagerGlobal.h"
      8 
      9 #include "mozilla/IntentionalCrash.h"
     10 #include "mozilla/Logging.h"
     11 #include "nsContentUtils.h"
     12 #include "nsJSUtils.h"
     13 
     14 #ifdef ANDROID
     15 #  include <android/log.h>
     16 #endif
     17 #ifdef XP_WIN
     18 #  include <windows.h>
     19 #endif
     20 
     21 namespace mozilla::dom {
     22 
     23 void MessageManagerGlobal::Dump(const nsAString& aStr) {
     24  if (!nsJSUtils::DumpEnabled()) {
     25    return;
     26  }
     27 
     28  NS_ConvertUTF16toUTF8 cStr(aStr);
     29  MOZ_LOG(nsContentUtils::DOMDumpLog(), mozilla::LogLevel::Debug,
     30          ("[MessageManager.Dump] %s", cStr.get()));
     31 #ifdef ANDROID
     32  __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", cStr.get());
     33 #endif
     34 #ifdef XP_WIN
     35  if (IsDebuggerPresent()) {
     36    OutputDebugStringW(PromiseFlatString(aStr).get());
     37  }
     38 #endif
     39  fputs(cStr.get(), stdout);
     40  fflush(stdout);
     41 }
     42 
     43 void MessageManagerGlobal::Atob(const nsAString& aAsciiString,
     44                                nsAString& aBase64Data, ErrorResult& aError) {
     45  aError = nsContentUtils::Atob(aAsciiString, aBase64Data);
     46 }
     47 
     48 void MessageManagerGlobal::Btoa(const nsAString& aBase64Data,
     49                                nsAString& aAsciiString, ErrorResult& aError) {
     50  aError = nsContentUtils::Btoa(aBase64Data, aAsciiString);
     51 }
     52 
     53 }  // namespace mozilla::dom