static void SetStorageKey(nsAutoCString& storageKey, nsCString& hostname, uint32_t aType) { storageKey = hostname; switch (aType) { case nsISiteSecurityService::HEADER_HSTS: storageKey.AppendLiteral(":HSTS"); break; case nsISiteSecurityService::HEADER_HPKP: storageKey.AppendLiteral(":HPKP"); break; default: NS_ASSERTION(false, "SSS:SetStorageKey got invalid type"); } }
/* static */ void nsBaseWidget::debug_DumpPaintEvent(FILE * aFileOut, nsIWidget * aWidget, const nsIntRegion & aRegion, const nsAutoCString & aWidgetName, int32_t aWindowID) { NS_ASSERTION(nullptr != aFileOut,"cmon, null output FILE"); NS_ASSERTION(nullptr != aWidget,"cmon, the widget is null"); if (!debug_GetCachedBoolPref("nglayout.debug.paint_dumping")) return; nsIntRect rect = aRegion.GetBounds(); fprintf(aFileOut, "%4d PAINT widget=%p name=%-12s id=0x%-6x bounds-rect=%3d,%-3d %3d,%-3d", _GetPrintCount(), (void *) aWidget, aWidgetName.get(), aWindowID, rect.x, rect.y, rect.width, rect.height ); fprintf(aFileOut,"\n"); }
/* static */ void nsBaseWidget::debug_DumpEvent(FILE * aFileOut, nsIWidget * aWidget, nsGUIEvent * aGuiEvent, const nsAutoCString & aWidgetName, int32_t aWindowID) { if (aGuiEvent->message == NS_MOUSE_MOVE) { if (!debug_GetCachedBoolPref("nglayout.debug.motion_event_dumping")) return; } if (aGuiEvent->message == NS_MOUSE_ENTER || aGuiEvent->message == NS_MOUSE_EXIT) { if (!debug_GetCachedBoolPref("nglayout.debug.crossing_event_dumping")) return; } if (!debug_GetCachedBoolPref("nglayout.debug.event_dumping")) return; NS_LossyConvertUTF16toASCII tempString(debug_GuiEventToString(aGuiEvent).get()); fprintf(aFileOut, "%4d %-26s widget=%-8p name=%-12s id=0x%-6x refpt=%d,%d\n", _GetPrintCount(), tempString.get(), (void *) aWidget, aWidgetName.get(), aWindowID, aGuiEvent->refPoint.x, aGuiEvent->refPoint.y); }
//------------------------------------------------------------------------- void nsFilePicker::GetFileSystemCharset(nsCString & fileSystemCharset) { static nsAutoCString aCharset; nsresult rv; if (aCharset.Length() < 1) { nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, aCharset); NS_ASSERTION(NS_SUCCEEDED(rv), "error getting platform charset"); if (NS_FAILED(rv)) aCharset.AssignLiteral("IBM850"); } fileSystemCharset = aCharset; }
bool GeckoChildProcessHost::PerformAsyncLaunch(std::vector<std::string> aExtraOpts, base::ProcessArchitecture arch) { // If NSPR log files are not requested, we're done. const char* origNSPRLogName = PR_GetEnv("NSPR_LOG_FILE"); const char* origMozLogName = PR_GetEnv("MOZ_LOG_FILE"); if (!origNSPRLogName && !origMozLogName) { return PerformAsyncLaunchInternal(aExtraOpts, arch); } ++mChildCounter; // remember original value so we can restore it. // - Note: this code is not called re-entrantly, nor are restoreOrig*LogName // or mChildCounter touched by any other thread, so this is safe. static nsAutoCString restoreOrigNSPRLogName; static nsAutoCString restoreOrigMozLogName; if (origNSPRLogName) { if (restoreOrigNSPRLogName.IsEmpty()) { restoreOrigNSPRLogName.AssignLiteral("NSPR_LOG_FILE="); restoreOrigNSPRLogName.Append(origNSPRLogName); } SetChildLogName("NSPR_LOG_FILE=", origNSPRLogName); } if (origMozLogName) { if (restoreOrigMozLogName.IsEmpty()) { restoreOrigMozLogName.AssignLiteral("MOZ_LOG_FILE="); restoreOrigMozLogName.Append(origMozLogName); } SetChildLogName("MOZ_LOG_FILE=", origMozLogName); } bool retval = PerformAsyncLaunchInternal(aExtraOpts, arch); // Revert to original value if (origNSPRLogName) { PR_SetEnv(restoreOrigNSPRLogName.get()); } if (origMozLogName) { PR_SetEnv(restoreOrigMozLogName.get()); } return retval; }
static nsresult GetNSSProfilePath(nsAutoCString& aProfilePath) { aProfilePath.Truncate(); const char* dbDirOverride = getenv("MOZPSM_NSSDBDIR_OVERRIDE"); if (dbDirOverride && strlen(dbDirOverride) > 0) { MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Using specified MOZPSM_NSSDBDIR_OVERRIDE as NSS DB dir: %s\n", dbDirOverride)); aProfilePath.Assign(dbDirOverride); return NS_OK; } nsCOMPtr<nsIFile> profileFile; nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profileFile)); if (NS_FAILED(rv)) { NS_WARNING("NSS will be initialized without a profile directory. " "Some things may not work as expected."); return NS_OK; } #if defined(XP_WIN) // Native path will drop Unicode characters that cannot be mapped to system's // codepage, using short (canonical) path as workaround. nsCOMPtr<nsILocalFileWin> profileFileWin(do_QueryInterface(profileFile)); if (!profileFileWin) { MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("Could not get nsILocalFileWin for profile directory.\n")); return NS_ERROR_FAILURE; } rv = profileFileWin->GetNativeCanonicalPath(aProfilePath); #else rv = profileFile->GetNativePath(aProfilePath); #endif if (NS_FAILED(rv)) { MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("Could not get native path for profile directory.\n")); return rv; } MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("NSS profile at '%s'\n", aProfilePath.get())); return NS_OK; }
// Charset used by the file system. const char * nsMsgI18NFileSystemCharset() { /* Get a charset used for the file. */ static nsAutoCString fileSystemCharset; if (fileSystemCharset.IsEmpty()) { nsresult rv; nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, fileSystemCharset); } if (NS_FAILED(rv)) fileSystemCharset.Assign("ISO-8859-1"); } return fileSystemCharset.get(); }
static nsresult GetHostPortKey(TransportSecurityInfo* infoObject, nsAutoCString &result) { nsresult rv; result.Truncate(); nsXPIDLCString hostName; rv = infoObject->GetHostName(getter_Copies(hostName)); NS_ENSURE_SUCCESS(rv, rv); int32_t port; rv = infoObject->GetPort(&port); NS_ENSURE_SUCCESS(rv, rv); result.Assign(hostName); result.Append(':'); result.AppendInt(port); return NS_OK; }
bool nsDefaultURIFixup::IsDomainWhitelisted(const nsAutoCString aAsciiHost, const uint32_t aDotLoc) { if (sDNSFirstForSingleWords) { return true; } // Check if this domain is whitelisted as an actual // domain (which will prevent a keyword query) // NB: any processing of the host here should stay in sync with // code in the front-end(s) that set the pref. nsAutoCString pref("browser.fixup.domainwhitelist."); if (aDotLoc == aAsciiHost.Length() - 1) { pref.Append(Substring(aAsciiHost, 0, aAsciiHost.Length() - 1)); } else { pref.Append(aAsciiHost); } return Preferences::GetBool(pref.get(), false); }
static inline bool canonicalizeBase(nsAutoCString &spec, nsACString &out) { nsAutoCString greBase, appBase; nsresult rv = mozilla::Omnijar::GetURIString(mozilla::Omnijar::GRE, greBase); if (NS_FAILED(rv) || !greBase.Length()) return false; rv = mozilla::Omnijar::GetURIString(mozilla::Omnijar::APP, appBase); if (NS_FAILED(rv)) return false; bool underGre = !greBase.Compare(spec.get(), false, greBase.Length()); bool underApp = appBase.Length() && !appBase.Compare(spec.get(), false, appBase.Length()); if (!underGre && !underApp) return false; /** * At this point, if both underGre and underApp are true, it can be one * of the two following cases: * - the GRE directory points to a subdirectory of the APP directory, * meaning spec points under GRE. * - the APP directory points to a subdirectory of the GRE directory, * meaning spec points under APP. * Checking the GRE and APP path length is enough to know in which case * we are. */ if (underGre && underApp && greBase.Length() < appBase.Length()) underGre = false; out.Append("/resource/"); out.Append(baseName[underGre ? mozilla::Omnijar::GRE : mozilla::Omnijar::APP]); out.Append(Substring(spec, underGre ? greBase.Length() : appBase.Length())); return true; }
/* static */ void nsBaseWidget::debug_DumpInvalidate(FILE * aFileOut, nsIWidget * aWidget, const nsIntRect * aRect, const nsAutoCString & aWidgetName, int32_t aWindowID) { if (!debug_GetCachedBoolPref("nglayout.debug.invalidate_dumping")) return; NS_ASSERTION(nullptr != aFileOut,"cmon, null output FILE"); NS_ASSERTION(nullptr != aWidget,"cmon, the widget is null"); fprintf(aFileOut, "%4d Invalidate widget=%p name=%-12s id=0x%-6x", _GetPrintCount(), (void *) aWidget, aWidgetName.get(), aWindowID); if (aRect) { fprintf(aFileOut, " rect=%3d,%-3d %3d,%-3d", aRect->x, aRect->y, aRect->width, aRect->height); } else { fprintf(aFileOut, " rect=%-15s", "none"); } fprintf(aFileOut,"\n"); }
mScopeObject = aScopeObject; } NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSEventListener) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSEventListener) if (tmp->mScopeObject) { tmp->mScopeObject = nullptr; mozilla::DropJSObjects(tmp); NS_IMPL_CYCLE_COLLECTION_UNLINK(mContext) } tmp->mHandler.ForgetHandler(); NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSEventListener) if (MOZ_UNLIKELY(cb.WantDebugInfo()) && tmp->mEventName) { nsAutoCString name; name.AppendLiteral("nsJSEventListener handlerName="); name.Append( NS_ConvertUTF16toUTF8(nsDependentAtomString(tmp->mEventName)).get()); cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name.get()); } else { NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsJSEventListener, tmp->mRefCnt.get()) } NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContext) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mHandler.Ptr()) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSEventListener) NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mScopeObject) NS_IMPL_CYCLE_COLLECTION_TRACE_END
void nsTestLog::PrintError(const char * aCall, const char * aMessage) { const char * trace = mTrace.get(); printf("ERROR at %s%s reason: %s.\n", trace, aCall, aMessage); }
void nsTestLog::PrintError(const char * aCall, const int aError) { const char * trace = mTrace.get(); printf("ERROR at %s%s code=0x%x.\n", trace, aCall, aError); }
void nsTestLog::DelTrace(const char * aTrace) { mTrace.Truncate(mTrace.Length() - strlen(aTrace) - strlen(kTraceDelimiter)); }
void nsTestLog::AddTrace(const char * aTrace) { mTrace.Append(aTrace); mTrace.Append(kTraceDelimiter); }