void Decoder::Finish() { // Implementation-specific finalization if (!HasError()) FinishInternal(); // If the implementation left us mid-frame, finish that up. if (mInFrame && !HasDecoderError()) PostFrameStop(); // If PostDecodeDone() has not been called, we need to sent teardown // notifications. if (!IsSizeDecode() && !mDecodeDone) { // Log data errors to the error console nsCOMPtr<nsIConsoleService> consoleService = do_GetService(NS_CONSOLESERVICE_CONTRACTID); nsCOMPtr<nsIScriptError> errorObject = do_CreateInstance(NS_SCRIPTERROR_CONTRACTID); if (consoleService && errorObject && !HasDecoderError()) { nsAutoString msg(NS_LITERAL_STRING("Image corrupt or truncated: ") + NS_ConvertASCIItoUTF16(mImage.GetURIString())); if (NS_SUCCEEDED(errorObject->InitWithWindowID( msg.get(), NS_ConvertUTF8toUTF16(mImage.GetURIString()).get(), nsnull, 0, 0, nsIScriptError::errorFlag, "Image", mImage.InnerWindowID() ))) { consoleService->LogMessage(errorObject); } } // If we only have a data error, see if things are worth salvaging bool salvage = !HasDecoderError() && mImage.GetNumFrames(); // If we're salvaging, say we finished decoding if (salvage) mImage.DecodingComplete(); // Fire teardown notifications if (mObserver) { mObserver->OnStopContainer(nsnull, &mImage); mObserver->OnStopDecode(nsnull, salvage ? NS_OK : NS_ERROR_FAILURE, nsnull); } } }
NS_IMETHODIMP nsNSSCertificate::GetSerialNumber(nsAString &_serialNumber) { nsNSSShutDownPreventionLock locker; if (isAlreadyShutDown()) return NS_ERROR_NOT_AVAILABLE; _serialNumber.Truncate(); char *tmpstr = CERT_Hexify(&mCert->serialNumber, 1); if (tmpstr) { _serialNumber = NS_ConvertASCIItoUTF16(tmpstr); PORT_Free(tmpstr); return NS_OK; } return NS_ERROR_FAILURE; }
void ErrorReporter::ReportUnexpected(const char *aMessage, const nsCSSToken &aToken) { if (!ShouldReportErrors()) return; nsAutoString tokenString; aToken.AppendToString(tokenString); const PRUnichar *params[1] = { tokenString.get() }; nsAutoString str; sStringBundle->FormatStringFromName(NS_ConvertASCIItoUTF16(aMessage).get(), params, ArrayLength(params), getter_Copies(str)); AddToError(str); }
void ErrorReporter::ReportUnexpectedEOF(const char *aMessage) { if (!ShouldReportErrors()) return; nsAutoString innerStr; sStringBundle->GetStringFromName(NS_ConvertASCIItoUTF16(aMessage).get(), getter_Copies(innerStr)); const PRUnichar *params[1] = { innerStr.get() }; nsAutoString str; sStringBundle->FormatStringFromName(NS_LITERAL_STRING("PEUnexpEOF2").get(), params, ArrayLength(params), getter_Copies(str)); AddToError(str); }
void MediaEngineWebrtcAudioSource::GetUUID(nsAString& aUUID) { char deviceName[KMaxDeviceNameLength]; memset(deviceName, 0, KMaxDeviceNameLength); char uniqueId[KMaxUniqueIdLength]; memset(uniqueId, 0, KMaxUniqueIdLength); if(true == mInitDone ) { mVoEHw->GetRecordingDeviceName( mCapIndex, deviceName, uniqueId ); aUUID.Assign(NS_ConvertASCIItoUTF16(uniqueId)); } return; }
void ErrorReporter::ReportUnexpected(const char *aMessage, const nsString &aParam) { if (!ShouldReportErrors()) return; nsAutoString qparam; nsStyleUtil::AppendEscapedCSSIdent(aParam, qparam); const PRUnichar *params[1] = { qparam.get() }; nsAutoString str; sStringBundle->FormatStringFromName(NS_ConvertASCIItoUTF16(aMessage).get(), params, ArrayLength(params), getter_Copies(str)); AddToError(str); }
void MediaEngineWebRTCVideoSource::GetUUID(nsAString& aUUID) { char deviceName[KMaxDeviceNameLength]; memset(deviceName, 0, KMaxDeviceNameLength); char uniqueId[KMaxUniqueIdLength]; memset(uniqueId, 0, KMaxUniqueIdLength); if (mInitDone) { mViECapture->GetCaptureDevice( mCapIndex, deviceName, KMaxDeviceNameLength, uniqueId, KMaxUniqueIdLength ); aUUID.Assign(NS_ConvertASCIItoUTF16(uniqueId)); } }
/* void openProgressDialog (in nsIDOMWindow parent, in string dialogURL, in nsISupports parameters); */ NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent, const char *dialogURL, nsISupports *parameters, nsIObserver *openDialogObserver, bool *notifyOnOpen) { m_observer = openDialogObserver; nsresult rv = NS_ERROR_FAILURE; if (m_dialog) return NS_ERROR_ALREADY_INITIALIZED; if (!dialogURL || !*dialogURL) return NS_ERROR_INVALID_ARG; if (parent) { // Set up window.arguments[0]... nsCOMPtr<nsISupportsArray> array; rv = NS_NewISupportsArray(getter_AddRefs(array)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); ifptr->SetData(static_cast<nsIPrintProgress*>(this)); ifptr->SetDataIID(&NS_GET_IID(nsIPrintProgress)); array->AppendElement(ifptr); array->AppendElement(parameters); // Open the dialog. nsCOMPtr<nsIDOMWindow> newWindow; rv = parent->OpenDialog(NS_ConvertASCIItoUTF16(dialogURL), NS_LITERAL_STRING("_blank"), NS_LITERAL_STRING("chrome,titlebar,dependent,centerscreen"), array, getter_AddRefs(newWindow)); if (NS_SUCCEEDED(rv)) { *notifyOnOpen = true; } } return rv; }
NS_IMETHODIMP nsXPInstallManager::ConfirmInstall(nsIDOMWindow *aParent, const PRUnichar **aPackageList, PRUint32 aCount, PRBool *aRetval) { *aRetval = PR_FALSE; nsCOMPtr<nsIDOMWindowInternal> parentWindow( do_QueryInterface(aParent) ); nsCOMPtr<nsIDialogParamBlock> params; nsresult rv = LoadParams( aCount, aPackageList, getter_AddRefs(params) ); if ( NS_SUCCEEDED(rv) && parentWindow && params) { nsCOMPtr<nsIDOMWindow> newWindow; nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); ifptr->SetData(params); ifptr->SetDataIID(&NS_GET_IID(nsIDialogParamBlock)); char* confirmDialogURL; nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); if (!pref) return rv; rv = pref->GetCharPref(PREF_XPINSTALL_CONFIRM_DLG, &confirmDialogURL); NS_ASSERTION(NS_SUCCEEDED(rv), "Can't invoke XPInstall FE without a FE URL! Set xpinstall.dialog.confirm"); if (NS_FAILED(rv)) return rv; rv = parentWindow->OpenDialog(NS_ConvertASCIItoUTF16(confirmDialogURL), NS_LITERAL_STRING("_blank"), NS_LITERAL_STRING("chrome,centerscreen,modal,titlebar"), ifptr, getter_AddRefs(newWindow)); if (NS_SUCCEEDED(rv)) { //Now get which button was pressed from the ParamBlock PRInt32 buttonPressed = 0; params->GetInt( 0, &buttonPressed ); *aRetval = buttonPressed ? PR_FALSE : PR_TRUE; } } return rv; }
nsresult Validate() { // Verify cert is self-signed bool selfSigned; nsresult rv = mCert->GetIsSelfSigned(&selfSigned); if (NS_FAILED(rv)) { return rv; } if (!selfSigned) { return NS_ERROR_FAILURE; } // Check that subject and issuer match nickname nsXPIDLString subjectName; nsXPIDLString issuerName; mCert->GetSubjectName(subjectName); mCert->GetIssuerName(issuerName); if (!subjectName.Equals(issuerName)) { return NS_ERROR_FAILURE; } NS_NAMED_LITERAL_STRING(commonNamePrefix, "CN="); nsAutoString subjectNameFromNickname( commonNamePrefix + NS_ConvertASCIItoUTF16(mNickname)); if (!subjectName.Equals(subjectNameFromNickname)) { return NS_ERROR_FAILURE; } nsCOMPtr<nsIX509CertValidity> validity; mCert->GetValidity(getter_AddRefs(validity)); PRTime notBefore, notAfter; validity->GetNotBefore(¬Before); validity->GetNotAfter(¬After); // Ensure cert will last at least one more day static const PRTime oneDay = PRTime(PR_USEC_PER_SEC) * PRTime(60) // sec * PRTime(60) // min * PRTime(24); // hours PRTime now = PR_Now(); if (notBefore > now || notAfter < (now - oneDay)) { return NS_ERROR_FAILURE; } return NS_OK; }
bool nsXHTMLContentSerializer::AfterElementStart(nsIContent* aContent, nsIContent* aOriginalElement, nsAString& aStr) { nsIAtom *name = aContent->Tag(); if (aContent->GetNameSpaceID() == kNameSpaceID_XHTML && mRewriteEncodingDeclaration && name == nsGkAtoms::head) { // Check if there already are any content-type meta children. // If there are, they will be modified to use the correct charset. // If there aren't, we'll insert one here. bool hasMeta = false; for (nsIContent* child = aContent->GetFirstChild(); child; child = child->GetNextSibling()) { if (child->IsHTML(nsGkAtoms::meta) && child->HasAttr(kNameSpaceID_None, nsGkAtoms::content)) { nsAutoString header; child->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header); if (header.LowerCaseEqualsLiteral("content-type")) { hasMeta = true; break; } } } if (!hasMeta) { NS_ENSURE_TRUE(AppendNewLineToString(aStr), false); if (mDoFormat) { NS_ENSURE_TRUE(AppendIndentation(aStr), false); } NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("<meta http-equiv=\"content-type\""), aStr), false); NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING(" content=\"text/html; charset="), aStr), false); NS_ENSURE_TRUE(AppendToString(NS_ConvertASCIItoUTF16(mCharset), aStr), false); if (mIsHTMLSerializer) { NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("\">"), aStr), false); } else { NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("\" />"), aStr), false); } } } return true; }
// aMessage must take no parameters void nsCSSScanner::ReportUnexpectedEOF(const char* aLookingFor) { ENSURE_STRINGBUNDLE; nsXPIDLString innerStr; gStringBundle->GetStringFromName(NS_ConvertASCIItoUTF16(aLookingFor).get(), getter_Copies(innerStr)); const PRUnichar *params[] = { innerStr.get() }; nsXPIDLString str; gStringBundle->FormatStringFromName(NS_LITERAL_STRING("PEUnexpEOF").get(), params, NS_ARRAY_LENGTH(params), getter_Copies(str)); AddToError(str); }
NS_IMETHODIMP nsCategoryObserver::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData) { if (!mListener) return NS_OK; if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) { mHash.Clear(); mListener->CategoryCleared(); return NS_OK; } if (!aData || !nsDependentString(aData).Equals(NS_ConvertASCIItoUTF16(mCategory))) return NS_OK; nsCAutoString str; nsCOMPtr<nsISupportsCString> strWrapper(do_QueryInterface(aSubject)); if (strWrapper) strWrapper->GetData(str); if (strcmp(aTopic, NS_XPCOM_CATEGORY_ENTRY_ADDED_OBSERVER_ID) == 0) { nsCOMPtr<nsICategoryManager> catMan = do_GetService(NS_CATEGORYMANAGER_CONTRACTID); if (!catMan) return NS_OK; nsCString entryValue; catMan->GetCategoryEntry(mCategory.get(), str.get(), getter_Copies(entryValue)); mHash.Put(str, entryValue); mListener->EntryAdded(entryValue); } else if (strcmp(aTopic, NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID) == 0) { nsCAutoString val; if (mHash.Get(str, &val)) { mHash.Remove(str); mListener->EntryRemoved(val); } } else if (strcmp(aTopic, NS_XPCOM_CATEGORY_CLEARED_OBSERVER_ID) == 0) { mHash.Clear(); mListener->CategoryCleared(); } return NS_OK; }
//-------------------------------------------------------------- NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsACString& aAlias, nsACString& oResult) { if (aAlias.IsEmpty()) return NS_ERROR_NULL_POINTER; NS_TIMELINE_START_TIMER("nsCharsetAlias2:GetPreferred"); // Delay loading charsetalias.properties by hardcoding the most // frequent aliases. Note that it's possible to recur in to this // function *while loading* charsetalias.properties (see bug 190951), // so we might have an |mDelegate| already that isn't valid yet, but // the load is guaranteed to be "UTF-8" so things will be OK. for (PRUint32 index = 0; index < NS_ARRAY_LENGTH(kAliases); index++) { if (aAlias.LowerCaseEqualsASCII(kAliases[index][0])) { oResult.Assign(nsDependentCString(kAliases[index][1], NS_PTR_TO_UINT32(kAliases[index][2]))); NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred"); return NS_OK; } } oResult.Truncate(); if(!mDelegate) { //load charsetalias.properties string bundle with all remaining aliases // we may need to protect the following section with a lock so we won't call the // 'new nsGREResProperties' from two different threads mDelegate = new nsGREResProperties( NS_LITERAL_CSTRING("charsetalias.properties") ); NS_ASSERTION(mDelegate, "cannot create nsGREResProperties"); if(nsnull == mDelegate) return NS_ERROR_OUT_OF_MEMORY; } NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred"); NS_TIMELINE_MARK_TIMER("nsCharsetAlias2:GetPreferred"); nsCAutoString key(aAlias); ToLowerCase(key); // hack for now, have to fix nsGREResProperties, but we can't until // string bundles use UTF8 keys nsAutoString result; nsresult rv = mDelegate->Get(NS_ConvertASCIItoUTF16(key), result); LossyAppendUTF16toASCII(result, oResult); return rv; }
nsresult sbSecurityMixin::DispatchNotificationEvent(const char* aNotificationType, const Scope* aScope, bool aHasAccess) { // NOTE: This method only /tries/ to dispatch the notification event. // If there's no notification document then it fails mostly silently. // This is intentional since there might be cases where this mixin is // used when no notification document is available. NS_ENSURE_ARG_POINTER(aNotificationType); NS_ENSURE_ARG_POINTER(aScope); // TODO: we need to add the notification type to the event eventually // get it? event eventually... LOG(( "sbSecurityMixin::DispatchNotificationEvent(%s)", aNotificationType )); // see if we've got a document to dispatch events to if ( mNotificationDocument ) { LOG(( "sbSecurityMixin::DispatchNotificationEvent - dispatching event" )); nsCOMPtr<sbIRemotePlayer> remotePlayer; nsresult rv = mOuter->GetRemotePlayer(getter_AddRefs(remotePlayer)); // objects that do not return a remote player do not want to trigger notifications because // they are owned by other objects that supercede them in the security hierarchy. if(NS_SUCCEEDED(rv)) { return sbRemotePlayer::DispatchSecurityEvent( mNotificationDocument, remotePlayer, RAPI_EVENT_CLASS, RAPI_EVENT_TYPE, NS_ConvertASCIItoUTF16(aScope->name), aHasAccess, PR_TRUE ); } } else { LOG(( "sbSecurityMixin::DispatchNotificationEvent - not dispatching event" )); NS_WARNING( "sbSecurityMixin::DispatchNotificationEvent didn't have a notification document to dispatch to" ); } return NS_OK; }
void nsXHTMLContentSerializer::AfterElementStart(nsIContent * aContent, nsIDOMElement *aOriginalElement, nsAString& aStr) { nsIAtom *name = aContent->Tag(); if (aContent->GetNameSpaceID() == kNameSpaceID_XHTML && mRewriteEncodingDeclaration && name == nsGkAtoms::head) { // Check if there already are any content-type meta children. // If there are, they will be modified to use the correct charset. // If there aren't, we'll insert one here. PRBool hasMeta = PR_FALSE; PRUint32 i, childCount = aContent->GetChildCount(); for (i = 0; i < childCount; ++i) { nsIContent* child = aContent->GetChildAt(i); if (child->IsHTML() && child->Tag() == nsGkAtoms::meta && child->HasAttr(kNameSpaceID_None, nsGkAtoms::content)) { nsAutoString header; child->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header); if (header.LowerCaseEqualsLiteral("content-type")) { hasMeta = PR_TRUE; break; } } } if (!hasMeta) { AppendNewLineToString(aStr); if (mDoFormat) { AppendIndentation(aStr); } AppendToString(NS_LITERAL_STRING("<meta http-equiv=\"content-type\""), aStr); AppendToString(NS_LITERAL_STRING(" content=\"text/html; charset="), aStr); AppendToString(NS_ConvertASCIItoUTF16(mCharset), aStr); if (mIsHTMLSerializer) AppendToString(NS_LITERAL_STRING("\">"), aStr); else AppendToString(NS_LITERAL_STRING("\" />"), aStr); } } }
already_AddRefed<Blob> BlobSet::GetBlobInternal(nsISupports* aParent, const nsACString& aContentType, ErrorResult& aRv) { nsTArray<RefPtr<BlobImpl>> subImpls(GetBlobImpls()); RefPtr<BlobImpl> blobImpl = MultipartBlobImpl::Create(Move(subImpls), NS_ConvertASCIItoUTF16(aContentType), aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } RefPtr<Blob> blob = Blob::Create(aParent, blobImpl); return blob.forget(); }
NS_IMETHODIMP nsMsgProgress::OpenProgressDialog(nsIDOMWindowInternal *parent, nsIMsgWindow *aMsgWindow, const char *dialogURL, PRBool inDisplayModal, nsISupports *parameters) { nsresult rv; if (aMsgWindow) { SetMsgWindow(aMsgWindow); aMsgWindow->SetStatusFeedback(this); } NS_ENSURE_TRUE(!m_dialog, NS_ERROR_ALREADY_INITIALIZED); NS_ENSURE_ARG_POINTER(dialogURL); NS_ENSURE_ARG_POINTER(parent); // Set up window.arguments[0]... nsCOMPtr<nsISupportsArray> array; rv = NS_NewISupportsArray(getter_AddRefs(array)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); ifptr->SetData(static_cast<nsIMsgProgress*>(this)); ifptr->SetDataIID(&NS_GET_IID(nsIMsgProgress)); array->AppendElement(ifptr); array->AppendElement(parameters); // Open the dialog. nsCOMPtr<nsIDOMWindow> newWindow; nsString chromeOptions(NS_LITERAL_STRING("chrome,titlebar,dependent")); if (inDisplayModal) chromeOptions.AppendLiteral(",modal"); return parent->OpenDialog(NS_ConvertASCIItoUTF16(dialogURL), NS_LITERAL_STRING("_blank"), chromeOptions, array, getter_AddRefs(newWindow)); }
nsresult nsSceneTracker::AssignDefaultSceneNumber(nsIDOMHTMLParagraphElement* aScene, PRBool* outPropagateChanges) { NS_ENSURE_ARG(aScene); nsAutoString className; aScene->GetClassName(className); if (! className.Equals(NS_LITERAL_STRING("sceneheading"))) return NS_ERROR_INVALID_ARG; nsresult rv; PRInt32 scriptRevision = 0; rv = mEditor->GetRevisionNumber(&scriptRevision); if (NS_FAILED(rv)) return rv; PRUint32 sceneNumber[DEFAULT_MAX_SCENE_DEPTH]; PRUint32 sceneNumberLength = DEFAULT_MAX_SCENE_DEPTH; nsCOMPtr<nsIDOMHTMLParagraphElement> prevScene; nsCOMPtr<nsIDOMHTMLParagraphElement> nextScene; rv = GetPriorNumberedScene(aScene, getter_AddRefs(prevScene)); if (NS_FAILED(rv)) return rv; rv = GetNextNumberedScene(aScene, getter_AddRefs(nextScene)); if (NS_FAILED(rv)) return rv; rv = SceneNumberBetweenScenes(prevScene, nextScene, &sceneNumberLength, sceneNumber, outPropagateChanges); if (NS_FAILED(rv)) return rv; nsCAutoString sceneNumberCStr; sceneNumberCStr.Assign(nsPrintfCString("%u", sceneNumber[0])); for (PRUint32 i = 1; i < sceneNumberLength; ++i) sceneNumberCStr.Append(nsPrintfCString(".%u", sceneNumber[i])); aScene->SetAttribute(NS_LITERAL_STRING("scenenumber"), NS_ConvertASCIItoUTF16(sceneNumberCStr)); return NS_OK; }
void nsUICommandCollector::AddEventListeners(nsIDOMEventTarget *window) { for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(kEvents); ++i) { // Attach a capturing event listener to the window. // Use capturing instead of bubbling so that we still record // the event even if propagation is canceled for some reason. // Using NS_LITERAL_STRING in const data is not allowed, so convert here. // This is not performance-sensitive. nsresult rv; rv = window->AddEventListener(NS_ConvertASCIItoUTF16(kEvents[i].event), this, PR_TRUE); if (NS_FAILED(rv)) { MS_LOG(("Couldn't add event listener %s", kEvents[i])); } } }
void nsEudoraWin32::GetAccountName( const char *pSection, nsString& str) { str.Truncate(); nsCString s(pSection); if (s.LowerCaseEqualsLiteral("settings")) { str.AssignLiteral("Eudora "); str.Append(NS_ConvertASCIItoUTF16(pSection)); } else { str.AssignASCII(pSection); if (StringBeginsWith(s, NS_LITERAL_CSTRING("persona-"), nsCaseInsensitiveCStringComparator())) CopyASCIItoUTF16(Substring(s, 8), str); } }
NS_IMETHODIMP nsMsgProgress::OpenProgressDialog(nsIDOMWindow *parentDOMWindow, nsIMsgWindow *aMsgWindow, const char *dialogURL, bool inDisplayModal, nsISupports *parameters) { nsresult rv; if (aMsgWindow) { SetMsgWindow(aMsgWindow); aMsgWindow->SetStatusFeedback(this); } NS_ENSURE_ARG_POINTER(dialogURL); nsCOMPtr<nsPIDOMWindow> parent(do_QueryInterface(parentDOMWindow)); NS_ENSURE_ARG_POINTER(parent); // Set up window.arguments[0]... nsCOMPtr<nsIMutableArray> array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); ifptr->SetData(static_cast<nsIMsgProgress*>(this)); ifptr->SetDataIID(&NS_GET_IID(nsIMsgProgress)); array->AppendElement(ifptr, false); array->AppendElement(parameters, false); // Open the dialog. nsCOMPtr<nsIDOMWindow> newWindow; nsString chromeOptions(NS_LITERAL_STRING("chrome,dependent,centerscreen")); if (inDisplayModal) chromeOptions.AppendLiteral(",modal"); return parent->OpenDialog(NS_ConvertASCIItoUTF16(dialogURL), NS_LITERAL_STRING("_blank"), chromeOptions, array, getter_AddRefs(newWindow)); }
void MediaEngineWebrtcVideoSource::GetName(nsAString& aName) { char deviceName[KMaxDeviceNameLength]; memset(deviceName, 0, KMaxDeviceNameLength); char uniqueId[KMaxUniqueIdLength]; memset(uniqueId, 0, KMaxUniqueIdLength); if(true == mInitDone ) { mViECapture->GetCaptureDevice( mCapIndex, deviceName, KMaxDeviceNameLength, uniqueId, KMaxUniqueIdLength ); aName.Assign(NS_ConvertASCIItoUTF16(deviceName)); } }
// nsIDOMEventListener NS_IMETHODIMP nsUICommandCollector::HandleEvent(nsIDOMEvent* event) { // First check that this is an event type that we expect. // If so, call the appropriate handler method. nsString type; nsresult rv = event->GetType(type); NS_ENSURE_SUCCESS(rv, rv); for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(kEvents); ++i) { if (NS_ConvertASCIItoUTF16(kEvents[i].event).Equals(type)) { return (this->*(kEvents[i].handler))(event); } } MS_LOG(("UICommandCollector: Unexpected event type %s received", NS_ConvertUTF16toUTF8(type).get())); return NS_ERROR_UNEXPECTED; }
void WebGLProgram::GetActiveUniformBlockName(GLuint uniformBlockIndex, nsAString& retval) const { if (!IsLinked()) { mContext->ErrorInvalidOperation("getActiveUniformBlockName: `program` must be linked."); return; } const webgl::LinkedProgramInfo* linkInfo = LinkInfo(); GLuint uniformBlockCount = (GLuint) linkInfo->uniformBlocks.size(); if (uniformBlockIndex >= uniformBlockCount) { mContext->ErrorInvalidValue("getActiveUniformBlockName: index %u invalid.", uniformBlockIndex); return; } const webgl::UniformBlockInfo* blockInfo = linkInfo->uniformBlocks[uniformBlockIndex]; retval.Assign(NS_ConvertASCIItoUTF16(blockInfo->mBaseUserName)); }
NS_IMETHODIMP nsXMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument, nsAString& aStr) { NS_ENSURE_ARG_POINTER(aDocument); nsCOMPtr<nsIDocument> doc(do_QueryInterface(aDocument)); if (!doc) { return NS_OK; } nsAutoString version, encoding, standalone; doc->GetXMLDeclaration(version, encoding, standalone); if (version.IsEmpty()) return NS_OK; // A declaration must have version, or there is no decl NS_NAMED_LITERAL_STRING(endQuote, "\""); aStr += NS_LITERAL_STRING("<?xml version=\"") + version + endQuote; if (!mCharset.IsEmpty()) { aStr += NS_LITERAL_STRING(" encoding=\"") + NS_ConvertASCIItoUTF16(mCharset) + endQuote; } // Otherwise just don't output an encoding attr. Not that we expect // mCharset to ever be empty. #ifdef DEBUG else { NS_WARNING("Empty mCharset? How come?"); } #endif if (!standalone.IsEmpty()) { aStr += NS_LITERAL_STRING(" standalone=\"") + standalone + endQuote; } aStr.AppendLiteral("?>"); mAddNewline = PR_TRUE; return NS_OK; }
void AndroidContentController::HandleSingleTap(const CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid) { // This function will get invoked first on the Java UI thread, and then // again on the main thread (because of the code in ChromeProcessController:: // HandleSingleTap). We want to post the SingleTap message once; it can be // done from either thread but we need access to the callback transform // so we do it from the main thread. if (NS_IsMainThread()) { CSSPoint point = mozilla::layers::APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid); nsIContent* content = nsLayoutUtils::FindContentFor(aGuid.mScrollId); nsIPresShell* shell = content ? mozilla::layers::APZCCallbackHelper::GetRootContentDocumentPresShellForContent(content) : nullptr; if (shell && shell->ScaleToResolution()) { // We need to convert from the root document to the root content document, // by unapplying the resolution that's on the content document. const float resolution = shell->GetResolution(); point.x /= resolution; point.y /= resolution; } CSSIntPoint rounded = RoundedToInt(point); nsAppShell::PostEvent([rounded] { nsCOMPtr<nsIObserverService> obsServ = mozilla::services::GetObserverService(); if (!obsServ) { return; } nsPrintfCString data("{\"x\":%d,\"y\":%d}", rounded.x, rounded.y); obsServ->NotifyObservers(nullptr, "Gesture:SingleTap", NS_ConvertASCIItoUTF16(data).get()); }); } ChromeProcessController::HandleSingleTap(aPoint, aModifiers, aGuid); }
nsresult nsListCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams) { NS_ASSERTION(aEditor, "Need editor here"); bool bMixed; PRUnichar *tagStr; nsresult rv = GetListState(aEditor,&bMixed, &tagStr); NS_ENSURE_SUCCESS(rv, rv); // Need to use mTagName???? bool inList = (0 == nsCRT::strcmp(tagStr, NS_ConvertASCIItoUTF16(mTagName).get())); aParams->SetBooleanValue(STATE_ALL, !bMixed && inList); aParams->SetBooleanValue(STATE_MIXED, bMixed); aParams->SetBooleanValue(STATE_ENABLED, true); if (tagStr) NS_Free(tagStr); return NS_OK; }
nsresult nsMsgOfflineManager::ShowStatus(const char *statusMsgName) { if (!mStringBundle) { nsCOMPtr<nsIStringBundleService> sBundleService = mozilla::services::GetStringBundleService(); NS_ENSURE_TRUE(sBundleService, NS_ERROR_UNEXPECTED); sBundleService->CreateBundle(MESSENGER_STRING_URL, getter_AddRefs(mStringBundle)); return NS_OK; } nsString statusString; nsresult res = mStringBundle->GetStringFromName(NS_ConvertASCIItoUTF16(statusMsgName).get(), getter_Copies(statusString)); if (NS_SUCCEEDED(res) && m_statusFeedback) m_statusFeedback->ShowStatusString(statusString); return res; }
void nsEudoraWin32::SetIdentities(nsIMsgAccountManager *accMgr, nsIMsgAccount *acc, const char *pSection, const char *pIniFile, const char *userName, const char *serverName, char *pBuff) { nsCAutoString realName; nsCAutoString email; nsCAutoString server; DWORD valSize; nsresult rv; valSize = ::GetPrivateProfileString( pSection, "RealName", "", pBuff, kIniValueSize, pIniFile); if (valSize) realName = pBuff; valSize = ::GetPrivateProfileString( pSection, "SMTPServer", "", pBuff, kIniValueSize, pIniFile); if (valSize) server = pBuff; valSize = ::GetPrivateProfileString( pSection, "ReturnAddress", "", pBuff, kIniValueSize, pIniFile); if (valSize) email = pBuff; nsCOMPtr<nsIMsgIdentity> id; rv = accMgr->CreateIdentity( getter_AddRefs( id)); if (id) { nsAutoString fullName; fullName.Assign(NS_ConvertASCIItoUTF16(realName)); id->SetFullName(fullName); id->SetIdentityName(fullName); if (email.IsEmpty()) { email = userName; email += "@"; email += serverName; } id->SetEmail(email); acc->AddIdentity( id); IMPORT_LOG0( "Created identity and added to the account\n"); IMPORT_LOG1( "\tname: %s\n", realName.get()); IMPORT_LOG1( "\temail: %s\n", email.get()); } SetSmtpServer( accMgr, acc, server.get(), userName); }