static void DisplayError(void) { nsresult rv; nsCOMPtr<nsIPromptService> promptService = do_GetService("@mozilla.org/embedcomp/prompt-service;1"); if (!promptService) return; nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID); if (!bundleService) return; nsCOMPtr<nsIStringBundle> bundle; bundleService->CreateBundle("chrome://autoconfig/locale/autoconfig.properties", getter_AddRefs(bundle)); if (!bundle) return; nsXPIDLString title; rv = bundle->GetStringFromName(MOZ_UTF16("readConfigTitle"), getter_Copies(title)); if (NS_FAILED(rv)) return; nsXPIDLString err; rv = bundle->GetStringFromName(MOZ_UTF16("readConfigMsg"), getter_Copies(err)); if (NS_FAILED(rv)) return; promptService->Alert(nullptr, title.get(), err.get()); }
void mozTXTToHTMLConv::CompleteAbbreviatedURL(const char16_t * aInString, int32_t aInLength, const uint32_t pos, nsString& aOutString) { NS_ASSERTION(int32_t(pos) < aInLength, "bad args to CompleteAbbreviatedURL, see bug #190851"); if (int32_t(pos) >= aInLength) return; if (aInString[pos] == '@') { // only pre-pend a mailto url if the string contains a .domain in it.. //i.e. we want to linkify [email protected] but not "let's meet @8pm" nsDependentString inString(aInString, aInLength); if (inString.FindChar('.', pos) != kNotFound) // if we have a '.' after the @ sign.... { aOutString.AssignLiteral("mailto:"); aOutString += aInString; } } else if (aInString[pos] == '.') { if (ItMatchesDelimited(aInString, aInLength, MOZ_UTF16("www."), 4, LT_IGNORE, LT_IGNORE)) { aOutString.AssignLiteral("http://"); aOutString += aInString; } else if (ItMatchesDelimited(aInString,aInLength, MOZ_UTF16("ftp."), 4, LT_IGNORE, LT_IGNORE)) { aOutString.AssignLiteral("ftp://"); aOutString += aInString; } } }
nsresult WebSocket::ConsoleError() { NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread"); nsAutoCString targetSpec; nsresult rv = mURI->GetSpec(targetSpec); if (NS_FAILED(rv)) { NS_WARNING("Failed to get targetSpec"); } else { NS_ConvertUTF8toUTF16 specUTF16(targetSpec); const char16_t* formatStrings[] = { specUTF16.get() }; if (mReadyState < WebSocket::OPEN) { PrintErrorOnConsole("chrome://global/locale/appstrings.properties", MOZ_UTF16("connectionFailure"), formatStrings, ArrayLength(formatStrings)); } else { PrintErrorOnConsole("chrome://global/locale/appstrings.properties", MOZ_UTF16("netInterrupt"), formatStrings, ArrayLength(formatStrings)); } } /// todo some specific errors - like for message too large return rv; }
NS_IMETHODIMP nsNSSDialogs::NotifyCACertExists(nsIInterfaceRequestor *ctx) { nsresult rv; nsCOMPtr<nsIPromptService> promptSvc(do_GetService(NS_PROMPTSERVICE_CONTRACTID)); if (!promptSvc) return NS_ERROR_FAILURE; // Get the parent window for the dialog nsCOMPtr<nsIDOMWindow> parent = do_GetInterface(ctx); nsAutoString title; rv = mPIPStringBundle->GetStringFromName(MOZ_UTF16("caCertExistsTitle"), getter_Copies(title)); NS_ENSURE_SUCCESS(rv, rv); nsAutoString msg; rv = mPIPStringBundle->GetStringFromName(MOZ_UTF16("caCertExistsMessage"), getter_Copies(msg)); NS_ENSURE_SUCCESS(rv, rv); rv = promptSvc->Alert(parent, title.get(), msg.get()); return rv; }
nsresult nsAutoConfig::PromptForEMailAddress(nsACString &emailAddress) { nsresult rv; nsCOMPtr<nsIPromptService> promptService = do_GetService("@mozilla.org/embedcomp/prompt-service;1", &rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIStringBundle> bundle; rv = bundleService->CreateBundle("chrome://autoconfig/locale/autoconfig.properties", getter_AddRefs(bundle)); NS_ENSURE_SUCCESS(rv, rv); nsXPIDLString title; rv = bundle->GetStringFromName(MOZ_UTF16("emailPromptTitle"), getter_Copies(title)); NS_ENSURE_SUCCESS(rv, rv); nsXPIDLString err; rv = bundle->GetStringFromName(MOZ_UTF16("emailPromptMsg"), getter_Copies(err)); NS_ENSURE_SUCCESS(rv, rv); bool check = false; nsXPIDLString emailResult; bool success; rv = promptService->Prompt(nullptr, title.get(), err.get(), getter_Copies(emailResult), nullptr, &check, &success); if (!success) return NS_ERROR_FAILURE; NS_ENSURE_SUCCESS(rv, rv); LossyCopyUTF16toASCII(emailResult, emailAddress); return NS_OK; }
void nsNNTPNewsgroupList::UpdateStatus(bool filtering, int32_t numDLed, int32_t totToDL) { int32_t numerator = (filtering ? m_currentXHDRIndex + 1 : 1) * numDLed; int32_t denominator = (m_filterHeaders.Length() + 1) * totToDL; int32_t percent = numerator * 100 / denominator; nsAutoString numDownloadedStr; numDownloadedStr.AppendInt(numDLed); nsAutoString totalToDownloadStr; totalToDownloadStr.AppendInt(totToDL); nsAutoString newsgroupName; nsresult rv = m_newsFolder->GetUnicodeName(newsgroupName); if (!NS_SUCCEEDED(rv)) return; nsString statusString; nsCOMPtr<nsIStringBundleService> bundleService = mozilla::services::GetStringBundleService(); if (!bundleService) return; nsCOMPtr<nsIStringBundle> bundle; rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle)); if (!NS_SUCCEEDED(rv)) return; if (filtering) { NS_ConvertUTF8toUTF16 header(m_filterHeaders[m_currentXHDRIndex]); const char16_t *formatStrings[4] = { header.get(), numDownloadedStr.get(), totalToDownloadStr.get(), newsgroupName.get() }; rv = bundle->FormatStringFromName(MOZ_UTF16("newNewsgroupFilteringHeaders"), formatStrings, 4, getter_Copies(statusString)); } else { const char16_t *formatStrings[3] = { numDownloadedStr.get(), totalToDownloadStr.get(), newsgroupName.get() }; rv = bundle->FormatStringFromName(MOZ_UTF16("newNewsgroupHeaders"), formatStrings, 3, getter_Copies(statusString)); } if (!NS_SUCCEEDED(rv)) return; SetProgressStatus(statusString.get()); m_lastStatusUpdate = PR_Now(); // only update the progress meter if it has changed if (percent != m_lastPercent) { SetProgressBarPercent(percent); m_lastPercent = percent; } }
void nsSVGTransform::GetValueAsString(nsAString& aValue) const { char16_t buf[256]; switch (mType) { case SVG_TRANSFORM_TRANSLATE: // The spec say that if Y is not provided, it is assumed to be zero. if (mMatrix.y0 != 0) nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t), MOZ_UTF16("translate(%g, %g)"), mMatrix.x0, mMatrix.y0); else nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t), MOZ_UTF16("translate(%g)"), mMatrix.x0); break; case SVG_TRANSFORM_ROTATE: if (mOriginX != 0.0f || mOriginY != 0.0f) nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t), MOZ_UTF16("rotate(%g, %g, %g)"), mAngle, mOriginX, mOriginY); else nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t), MOZ_UTF16("rotate(%g)"), mAngle); break; case SVG_TRANSFORM_SCALE: if (mMatrix.xx != mMatrix.yy) nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t), MOZ_UTF16("scale(%g, %g)"), mMatrix.xx, mMatrix.yy); else nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t), MOZ_UTF16("scale(%g)"), mMatrix.xx); break; case SVG_TRANSFORM_SKEWX: nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t), MOZ_UTF16("skewX(%g)"), mAngle); break; case SVG_TRANSFORM_SKEWY: nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t), MOZ_UTF16("skewY(%g)"), mAngle); break; case SVG_TRANSFORM_MATRIX: nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t), MOZ_UTF16("matrix(%g, %g, %g, %g, %g, %g)"), mMatrix.xx, mMatrix.yx, mMatrix.xy, mMatrix.yy, mMatrix.x0, mMatrix.y0); break; default: buf[0] = '\0'; NS_ERROR("unknown transformation type"); break; } aValue.Assign(buf); }
static void PgpMimeGetNeedsAddonString(nsCString &aResult) { aResult.AssignLiteral("???"); nsCOMPtr<nsIStringBundleService> stringBundleService = mozilla::services::GetStringBundleService(); nsCOMPtr<nsIStringBundle> stringBundle; nsresult rv = stringBundleService->CreateBundle(PGPMIME_PROPERTIES_URL, getter_AddRefs(stringBundle)); if (NS_FAILED(rv)) return; nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); if (NS_FAILED(rv)) return; nsCString url; if (NS_FAILED(prefs->GetCharPref("mail.pgpmime.addon_url", getter_Copies(url)))) return; NS_ConvertUTF8toUTF16 url16(url); const char16_t *formatStrings[] = { url16.get() }; nsString result; rv = stringBundle->FormatStringFromName(MOZ_UTF16(PGPMIME_STR_NOT_SUPPORTED_ID), formatStrings, 1, getter_Copies(result)); if (NS_FAILED(rv)) return; aResult = NS_ConvertUTF16toUTF8(result); }
nsresult PluginHangUIParent::GetHangUIOwnerWindowHandle(NativeWindowHandle& windowHandle) { windowHandle = nullptr; nsresult rv; nsCOMPtr<nsIWindowMediator> winMediator(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDOMWindow> navWin; rv = winMediator->GetMostRecentWindow(MOZ_UTF16("navigator:browser"), getter_AddRefs(navWin)); NS_ENSURE_SUCCESS(rv, rv); if (!navWin) { return NS_ERROR_FAILURE; } nsCOMPtr<nsIWidget> widget = WidgetUtils::DOMWindowToWidget(navWin); if (!widget) { return NS_ERROR_FAILURE; } windowHandle = reinterpret_cast<NativeWindowHandle>(widget->GetNativeData(NS_NATIVE_WINDOW)); if (!windowHandle) { return NS_ERROR_FAILURE; } return NS_OK; }
NS_IMETHODIMP nsBeckyFilters::AutoLocate(char16_t **aDescription, nsIFile **aLocation, bool *_retval) { NS_ENSURE_ARG_POINTER(aLocation); NS_ENSURE_ARG_POINTER(_retval); if (aDescription) { *aDescription = nsBeckyStringBundle::GetStringByName(MOZ_UTF16("BeckyImportDescription")); } *aLocation = nullptr; *_retval = false; nsresult rv; nsCOMPtr<nsIFile> location; rv = GetDefaultFilterLocation(getter_AddRefs(location)); if (NS_FAILED(rv)) location = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv); else *_retval = true; location.forget(aLocation); return NS_OK; }
bool RootList::init(HandleObject debuggees) { MOZ_ASSERT(debuggees && JS::dbg::IsDebugger(ObjectValue(*debuggees))); js::Debugger *dbg = js::Debugger::fromJSObject(debuggees); ZoneSet debuggeeZones; if (!debuggeeZones.init()) return false; for (js::WeakGlobalObjectSet::Range r = dbg->allDebuggees(); !r.empty(); r.popFront()) { if (!debuggeeZones.put(r.front()->zone())) return false; } if (!init(debuggeeZones)) return false; // Ensure that each of our debuggee globals are in the root list. for (js::WeakGlobalObjectSet::Range r = dbg->allDebuggees(); !r.empty(); r.popFront()) { if (!addRoot(JS::ubi::Node(static_cast<JSObject *>(r.front())), MOZ_UTF16("debuggee global"))) { return false; } } return true; }
namespace ubi { template<> class Concrete<FakeNode> : public Base { protected: explicit Concrete(FakeNode* ptr) : Base(ptr) { } FakeNode& get() const { return *static_cast<FakeNode*>(ptr); } public: static void construct(void* storage, FakeNode* ptr) { new (storage) Concrete(ptr); } UniquePtr<EdgeRange> edges(JSRuntime* rt, bool wantNames) const override { return UniquePtr<EdgeRange>(js_new<PreComputedEdgeRange>(get().edges)); } Node::Size size(mozilla::MallocSizeOf) const override { return 1; } static const char16_t concreteTypeName[]; const char16_t* typeName() const override { return concreteTypeName; } }; const char16_t Concrete<FakeNode>::concreteTypeName[] = MOZ_UTF16("FakeNode"); } // namespace ubi
void nsXREDirProvider::DoShutdown() { if (mProfileNotified) { nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService(); NS_ASSERTION(obsSvc, "No observer service?"); if (obsSvc) { static const char16_t kShutdownPersist[] = MOZ_UTF16("shutdown-persist"); obsSvc->NotifyObservers(nullptr, "profile-change-net-teardown", kShutdownPersist); obsSvc->NotifyObservers(nullptr, "profile-change-teardown", kShutdownPersist); // Phase 2c: Now that things are torn down, force JS GC so that things which depend on // resources which are about to go away in "profile-before-change" are destroyed first. JSRuntime *rt = xpc::GetJSRuntime(); if (rt) { JS_GC(rt); } // Phase 3: Notify observers of a profile change obsSvc->NotifyObservers(nullptr, "profile-before-change", kShutdownPersist); obsSvc->NotifyObservers(nullptr, "profile-before-change2", kShutdownPersist); } mProfileNotified = false; } }
NS_IMETHODIMP nsAppleMailImportModule::GetImportInterface(const char *aImportType, nsISupports **aInterface) { NS_ENSURE_ARG_POINTER(aImportType); NS_ENSURE_ARG_POINTER(aInterface); *aInterface = nullptr; nsresult rv = NS_ERROR_NOT_AVAILABLE; if (!strcmp(aImportType, "mail")) { nsCOMPtr<nsIImportMail> mail(do_CreateInstance(NS_APPLEMAILIMPL_CONTRACTID, &rv)); if (NS_SUCCEEDED(rv)) { nsCOMPtr<nsIImportService> impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv)); if (NS_SUCCEEDED(rv)) { nsCOMPtr<nsIImportGeneric> generic; rv = impSvc->CreateNewGenericMail(getter_AddRefs(generic)); if (NS_SUCCEEDED(rv)) { nsAutoString name; rv = mBundle->GetStringFromName(MOZ_UTF16("ApplemailImportName"), getter_Copies(name)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsISupportsString> nameString(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); nameString->SetData(name); generic->SetData("name", nameString); generic->SetData("mailInterface", mail); generic.forget(aInterface); } } } } return rv; }
void nsNNTPNewsgroupList::SetProgressStatus(const char16_t *aMessage) { if (!m_runningURL) return; nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL); if (mailnewsUrl) { nsCOMPtr <nsIMsgStatusFeedback> feedback; mailnewsUrl->GetStatusFeedback(getter_AddRefs(feedback)); if (feedback) { // prepending the account name to the status message. nsresult rv; nsCOMPtr <nsIMsgIncomingServer> server; rv = mailnewsUrl->GetServer(getter_AddRefs(server)); NS_ENSURE_SUCCESS_VOID(rv); nsString accountName; server->GetPrettyName(accountName); nsString statusMessage; nsCOMPtr<nsIStringBundleService> sbs = mozilla::services::GetStringBundleService(); nsCOMPtr<nsIStringBundle> bundle; rv = sbs->CreateBundle(MSGS_URL, getter_AddRefs(bundle)); NS_ENSURE_SUCCESS_VOID(rv); const char16_t *params[] = { accountName.get(), aMessage }; bundle->FormatStringFromName(MOZ_UTF16("statusMessage"), params, 2, getter_Copies(statusMessage)); feedback->ShowStatusString(statusMessage); } } }
// static nsHtml5HtmlAttributes* nsHtml5PlainTextUtils::NewLinkAttributes() { nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0); nsString* rel = new nsString(NS_LITERAL_STRING("alternate stylesheet")); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel); nsString* type = new nsString(NS_LITERAL_STRING("text/css")); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type); nsString* href = new nsString( NS_LITERAL_STRING("resource://gre-resources/plaintext.css")); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href); nsresult rv; nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); NS_ASSERTION(NS_SUCCEEDED(rv) && bundleService, "The bundle service could not be loaded"); nsCOMPtr<nsIStringBundle> bundle; rv = bundleService->CreateBundle("chrome://global/locale/browser.properties", getter_AddRefs(bundle)); NS_ASSERTION(NS_SUCCEEDED(rv) && bundle, "chrome://global/locale/browser.properties could not be loaded"); nsXPIDLString title; if (bundle) { bundle->GetStringFromName(MOZ_UTF16("plainText.wordWrap"), getter_Copies(title)); } nsString* titleCopy = new nsString(title); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TITLE, titleCopy); return linkAttrs; }
//--------------------------------------------------- //-- nsPrintData Class Impl //--------------------------------------------------- nsPrintData::nsPrintData(ePrintDataType aType) : mType(aType), mDebugFilePtr(nullptr), mPrintObject(nullptr), mSelectedPO(nullptr), mPrintDocList(0), mIsIFrameSelected(false), mIsParentAFrameSet(false), mOnStartSent(false), mIsAborted(false), mPreparingForPrint(false), mDocWasToBeDestroyed(false), mShrinkToFit(false), mPrintFrameType(nsIPrintSettings::kFramesAsIs), mNumPrintablePages(0), mNumPagesPrinted(0), mShrinkRatio(1.0), mOrigDCScale(1.0), mPPEventListeners(nullptr), mBrandName(nullptr) { MOZ_COUNT_CTOR(nsPrintData); nsCOMPtr<nsIStringBundle> brandBundle; nsCOMPtr<nsIStringBundleService> svc = mozilla::services::GetStringBundleService(); if (svc) { svc->CreateBundle( "chrome://branding/locale/brand.properties", getter_AddRefs( brandBundle ) ); if (brandBundle) { brandBundle->GetStringFromName(MOZ_UTF16("brandShortName"), &mBrandName ); } } if (!mBrandName) { mBrandName = ToNewUnicode(NS_LITERAL_STRING("Mozilla Document")); } }
bool nsMapiHook::IsBlindSendAllowed() { bool enabled = false; bool warn = true; nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); if (prefBranch) { prefBranch->GetBoolPref(PREF_MAPI_WARN_PRIOR_TO_BLIND_SEND, &warn); prefBranch->GetBoolPref(PREF_MAPI_BLIND_SEND_ENABLED, &enabled); } if (!enabled) return false; if (!warn) return true; // Everything is okay. nsresult rv; nsCOMPtr<nsIStringBundleService> bundleService = mozilla::services::GetStringBundleService(); if (!bundleService) return false; nsCOMPtr<nsIStringBundle> bundle; rv = bundleService->CreateBundle(MAPI_PROPERTIES_CHROME, getter_AddRefs(bundle)); if (NS_FAILED(rv) || !bundle) return false; nsString warningMsg; rv = bundle->GetStringFromName(MOZ_UTF16("mapiBlindSendWarning"), getter_Copies(warningMsg)); if (NS_FAILED(rv)) return false; nsString dontShowAgainMessage; rv = bundle->GetStringFromName(MOZ_UTF16("mapiBlindSendDontShowAgain"), getter_Copies(dontShowAgainMessage)); if (NS_FAILED(rv)) return false; nsCOMPtr<nsIPromptService> dlgService(do_GetService(NS_PROMPTSERVICE_CONTRACTID, &rv)); if (NS_FAILED(rv) || !dlgService) return false; bool continueToWarn = true; bool okayToContinue = false; dlgService->ConfirmCheck(nullptr, nullptr, warningMsg.get(), dontShowAgainMessage.get(), &continueToWarn, &okayToContinue); if (!continueToWarn && okayToContinue && prefBranch) prefBranch->SetBoolPref(PREF_MAPI_WARN_PRIOR_TO_BLIND_SEND, false); return okayToContinue; }
void RequestSyncWifiService::Notify(const hal::NetworkInformation& aNetworkInfo) { bool isWifi = aNetworkInfo.isWifi(); if (isWifi == mIsWifi) { return; } mIsWifi = isWifi; nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); if (obs) { obs->NotifyObservers(nullptr, "wifi-state-changed", mIsWifi ? MOZ_UTF16("enabled") : MOZ_UTF16("disabled")); } }
//static bool nsCharsetConverterManager::IsInternal(const nsACString& aCharset) { nsAutoString str; // fully qualify to possibly avoid vtable call nsresult rv = GetCharsetDataImpl(PromiseFlatCString(aCharset).get(), MOZ_UTF16(".isInternal"), str); return NS_SUCCEEDED(rv); }
//----------------------------------------------------------------------------- // CaptivePortalService::nsICaptivePortalCallback //----------------------------------------------------------------------------- NS_IMETHODIMP CaptivePortalService::Prepare() { LOG(("CaptivePortalService::Prepare\n")); // XXX: Finish preparation shouldn't be called until dns and routing is available. if (mCaptivePortalDetector) { mCaptivePortalDetector->FinishPreparation(MOZ_UTF16(kInterfaceName)); } return NS_OK; }
void mozTXTToHTMLConv::UnescapeStr(const char16_t * aInString, int32_t aStartPos, int32_t aLength, nsString& aOutString) { const char16_t * subString = nullptr; for (uint32_t i = aStartPos; int32_t(i) - aStartPos < aLength;) { int32_t remainingChars = i - aStartPos; if (aInString[i] == '&') { subString = &aInString[i]; if (!nsCRT::strncmp(subString, MOZ_UTF16("<"), std::min(4, aLength - remainingChars))) { aOutString.Append(char16_t('<')); i += 4; } else if (!nsCRT::strncmp(subString, MOZ_UTF16(">"), std::min(4, aLength - remainingChars))) { aOutString.Append(char16_t('>')); i += 4; } else if (!nsCRT::strncmp(subString, MOZ_UTF16("&"), std::min(5, aLength - remainingChars))) { aOutString.Append(char16_t('&')); i += 5; } else if (!nsCRT::strncmp(subString, MOZ_UTF16("""), std::min(6, aLength - remainingChars))) { aOutString.Append(char16_t('"')); i += 6; } else { aOutString += aInString[i]; i++; } } else { aOutString += aInString[i]; i++; } } }
// Add the given set of globals as explicit roots in the given roots // list. Returns false on OOM failure. static bool AddGlobalsAsRoots(AutoObjectVector& globals, ubi::RootList& roots) { unsigned length = globals.length(); for (unsigned i = 0; i < length; i++) { if (!roots.addRoot(ubi::Node(globals[i].get()), MOZ_UTF16("heap snapshot global"))) { return false; } } return true; }
void SVGLength::GetValueAsString(nsAString &aValue) const { char16_t buf[24]; nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t), MOZ_UTF16("%g"), (double)mValue); aValue.Assign(buf); nsAutoString unitString; GetUnitString(unitString, mUnit); aValue.Append(unitString); }
NS_IMETHODIMP nsSecurityWarningDialogs::ConfirmPostToInsecureFromSecure(nsIInterfaceRequestor *ctx, bool* _result) { nsresult rv; // The Telemetry clickthrough constant is 1 more than the constant for the dialog. rv = ConfirmDialog(ctx, nullptr, // No preference for this one - it's too important MOZ_UTF16("PostToInsecureFromSecureMessage"), nullptr, nsISecurityUITelemetry::WARNING_CONFIRM_POST_TO_INSECURE_FROM_SECURE, _result); return rv; }
nsresult EventSource::ConsoleError() { nsAutoCString targetSpec; nsresult rv = mSrc->GetSpec(targetSpec); NS_ENSURE_SUCCESS(rv, rv); NS_ConvertUTF8toUTF16 specUTF16(targetSpec); const char16_t *formatStrings[] = { specUTF16.get() }; if (mReadyState == CONNECTING) { rv = PrintErrorOnConsole("chrome://global/locale/appstrings.properties", MOZ_UTF16("connectionFailure"), formatStrings, ArrayLength(formatStrings)); } else { rv = PrintErrorOnConsole("chrome://global/locale/appstrings.properties", MOZ_UTF16("netInterrupt"), formatStrings, ArrayLength(formatStrings)); } NS_ENSURE_SUCCESS(rv, rv); return NS_OK; }
NS_IMETHODIMP PresentationDeviceManager::UpdateDevice(nsIPresentationDevice* aDevice) { NS_ENSURE_ARG(aDevice); MOZ_ASSERT(NS_IsMainThread()); if (NS_WARN_IF(!mDevices.Contains(aDevice))) { return NS_ERROR_FAILURE; } NotifyDeviceChange(aDevice, MOZ_UTF16("update")); return NS_OK; }
bool nsMsgI18Nmultibyte_charset(const char *charset) { nsresult res; nsCOMPtr <nsICharsetConverterManager> ccm = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res); bool result = false; if (NS_SUCCEEDED(res)) { nsAutoString charsetData; res = ccm->GetCharsetData(charset, MOZ_UTF16(".isMultibyte"), charsetData); if (NS_SUCCEEDED(res)) { result = charsetData.LowerCaseEqualsLiteral("true"); } } return result; }
nsresult nsEudoraFilters::Init() { nsresult rv; nsCOMPtr<nsIMsgAccountManager> accMgr = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr <nsIMsgIncomingServer> server; rv = accMgr->GetLocalFoldersServer(getter_AddRefs(server)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr <nsIMsgFolder> localRootFolder; rv = server->GetRootMsgFolder(getter_AddRefs(localRootFolder)); NS_ENSURE_SUCCESS(rv, rv); // we need to call GetSubFolders() so that the folders get initialized // if they are not initialized yet. nsCOMPtr<nsISimpleEnumerator> enumerator; rv = localRootFolder->GetSubFolders(getter_AddRefs(enumerator)); NS_ENSURE_SUCCESS(rv, rv); // Get the name of the folder where one-off imported mail is placed nsAutoString folderName(NS_LITERAL_STRING("Eudora Import")); nsCOMPtr<nsIStringBundleService> bundleService = mozilla::services::GetStringBundleService(); NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED); nsCOMPtr<nsIStringBundle> bundle; rv = bundleService->CreateBundle("chrome://messenger/locale/importMsgs.properties", getter_AddRefs(bundle)); if (NS_SUCCEEDED(rv)) { nsAutoString Eudora(NS_LITERAL_STRING("Eudora")); const char16_t *moduleName[] = { Eudora.get() }; rv = bundle->FormatStringFromName(MOZ_UTF16("ImportModuleFolderName"), moduleName, 1, getter_Copies(folderName)); } localRootFolder->GetChildNamed(folderName, getter_AddRefs(m_pMailboxesRoot)); if (!m_pMailboxesRoot) { // If no "Eudora Import" folder then this is a // migration which just puts it in the root m_pMailboxesRoot = localRootFolder; } return rv; }
// nsIPresentationDeviceListener NS_IMETHODIMP PresentationDeviceManager::AddDevice(nsIPresentationDevice* aDevice) { NS_ENSURE_ARG(aDevice); MOZ_ASSERT(NS_IsMainThread()); if (NS_WARN_IF(mDevices.Contains(aDevice))) { return NS_ERROR_FAILURE; } mDevices.AppendElement(aDevice); aDevice->SetListener(this); NotifyDeviceChange(aDevice, MOZ_UTF16("add")); return NS_OK; }