Ejemplo n.º 1
0
static bool
IsSupportedAudioCodec(const nsAString& aCodec,
                      bool& aOutContainsAAC,
                      bool& aOutContainsMP3)
{
  // AAC-LC or HE-AAC in M4A.
  aOutContainsAAC = aCodec.EqualsASCII("mp4a.40.2") ||
                    aCodec.EqualsASCII("mp4a.40.5");
  if (aOutContainsAAC) {
#ifdef XP_WIN
    if (!Preferences::GetBool("media.fragmented-mp4.use-blank-decoder") &&
        !WMFDecoderModule::HasAAC()) {
      return false;
    }
#endif
    return true;
  }
#ifndef MOZ_GONK_MEDIACODEC // B2G doesn't support MP3 in MP4 yet.
  aOutContainsMP3 = aCodec.EqualsASCII("mp3");
  if (aOutContainsMP3) {
    return true;
  }
#else
  aOutContainsMP3 = false;
#endif
  return false;
}
Ejemplo n.º 2
0
NS_IMETHODIMP
GonkGPSGeolocationProvider::Handle(const nsAString& aName,
                                   JS::Handle<JS::Value> aResult)
{
#ifdef MOZ_B2G_RIL
  if (aName.EqualsLiteral("ril.supl.apn")) {
    // When we get the APN, we attempt to call data_call_open of AGPS.
    if (aResult.isString()) {
      JSContext *cx = nsContentUtils::GetCurrentJSContext();
      NS_ENSURE_TRUE(cx, NS_OK);

      // NB: No need to enter a compartment to read the contents of a string.
      nsAutoJSString apn;
      if (!apn.init(cx, aResult.toString())) {
        return NS_ERROR_FAILURE;
      }
      if (!apn.IsEmpty()) {
        SetAGpsDataConn(apn);
      }
    }
  } else
#endif // MOZ_B2G_RIL
  if (aName.EqualsASCII(kSettingDebugGpsIgnored)) {
    gDebug_isGPSLocationIgnored = aResult.isBoolean() ? aResult.toBoolean() : false;
    if (gDebug_isLoggingEnabled) {
      nsContentUtils::LogMessageToConsole("geo: Debug: GPS ignored %d\n", gDebug_isGPSLocationIgnored);
    }
    return NS_OK;
  } else if (aName.EqualsASCII(kSettingDebugEnabled)) {
    gDebug_isLoggingEnabled = aResult.isBoolean() ? aResult.toBoolean() : false;
    return NS_OK;
  }
  return NS_OK;
}
Ejemplo n.º 3
0
static bool
IsSupportedKeySystem(const nsAString& aKeySystem)
{
  return aKeySystem.EqualsASCII("org.w3.clearkey") ||
#ifdef XP_WIN
         (aKeySystem.EqualsASCII("com.adobe.access") &&
          IsVistaOrLater() &&
          Preferences::GetBool("media.eme.adobe-access.enabled", false)) ||
#endif
         false;
}
Ejemplo n.º 4
0
/* static */
MediaKeySystemStatus
MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem,
        int32_t aMinCdmVersion,
        nsACString& aOutMessage,
        nsACString& aOutCdmVersion)
{
    MOZ_ASSERT(MediaPrefs::EMEEnabled() || IsClearkeyKeySystem(aKeySystem));
    nsCOMPtr<mozIGeckoMediaPluginService> mps =
        do_GetService("@mozilla.org/gecko-media-plugin-service;1");
    if (NS_WARN_IF(!mps)) {
        aOutMessage = NS_LITERAL_CSTRING("Failed to get GMP service");
        return MediaKeySystemStatus::Error;
    }

    if (aKeySystem.EqualsASCII(kEMEKeySystemClearkey)) {
        return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
    }

    if (Preferences::GetBool("media.gmp-eme-adobe.visible", false)) {
        if (aKeySystem.EqualsASCII(kEMEKeySystemPrimetime)) {
            if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) {
                aOutMessage = NS_LITERAL_CSTRING("Adobe EME disabled");
                return MediaKeySystemStatus::Cdm_disabled;
            }
#ifdef XP_WIN
            // Win Vista and later only.
            if (!IsVistaOrLater()) {
                aOutMessage = NS_LITERAL_CSTRING("Minimum Windows version (Vista) not met for Adobe EME");
                return MediaKeySystemStatus::Cdm_not_supported;
            }
#endif
            return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
        }
    }

    if (Preferences::GetBool("media.gmp-widevinecdm.visible", false)) {
        if (aKeySystem.EqualsASCII(kEMEKeySystemWidevine)) {
#ifdef XP_WIN
            // Win Vista and later only.
            if (!IsVistaOrLater()) {
                aOutMessage = NS_LITERAL_CSTRING("Minimum Windows version (Vista) not met for Widevine EME");
                return MediaKeySystemStatus::Cdm_not_supported;
            }
#endif
            if (!Preferences::GetBool("media.gmp-widevinecdm.enabled", false)) {
                aOutMessage = NS_LITERAL_CSTRING("Widevine EME disabled");
                return MediaKeySystemStatus::Cdm_disabled;
            }
            return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
        }
    }

    return MediaKeySystemStatus::Cdm_not_supported;
}
Ejemplo n.º 5
0
bool
WMFDecoder::CanPlayType(const nsACString& aType,
                        const nsAString& aCodecs)
{
  if (!MediaDecoder::IsWMFEnabled() ||
      NS_FAILED(LoadDLLs())) {
    return false;
  }

  // Assume that if LoadDLLs() didn't fail, we can playback the types that
  // we know should be supported by Windows Media Foundation.
  if ((aType.EqualsASCII("audio/mpeg") || aType.EqualsASCII("audio/mp3")) &&
      IsMP3Supported()) {
    // Note: We block MP3 playback on Window 7 SP0 since it seems to crash
    // in some circumstances.
    return !aCodecs.Length() || aCodecs.EqualsASCII("mp3");
  }

  // AAC-LC or MP3 in M4A.
  if (aType.EqualsASCII("audio/mp4") || aType.EqualsASCII("audio/x-m4a")) {
    return !aCodecs.Length() ||
           aCodecs.EqualsASCII("mp4a.40.2") ||
           aCodecs.EqualsASCII("mp3");
  }

  if (!aType.EqualsASCII("video/mp4")) {
    return false;
  }

  // H.264 + AAC in MP4. Verify that all the codecs specifed are ones that
  // we expect that we can play.
  nsCharSeparatedTokenizer tokenizer(aCodecs, ',');
  bool expectMoreTokens = false;
  while (tokenizer.hasMoreTokens()) {
    const nsSubstring& token = tokenizer.nextToken();
    expectMoreTokens = tokenizer.separatorAfterCurrentToken();
    if (token.EqualsASCII("mp4a.40.2") || // AAC-LC
        token.EqualsASCII("mp3") ||
        IsSupportedH264Codec(token)) {
      continue;
    }
    return false;
  }
  if (expectMoreTokens) {
    // Last codec name was empty
    return false;
  }
  return true;
}
Ejemplo n.º 6
0
/* static */
bool
WaveDecoder::CanHandleMediaType(const nsACString& aType,
                                const nsAString& aCodecs)
{
  if (!IsWaveEnabled()) {
    return false;
  }
  if (aType.EqualsASCII("audio/wave") || aType.EqualsASCII("audio/x-wav") ||
      aType.EqualsASCII("audio/wav")  || aType.EqualsASCII("audio/x-pn-wav")) {
    return (aCodecs.IsEmpty() || aCodecs.EqualsASCII("1") ||
            aCodecs.EqualsASCII("6") || aCodecs.EqualsASCII("7"));
  }

  return false;
}
Ejemplo n.º 7
0
NS_IMETHODIMP
DataTransfer::SetEffectAllowed(const nsAString& aEffectAllowed)
{
  if (aEffectAllowed.EqualsLiteral("uninitialized")) {
    mEffectAllowed = nsIDragService::DRAGDROP_ACTION_UNINITIALIZED;
    return NS_OK;
  }

  static_assert(nsIDragService::DRAGDROP_ACTION_NONE == 0,
                "DRAGDROP_ACTION_NONE constant is wrong");
  static_assert(nsIDragService::DRAGDROP_ACTION_COPY == 1,
                "DRAGDROP_ACTION_COPY constant is wrong");
  static_assert(nsIDragService::DRAGDROP_ACTION_MOVE == 2,
                "DRAGDROP_ACTION_MOVE constant is wrong");
  static_assert(nsIDragService::DRAGDROP_ACTION_LINK == 4,
                "DRAGDROP_ACTION_LINK constant is wrong");

  for (uint32_t e = 0; e < ArrayLength(sEffects); e++) {
    if (aEffectAllowed.EqualsASCII(sEffects[e])) {
      mEffectAllowed = e;
      break;
    }
  }

  return NS_OK;
}
Ejemplo n.º 8
0
nsresult
GonkCameraParameters::MapIsoToGonk(const nsAString& aIso, nsACString& aIsoOut)
{
  if (aIso.EqualsASCII("hjr")) {
    aIsoOut = "ISO_HJR";
  } else if (aIso.EqualsASCII("auto")) {
    aIsoOut = "auto";
  } else {
    nsAutoCString v = NS_LossyConvertUTF16toASCII(aIso);
    unsigned int iso;
    if (sscanf(v.get(), "%u", &iso) != 1) {
      return NS_ERROR_INVALID_ARG;
    }
    aIsoOut = nsPrintfCString("ISO%u", iso);
  }

  return NS_OK;
}
Ejemplo n.º 9
0
/* static */
bool MP3Decoder::CanHandleMediaType(const nsACString& aType,
                                    const nsAString& aCodecs)
{
  if (aType.EqualsASCII("audio/mp3") || aType.EqualsASCII("audio/mpeg")) {
    return IsEnabled() &&
      (aCodecs.IsEmpty() || aCodecs.EqualsASCII("mp3"));
  }
  return false;
}
static bool
ToSessionType(const nsAString& aSessionType, MediaKeySessionType& aOutType)
{
  using MediaKeySessionTypeValues::strings;
  const char* temporary =
    strings[static_cast<uint32_t>(MediaKeySessionType::Temporary)].value;
  if (aSessionType.EqualsASCII(temporary)) {
    aOutType = MediaKeySessionType::Temporary;
    return true;
  }
  const char* persistentLicense =
    strings[static_cast<uint32_t>(MediaKeySessionType::Persistent_license)].value;
  if (aSessionType.EqualsASCII(persistentLicense)) {
    aOutType = MediaKeySessionType::Persistent_license;
    return true;
  }
  return false;
}
Ejemplo n.º 11
0
/* static */ bool
ADTSDecoder::CanHandleMediaType(const nsACString& aType,
                                const nsAString& aCodecs)
{
  if (aType.EqualsASCII("audio/aac") || aType.EqualsASCII("audio/aacp")) {
    return IsEnabled() && (aCodecs.IsEmpty() || aCodecs.EqualsASCII("aac"));
  }

  return false;
}
Ejemplo n.º 12
0
bool
logging::IsEnabled(const nsAString& aModuleStr)
{
  for (unsigned int idx = 0; idx < ArrayLength(sModuleMap); idx++) {
    if (aModuleStr.EqualsASCII(sModuleMap[idx].mStr))
      return sModules & sModuleMap[idx].mModule;
  }

  return false;
}
Ejemplo n.º 13
0
PRBool
nsAttrValue::ParseEnumValue(const nsAString& aValue,
                            const EnumTable* aTable,
                            PRBool aCaseSensitive,
                            const EnumTable* aDefaultValue)
{
  ResetIfSet();
  const EnumTable* tableEntry = aTable;

  while (tableEntry->tag) {
    if (aCaseSensitive ? aValue.EqualsASCII(tableEntry->tag) :
                         aValue.LowerCaseEqualsASCII(tableEntry->tag)) {
      PRInt32 value = EnumTableEntryToValue(aTable, tableEntry);

      PRBool equals = aCaseSensitive || aValue.EqualsASCII(tableEntry->tag);
      if (!equals) {
        nsAutoString tag;
        tag.AssignASCII(tableEntry->tag);
        ToUpperCase(tag);
        if ((equals = tag.Equals(aValue))) {
          value |= NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER;
        }
      }
      SetIntValueAndType(value, eEnum, equals ? nsnull : &aValue);
      NS_ASSERTION(GetEnumValue() == tableEntry->value,
                   "failed to store enum properly");

      return PR_TRUE;
    }
    tableEntry++;
  }

  if (aDefaultValue) {
    NS_PRECONDITION(aTable <= aDefaultValue && aDefaultValue < tableEntry,
                    "aDefaultValue not inside aTable?");
    SetIntValueAndType(EnumTableEntryToValue(aTable, aDefaultValue),
                       eEnum, &aValue);
    return PR_TRUE;
  }

  return PR_FALSE;
}
Ejemplo n.º 14
0
bool IsFontMimeType(const nsAString& aType) {
  if (aType.IsEmpty()) {
    return true;
  }
  for (uint32_t i = 0; i < StyleLinkElementFontMimeTypesNum; i++) {
    if (aType.EqualsASCII(StyleLinkElementFontMimeTypes[i])) {
      return true;
    }
  }
  return false;
}
static PRUint16
GetAlignForString(const nsAString &aAlignString)
{
  for (PRUint32 i = 0 ; i < NS_ARRAY_LENGTH(sAlignStrings) ; i++) {
    if (aAlignString.EqualsASCII(sAlignStrings[i])) {
      return (i + nsIDOMSVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE);
    }
  }

  return nsIDOMSVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_UNKNOWN;
}
Ejemplo n.º 16
0
/* static */ bool
MediaKeySystemAccess::IsGMPPresentOnDisk(const nsAString& aKeySystem,
        const nsACString& aVersion,
        nsACString& aOutMessage)
{
    MOZ_ASSERT(NS_IsMainThread());

    if (XRE_GetProcessType() != GeckoProcessType_Default) {
        // We need to be able to access the filesystem, so call this in the
        // main process via ContentChild.
        ContentChild* contentChild = ContentChild::GetSingleton();
        if (NS_WARN_IF(!contentChild)) {
            return false;
        }

        nsCString message;
        bool result = false;
        bool ok = contentChild->SendIsGMPPresentOnDisk(nsString(aKeySystem), nsCString(aVersion),
                  &result, &message);
        aOutMessage = message;
        return ok && result;
    }

    bool isPresent = true;

#if XP_WIN
    if (aKeySystem.EqualsASCII(kEMEKeySystemPrimetime)) {
        if (!AdobePluginDLLExists(aVersion)) {
            NS_WARNING("Adobe EME plugin disappeared from disk!");
            aOutMessage = NS_LITERAL_CSTRING("Adobe DLL was expected to be on disk but was not");
            isPresent = false;
        }
        if (!AdobePluginVoucherExists(aVersion)) {
            NS_WARNING("Adobe EME voucher disappeared from disk!");
            aOutMessage = NS_LITERAL_CSTRING("Adobe plugin voucher was expected to be on disk but was not");
            isPresent = false;
        }

        if (!isPresent) {
            // Reset the prefs that Firefox's GMP downloader sets, so that
            // Firefox will try to download the plugin next time the updater runs.
            Preferences::ClearUser("media.gmp-eme-adobe.lastUpdate");
            Preferences::ClearUser("media.gmp-eme-adobe.version");
        } else if (!EMEVoucherFileExists()) {
            // Gecko doesn't have a voucher file for the plugin-container.
            // Adobe EME isn't going to work, so don't advertise that it will.
            aOutMessage = NS_LITERAL_CSTRING("Plugin-container voucher not present");
            isPresent = false;
        }
    }
#endif

    return isPresent;
}
static PRUint16
GetMeetOrSliceForString(const nsAString &aMeetOrSlice)
{
  for (PRUint32 i = 0 ; i < NS_ARRAY_LENGTH(sMeetOrSliceStrings) ; i++) {
    if (aMeetOrSlice.EqualsASCII(sMeetOrSliceStrings[i])) {
      return (i + nsIDOMSVGPreserveAspectRatio::SVG_MEETORSLICE_MEET);
    }
  }

  return nsIDOMSVGPreserveAspectRatio::SVG_MEETORSLICE_UNKNOWN;
}
Ejemplo n.º 18
0
/* static */ AudioChannel
AudioChannelService::GetAudioChannel(const nsAString& aChannel)
{
  for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].tag; ++i) {
    if (aChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].tag)) {
      return static_cast<AudioChannel>(kMozAudioChannelAttributeTable[i].value);
    }
  }

  return AudioChannel::Normal;
}
Ejemplo n.º 19
0
/* static */ bool
DataTransfer::PrincipalMaySetData(const nsAString& aType,
                                  nsIVariant* aData,
                                  nsIPrincipal* aPrincipal)
{
  if (!nsContentUtils::IsSystemPrincipal(aPrincipal)) {
    DataTransferItem::eKind kind = DataTransferItem::KindFromData(aData);
    if (kind == DataTransferItem::KIND_OTHER) {
      NS_WARNING("Disallowing adding non string/file types to DataTransfer");
      return false;
    }

    if (aType.EqualsASCII(kFileMime) ||
        aType.EqualsASCII(kFilePromiseMime)) {
      NS_WARNING("Disallowing adding x-moz-file or x-moz-file-promize types to DataTransfer");
      return false;
    }
  }
  return true;
}
Ejemplo n.º 20
0
static bool
IsSupportedAudioCodec(const nsAString& aCodec,
                      bool& aOutContainsAAC,
                      bool& aOutContainsMP3)
{
  // AAC-LC or HE-AAC in M4A.
  aOutContainsAAC = aCodec.EqualsASCII("mp4a.40.2") ||
                    aCodec.EqualsASCII("mp4a.40.5");
  if (aOutContainsAAC) {
    return true;
  }
#ifndef MOZ_GONK_MEDIACODEC // B2G doesn't support MP3 in MP4 yet.
  aOutContainsMP3 = aCodec.EqualsASCII("mp3");
  if (aOutContainsMP3) {
    return true;
  }
#else
  aOutContainsMP3 = false;
#endif
  return false;
}
Ejemplo n.º 21
0
PRBool
nsAttrValue::ParseEnumValue(const nsAString& aValue,
                            const EnumTable* aTable,
                            PRBool aCaseSensitive)
{
  ResetIfSet();
  const EnumTable* tableEntry = aTable;

  while (tableEntry->tag) {
    if (aCaseSensitive ? aValue.EqualsASCII(tableEntry->tag) :
                         aValue.LowerCaseEqualsASCII(tableEntry->tag)) {
      PRInt16 index;
      if (!GetEnumTableIndex(aTable, index)) {
        return PR_FALSE;
      }

      PRInt32 value = (tableEntry->value << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) +
                      index;

      PRBool equals = aCaseSensitive || aValue.EqualsASCII(tableEntry->tag);
      if (!equals) {
        nsAutoString tag;
        tag.AssignASCII(tableEntry->tag);
        ToUpperCase(tag);
        if ((equals = tag.Equals(aValue))) {
          value |= NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER;
        }
      }
      SetIntValueAndType(value, eEnum, equals ? nsnull : &aValue);
      NS_ASSERTION(GetEnumValue() == tableEntry->value,
                   "failed to store enum properly");

      return PR_TRUE;
    }
    tableEntry++;
  }

  return PR_FALSE;
}
Ejemplo n.º 22
0
NS_IMETHODIMP
GonkGPSGeolocationProvider::Handle(const nsAString& aName,
                                   JS::Handle<JS::Value> aResult)
{
#ifdef MOZ_B2G_RIL
  if (aName.EqualsLiteral("ril.supl.apn")) {
    // When we get the APN, we attempt to call data_call_open of AGPS.
    if (aResult.isString()) {
      JSContext *cx = nsContentUtils::GetCurrentJSContext();
      NS_ENSURE_TRUE(cx, NS_OK);

      // NB: No need to enter a compartment to read the contents of a string.
      nsAutoJSString apn;
      if (!apn.init(cx, aResult.toString())) {
        return NS_ERROR_FAILURE;
      }
      if (!apn.IsEmpty()) {
        SetAGpsDataConn(apn);
      }
    }
  } else if (aName.EqualsASCII(kSettingRilDefaultServiceId)) {
    uint32_t id = 0;
    JSContext *cx = nsContentUtils::GetCurrentJSContext();
    NS_ENSURE_TRUE(cx, NS_OK);
    if (!JS::ToUint32(cx, aResult, &id)) {
      return NS_ERROR_FAILURE;
    }

    if (!IsValidRilServiceId(id)) {
      return NS_ERROR_UNEXPECTED;
    }

    mRilDataServiceId = id;
    UpdateRadioInterface();

    MOZ_ASSERT(!mObservingNetworkConnStateChange);

    // Now we know which service ID to deal with, observe necessary topic then
    nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
    NS_ENSURE_TRUE(obs, NS_OK);

    if (NS_FAILED(obs->AddObserver(this, kNetworkConnStateChangedTopic, false))) {
      NS_WARNING("Failed to add network state changed observer!");
    } else {
      mObservingNetworkConnStateChange = true;
    }
  }
#endif // MOZ_B2G_RIL
  return NS_OK;
}
Ejemplo n.º 23
0
bool
permitsScheme(const nsAString& aEnforcementScheme,
              nsIURI* aUri,
              bool aReportOnly,
              bool aUpgradeInsecure)
{
  nsAutoCString scheme;
  nsresult rv = aUri->GetScheme(scheme);
  NS_ENSURE_SUCCESS(rv, false);

  // no scheme to enforce, let's allow the load (e.g. script-src *)
  if (aEnforcementScheme.IsEmpty()) {
    return true;
  }

  // if the scheme matches, all good - allow the load
  if (aEnforcementScheme.EqualsASCII(scheme.get())) {
    return true;
  }

  // allow scheme-less sources where the protected resource is http
  // and the load is https, see:
  // http://www.w3.org/TR/CSP2/#match-source-expression
  if (aEnforcementScheme.EqualsASCII("http") &&
      scheme.EqualsASCII("https")) {
    return true;
  }

  // Allow the load when enforcing upgrade-insecure-requests with the
  // promise the request gets upgraded from http to https and ws to wss.
  // See nsHttpChannel::Connect() and also WebSocket.cpp. Please note,
  // the report only policies should not allow the load and report
  // the error back to the page.
  return ((aUpgradeInsecure && !aReportOnly) &&
          ((scheme.EqualsASCII("http") && aEnforcementScheme.EqualsASCII("https")) ||
           (scheme.EqualsASCII("ws") && aEnforcementScheme.EqualsASCII("wss"))));
}
Ejemplo n.º 24
0
 NS_IMETHOD Callback(const nsAString& aTopic, const nsAString& aState) {
   if (!aTopic.EqualsASCII("screen")) {
     return NS_OK;
   }
   // Note the wake lock code ensures that we're not sent duplicate
   // "locked-foreground" notifications when multipe wake locks are held.
   if (aState.EqualsASCII("locked-foreground")) {
     WAKE_LOCK_LOG("WinWakeLock: Blocking screen saver");
     // We block the screen saver by periodically resetting the screen
     // saver timeout.
     StartTimer();
     // Prevent the display turning off. On Win7 and later this also
     // blocks the screen saver, but we need the timer started above
     // to block on Win XP and Vista.
     SetThreadExecutionState(ES_DISPLAY_REQUIRED|ES_CONTINUOUS);
   } else {
     WAKE_LOCK_LOG("WinWakeLock: Unblocking screen saver");
     // Re-enable screen saver.
     StopTimer();
     // Unblock display turning off.
     SetThreadExecutionState(ES_CONTINUOUS);
   }
   return NS_OK;
 }
Ejemplo n.º 25
0
NS_IMETHODIMP
DataTransfer::SetDropEffect(const nsAString& aDropEffect)
{
  // the drop effect can only be 'none', 'copy', 'move' or 'link'.
  for (uint32_t e = 0; e <= nsIDragService::DRAGDROP_ACTION_LINK; e++) {
    if (aDropEffect.EqualsASCII(sEffects[e])) {
      // don't allow copyMove
      if (e != (nsIDragService::DRAGDROP_ACTION_COPY |
                nsIDragService::DRAGDROP_ACTION_MOVE))
        mDropEffect = e;
      break;
    }
  }

  return NS_OK;
}
Ejemplo n.º 26
0
void
ContentChild::SetProcessName(const nsAString& aName)
{
    char* name;
    if ((name = PR_GetEnv("MOZ_DEBUG_APP_PROCESS")) &&
        aName.EqualsASCII(name)) {
#ifdef OS_POSIX
        printf_stderr("\n\nCHILDCHILDCHILDCHILD\n  [%s] debug me @%d\n\n", name, getpid());
        sleep(30);
#elif defined(OS_WIN)
        printf_stderr("\n\nCHILDCHILDCHILDCHILD\n  [%s] debug me @%d\n\n", name, _getpid());
        Sleep(30000);
#endif
    }

    mProcessName = aName;
    mozilla::ipc::SetThisProcessName(NS_LossyConvertUTF16toASCII(aName).get());
}
Ejemplo n.º 27
0
// To be removed once bug 1124165 lands
bool
nsPerformance::IsPerformanceTimingAttribute(const nsAString& aName)
{
  // Note that toJSON is added to this list due to bug 1047848
  static const char* attributes[] =
    {"navigationStart", "unloadEventStart", "unloadEventEnd", "redirectStart",
     "redirectEnd", "fetchStart", "domainLookupStart", "domainLookupEnd",
     "connectStart", "connectEnd", "requestStart", "responseStart",
     "responseEnd", "domLoading", "domInteractive", "domContentLoadedEventStart",
     "domContentLoadedEventEnd", "domComplete", "loadEventStart",
     "loadEventEnd", nullptr};

  for (uint32_t i = 0; attributes[i]; ++i) {
    if (aName.EqualsASCII(attributes[i])) {
      return true;
    }
  }
  return false;
}
PRBool
nsCSSTextAttr::Get(nsACString& aName, nsAString& aValue)
{
  if (!mStyleDecl)
    return PR_FALSE;

  NS_ConvertASCIItoUTF16 cssName(gCSSTextAttrsMap[mIndex].mCSSName);
  nsresult rv = mStyleDecl->GetPropertyValue(cssName, aValue);
  if (NS_FAILED(rv))
    return PR_FALSE;

  // Don't expose text attribute if corresponding CSS value on the element
  // equals to CSS value on the root element and we don't want to include
  // default values.
  if (!mIncludeDefAttrValue) {
    if (!mDefStyleDecl)
      return PR_FALSE;

    nsAutoString defValue;
    mDefStyleDecl->GetPropertyValue(cssName, defValue);
    if (defValue == aValue)
      return PR_FALSE;
  }

  // Don't expose text attribute if its required specific CSS value isn't
  // matched with the CSS value we got.
  const char *cssValue = gCSSTextAttrsMap[mIndex].mCSSValue;
  if (cssValue != kAnyValue && !aValue.EqualsASCII(cssValue))
    return PR_FALSE;

  // Get the name of text attribute.
  if (gCSSTextAttrsMap[mIndex].mAttrName != kCopyName)
    aName = gCSSTextAttrsMap[mIndex].mAttrName;
  else
    aName = gCSSTextAttrsMap[mIndex].mCSSName;

  // Get the value of text attribute.
  const char *attrValue = gCSSTextAttrsMap[mIndex].mAttrValue;
  if (attrValue != kCopyValue)
    AppendASCIItoUTF16(attrValue, aValue);

  return PR_TRUE;
}
Ejemplo n.º 29
0
void
ContentChild::SetProcessName(const nsAString& aName)
{
    char* name;
    if ((name = PR_GetEnv("MOZ_DEBUG_APP_PROCESS")) &&
            aName.EqualsASCII(name)) {
#ifdef OS_POSIX
        printf_stderr("\n\nCHILDCHILDCHILDCHILD\n  [%s] debug me @%d\n\n", name, getpid());
        sleep(30);
#elif defined(OS_WIN)
        // Windows has a decent JIT debugging story, so NS_DebugBreak does the
        // right thing.
        NS_DebugBreak(NS_DEBUG_BREAK,
                      "Invoking NS_DebugBreak() to debug child process",
                      nullptr, __FILE__, __LINE__);
#endif
    }

    mProcessName = aName;
    mozilla::ipc::SetThisProcessName(NS_LossyConvertUTF16toASCII(aName).get());
}
Ejemplo n.º 30
0
NS_IMETHODIMP
nsDOMDataTransfer::SetEffectAllowed(const nsAString& aEffectAllowed)
{
  if (aEffectAllowed.EqualsLiteral("uninitialized")) {
    mEffectAllowed = nsIDragService::DRAGDROP_ACTION_UNINITIALIZED;
    return NS_OK;
  }

  PR_STATIC_ASSERT(nsIDragService::DRAGDROP_ACTION_NONE == 0);
  PR_STATIC_ASSERT(nsIDragService::DRAGDROP_ACTION_COPY == 1);
  PR_STATIC_ASSERT(nsIDragService::DRAGDROP_ACTION_MOVE == 2);
  PR_STATIC_ASSERT(nsIDragService::DRAGDROP_ACTION_LINK == 4);

  for (uint32_t e = 0; e < ArrayLength(sEffects); e++) {
    if (aEffectAllowed.EqualsASCII(sEffects[e])) {
      mEffectAllowed = e;
      break;
    }
  }

  return NS_OK;
}