本文整理汇总了C++中NS_ENSURE_ARG_POINTER函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_ENSURE_ARG_POINTER函数的具体用法?C++ NS_ENSURE_ARG_POINTER怎么用?C++ NS_ENSURE_ARG_POINTER使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_ENSURE_ARG_POINTER函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NS_ENSURE_ARG_POINTER
nsresult
nsJARInputStream::InitDirectory(nsZipArchive* aZip,
const nsACString& aJarDirSpec,
const char* aDir)
{
NS_ENSURE_ARG_POINTER(aZip);
NS_ENSURE_ARG_POINTER(aDir);
// Mark it as closed, in case something fails in initialisation
mClosed = PR_TRUE;
mDirectory = PR_TRUE;
// Keep the zipReader for getting the actual zipItems
mZip = aZip;
nsZipFind *find;
nsresult rv;
// We can get aDir's contents as strings via FindEntries
// with the following pattern (see nsIZipReader.findEntries docs)
// assuming dirName is properly escaped:
//
// dirName + "?*~" + dirName + "?*/?*"
nsDependentCString dirName(aDir);
mNameLen = dirName.Length();
// iterate through dirName and copy it to escDirName, escaping chars
// which are special at the "top" level of the regexp so FindEntries
// works correctly
nsCAutoString escDirName;
const char* curr = dirName.BeginReading();
const char* end = dirName.EndReading();
while (curr != end) {
switch (*curr) {
case '*':
case '?':
case '$':
case '[':
case ']':
case '^':
case '~':
case '(':
case ')':
case '\\':
escDirName.Append('\\');
// fall through
default:
escDirName.Append(*curr);
}
++curr;
}
nsCAutoString pattern = escDirName + NS_LITERAL_CSTRING("?*~") +
escDirName + NS_LITERAL_CSTRING("?*/?*");
rv = aZip->FindInit(pattern.get(), &find);
if (NS_FAILED(rv)) return rv;
const char *name;
while ((rv = find->FindNext( &name )) == NS_OK) {
// No need to copy string, just share the one from nsZipArchive
mArray.AppendCString(nsDependentCString(name));
}
delete find;
if (rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST && NS_FAILED(rv)) {
return NS_ERROR_FAILURE; // no error translation
}
// Sort it
mArray.Sort();
mBuffer.AssignLiteral("300: ");
mBuffer.Append(aJarDirSpec);
mBuffer.AppendLiteral("\n200: filename content-length last-modified file-type\n");
// Open for reading
mClosed = PR_FALSE;
mCurPos = 0;
mArrPos = 0;
return NS_OK;
}
示例2: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP nsPop3Sink::GetFolder(nsIMsgFolder **aFolder)
{
NS_ENSURE_ARG_POINTER(aFolder);
NS_IF_ADDREF(*aFolder = m_folder);
return NS_OK;
}
示例3: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP
nsFilePicker::Show(PRInt16 *aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
nsXPIDLCString title;
title.Adopt(ToNewUTF8String(mTitle));
GtkWindow *parent_widget = get_gtk_window_for_nsiwidget(mParentWidget);
GtkFileChooserAction action = GetGtkFileChooserAction(mMode);
const gchar *accept_button = (mMode == GTK_FILE_CHOOSER_ACTION_SAVE)
? GTK_STOCK_SAVE : GTK_STOCK_OPEN;
GtkWidget *file_chooser =
_gtk_file_chooser_dialog_new(title, parent_widget, action,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
accept_button, GTK_RESPONSE_ACCEPT,
NULL);
if (parent_widget && parent_widget->group) {
gtk_window_group_add_window(parent_widget->group, GTK_WINDOW(file_chooser));
}
if (mMode == nsIFilePicker::modeOpenMultiple) {
_gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER(file_chooser), TRUE);
} else if (mMode == nsIFilePicker::modeSave) {
char *default_filename = ToNewUTF8String(mDefault);
_gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(file_chooser),
NS_STATIC_CAST(const gchar*, default_filename));
nsMemory::Free(default_filename);
}
gtk_dialog_set_default_response(GTK_DIALOG(file_chooser), GTK_RESPONSE_ACCEPT);
nsCAutoString directory;
if (mDisplayDirectory) {
mDisplayDirectory->GetNativePath(directory);
} else if (mPrevDisplayDirectory) {
mPrevDisplayDirectory->GetNativePath(directory);
}
if (!directory.IsEmpty()) {
_gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(file_chooser),
directory.get());
}
PRInt32 count = mFilters.Count();
for (PRInt32 i = 0; i < count; ++i) {
// This is fun... the GTK file picker does not accept a list of filters
// so we need to split out each string, and add it manually.
char **patterns = g_strsplit(mFilters[i]->get(), ";", -1);
if (!patterns) {
return NS_ERROR_OUT_OF_MEMORY;
}
GtkFileFilter *filter = _gtk_file_filter_new ();
for (int j = 0; patterns[j] != NULL; ++j) {
_gtk_file_filter_add_pattern (filter, g_strstrip (patterns[j]));
}
g_strfreev(patterns);
if (!mFilterNames[i]->IsEmpty()) {
// If we have a name for our filter, let's use that.
const char *filter_name = mFilterNames[i]->get();
_gtk_file_filter_set_name (filter, filter_name);
} else {
// If we don't have a name, let's just use the filter pattern.
const char *filter_pattern = mFilters[i]->get();
_gtk_file_filter_set_name (filter, filter_pattern);
}
_gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_chooser), filter);
// Set the initially selected filter
if (mSelectedType == i) {
_gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(file_chooser), filter);
}
}
PRBool checkForOverwrite = PR_TRUE;
if (_gtk_file_chooser_set_do_overwrite_confirmation) {
checkForOverwrite = PR_FALSE;
// Only available in GTK 2.8
_gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(file_chooser), PR_TRUE);
}
gint response = gtk_dialog_run (GTK_DIALOG (file_chooser));
switch (response) {
case GTK_RESPONSE_ACCEPT:
ReadValuesFromFileChooser(file_chooser);
*aReturn = nsIFilePicker::returnOK;
if (mMode == nsIFilePicker::modeSave) {
nsCOMPtr<nsILocalFile> file;
GetFile(getter_AddRefs(file));
if (file) {
PRBool exists = PR_FALSE;
file->Exists(&exists);
//.........这里部分代码省略.........
示例4: PLUG_NewPluginNativeWindow
nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow)
{
NS_ENSURE_ARG_POINTER(aPluginNativeWindow);
*aPluginNativeWindow = new nsPluginNativeWindowGtk();
return *aPluginNativeWindow ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
示例5: GetScriptHandlingObject
NS_IMETHODIMP
nsXMLDocument::Load(const nsAString& aUrl, bool *aReturn)
{
bool hasHadScriptObject = true;
nsIScriptGlobalObject* scriptObject =
GetScriptHandlingObject(hasHadScriptObject);
NS_ENSURE_STATE(scriptObject || !hasHadScriptObject);
ReportUseOfDeprecatedMethod(this, "UseOfDOM3LoadMethodWarning");
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = false;
nsCOMPtr<nsIDocument> callingDoc =
do_QueryInterface(nsContentUtils::GetDocumentFromContext());
nsIURI *baseURI = mDocumentURI;
nsCAutoString charset;
if (callingDoc) {
baseURI = callingDoc->GetDocBaseURI();
charset = callingDoc->GetDocumentCharacterSet();
}
// Create a new URI
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), aUrl, charset.get(), baseURI);
if (NS_FAILED(rv)) {
return rv;
}
// Check to see whether the current document is allowed to load this URI.
// It's important to use the current document's principal for this check so
// that we don't end up in a case where code with elevated privileges is
// calling us and changing the principal of this document.
// Enforce same-origin even for chrome loaders to avoid someone accidentally
// using a document that content has a reference to and turn that into a
// chrome document.
nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
if (!nsContentUtils::IsSystemPrincipal(principal)) {
rv = principal->CheckMayLoad(uri, false, false);
NS_ENSURE_SUCCESS(rv, rv);
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_XMLHTTPREQUEST,
uri,
principal,
callingDoc ? callingDoc.get() :
static_cast<nsIDocument*>(this),
NS_LITERAL_CSTRING("application/xml"),
nullptr,
&shouldLoad,
nsContentUtils::GetContentPolicy(),
nsContentUtils::GetSecurityManager());
NS_ENSURE_SUCCESS(rv, rv);
if (NS_CP_REJECTED(shouldLoad)) {
return NS_ERROR_CONTENT_BLOCKED;
}
} else {
// We're called from chrome, check to make sure the URI we're
// about to load is also chrome.
bool isChrome = false;
if (NS_FAILED(uri->SchemeIs("chrome", &isChrome)) || !isChrome) {
nsCAutoString spec;
if (mDocumentURI)
mDocumentURI->GetSpec(spec);
nsAutoString error;
error.AssignLiteral("Cross site loading using document.load is no "
"longer supported. Use XMLHttpRequest instead.");
nsCOMPtr<nsIScriptError> errorObject =
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = errorObject->InitWithWindowID(error.get(), NS_ConvertUTF8toUTF16(spec).get(),
nullptr, 0, 0, nsIScriptError::warningFlag,
"DOM",
callingDoc ?
callingDoc->InnerWindowID() :
this->InnerWindowID());
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
if (consoleService) {
consoleService->LogMessage(errorObject);
}
return NS_ERROR_DOM_SECURITY_ERR;
}
}
// Partial Reset, need to restore principal for security reasons and
// event listener manager so that load listeners etc. will
// remain. This should be done before the security check is done to
// ensure that the document is reset even if the new document can't
// be loaded. Note that we need to hold a strong ref to |principal|
//.........这里部分代码省略.........
示例6: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP nsPop3IncomingServer::GetRunningProtocol(nsIPop3Protocol **aProtocol)
{
NS_ENSURE_ARG_POINTER(aProtocol);
NS_IF_ADDREF(*aProtocol = m_runningProtocol);
return NS_OK;
}
示例7: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP nsNNTPNewsgroupList::ApplyFilterHit(nsIMsgFilter *aFilter, nsIMsgWindow *aMsgWindow, bool *aApplyMore)
{
NS_ENSURE_ARG_POINTER(aFilter);
NS_ENSURE_ARG_POINTER(aApplyMore);
NS_ENSURE_TRUE(m_newMsgHdr, NS_ERROR_UNEXPECTED);
NS_ENSURE_TRUE(m_newsDB, NS_ERROR_UNEXPECTED);
// you can't move news messages, so applyMore is always true
*aApplyMore = true;
nsCOMPtr<nsISupportsArray> filterActionList;
nsresult rv = NS_NewISupportsArray(getter_AddRefs(filterActionList));
NS_ENSURE_SUCCESS(rv, rv);
rv = aFilter->GetSortedActionList(filterActionList);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t numActions;
rv = filterActionList->Count(&numActions);
NS_ENSURE_SUCCESS(rv, rv);
bool loggingEnabled = false;
nsCOMPtr<nsIMsgFilterList> currentFilterList;
rv = aFilter->GetFilterList(getter_AddRefs(currentFilterList));
if (NS_SUCCEEDED(rv) && currentFilterList && numActions)
currentFilterList->GetLoggingEnabled(&loggingEnabled);
for (uint32_t actionIndex = 0; actionIndex < numActions; actionIndex++)
{
nsCOMPtr<nsIMsgRuleAction> filterAction;
filterActionList->QueryElementAt(actionIndex, NS_GET_IID(nsIMsgRuleAction), getter_AddRefs(filterAction));
if (!filterAction)
continue;
nsMsgRuleActionType actionType;
if (NS_SUCCEEDED(filterAction->GetType(&actionType)))
{
switch (actionType)
{
case nsMsgFilterAction::Delete:
m_addHdrToDB = false;
break;
case nsMsgFilterAction::MarkRead:
m_newsDB->MarkHdrRead(m_newMsgHdr, true, nullptr);
break;
case nsMsgFilterAction::MarkUnread:
m_newsDB->MarkHdrRead(m_newMsgHdr, false, nullptr);
break;
case nsMsgFilterAction::KillThread:
m_newMsgHdr->SetUint32Property("ProtoThreadFlags", nsMsgMessageFlags::Ignored);
break;
case nsMsgFilterAction::KillSubthread:
{
uint32_t newFlags;
m_newMsgHdr->OrFlags(nsMsgMessageFlags::Ignored, &newFlags);
}
break;
case nsMsgFilterAction::WatchThread:
{
uint32_t newFlags;
m_newMsgHdr->OrFlags(nsMsgMessageFlags::Watched, &newFlags);
}
break;
case nsMsgFilterAction::MarkFlagged:
m_newMsgHdr->MarkFlagged(true);
break;
case nsMsgFilterAction::ChangePriority:
{
nsMsgPriorityValue filterPriority;
filterAction->GetPriority(&filterPriority);
m_newMsgHdr->SetPriority(filterPriority);
}
break;
case nsMsgFilterAction::AddTag:
{
nsCString keyword;
filterAction->GetStrValue(keyword);
nsCOMPtr<nsIMutableArray> messageArray(do_CreateInstance(NS_ARRAY_CONTRACTID));
messageArray->AppendElement(m_newMsgHdr, false);
nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
if (folder)
folder->AddKeywordsToMessages(messageArray, keyword);
break;
}
case nsMsgFilterAction::Label:
{
nsMsgLabelValue filterLabel;
filterAction->GetLabel(&filterLabel);
nsMsgKey msgKey;
m_newMsgHdr->GetMessageKey(&msgKey);
m_newsDB->SetLabel(msgKey, filterLabel);
}
break;
case nsMsgFilterAction::StopExecution:
{
// don't apply any more filters
*aApplyMore = false;
}
break;
//.........这里部分代码省略.........
示例8: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP
nsChromeProtocolHandler::NewChannel2(nsIURI* aURI,
nsILoadInfo* aLoadInfo,
nsIChannel** aResult)
{
nsresult rv;
NS_ENSURE_ARG_POINTER(aURI);
NS_ENSURE_ARG_POINTER(aLoadInfo);
NS_PRECONDITION(aResult, "Null out param");
#ifdef DEBUG
// Check that the uri we got is already canonified
nsresult debug_rv;
nsCOMPtr<nsIURI> debugClone;
debug_rv = aURI->Clone(getter_AddRefs(debugClone));
if (NS_SUCCEEDED(debug_rv)) {
nsCOMPtr<nsIURL> debugURL (do_QueryInterface(debugClone));
debug_rv = nsChromeRegistry::Canonify(debugURL);
if (NS_SUCCEEDED(debug_rv)) {
bool same;
debug_rv = aURI->Equals(debugURL, &same);
if (NS_SUCCEEDED(debug_rv)) {
NS_ASSERTION(same, "Non-canonified chrome uri passed to nsChromeProtocolHandler::NewChannel!");
}
}
}
#endif
nsCOMPtr<nsIChannel> result;
if (!nsChromeRegistry::gChromeRegistry) {
// We don't actually want this ref, we just want the service to
// initialize if it hasn't already.
nsCOMPtr<nsIChromeRegistry> reg =
mozilla::services::GetChromeRegistryService();
NS_ENSURE_TRUE(nsChromeRegistry::gChromeRegistry, NS_ERROR_FAILURE);
}
nsCOMPtr<nsIURI> resolvedURI;
rv = nsChromeRegistry::gChromeRegistry->ConvertChromeURL(aURI, getter_AddRefs(resolvedURI));
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("Couldn't convert chrome URL: %s\n",
aURI->GetSpecOrDefault().get());
#endif
return rv;
}
// We don't want to allow the inner protocol handler modify the result principal URI
// since we want either |aURI| or anything pre-set by upper layers to prevail.
nsCOMPtr<nsIURI> savedResultPrincipalURI;
rv = aLoadInfo->GetResultPrincipalURI(getter_AddRefs(savedResultPrincipalURI));
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewChannelInternal(getter_AddRefs(result),
resolvedURI,
aLoadInfo);
NS_ENSURE_SUCCESS(rv, rv);
#ifdef DEBUG
nsCOMPtr<nsIFileChannel> fileChan(do_QueryInterface(result));
if (fileChan) {
nsCOMPtr<nsIFile> file;
fileChan->GetFile(getter_AddRefs(file));
bool exists = false;
file->Exists(&exists);
if (!exists) {
nsAutoCString path;
file->GetNativePath(path);
printf("Chrome file doesn't exist: %s\n", path.get());
}
}
#endif
// Make sure that the channel remembers where it was
// originally loaded from.
rv = aLoadInfo->SetResultPrincipalURI(savedResultPrincipalURI);
NS_ENSURE_SUCCESS(rv, rv);
rv = result->SetOriginalURI(aURI);
if (NS_FAILED(rv)) return rv;
// Get a system principal for content files and set the owner
// property of the result
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
nsAutoCString path;
rv = url->GetPathQueryRef(path);
if (StringBeginsWith(path, NS_LITERAL_CSTRING("/content/"))) {
result->SetOwner(nsContentUtils::GetSystemPrincipal());
}
// XXX Removed dependency-tracking code from here, because we're not
// tracking them anyways (with fastload we checked only in DEBUG
// and with startupcache not at all), but this is where we would start
// if we need to re-add.
// See bug 531886, bug 533038.
result->SetContentCharset(NS_LITERAL_CSTRING("UTF-8"));
//.........这里部分代码省略.........
示例9: NS_ENSURE_ARG_POINTER
/* attribute boolean processCanceledByUser; */
NS_IMETHODIMP nsPrintProgress::GetProcessCanceledByUser(PRBool *aProcessCanceledByUser)
{
NS_ENSURE_ARG_POINTER(aProcessCanceledByUser);
*aProcessCanceledByUser = m_processCanceled;
return NS_OK;
}
示例10: ShowNativePrintDialog
//------------------------------------------------------------------
// Displays the native Print Dialog
static nsresult
ShowNativePrintDialog(HWND aHWnd,
nsIPrintSettings* aPrintSettings)
{
//NS_ENSURE_ARG_POINTER(aHWnd);
NS_ENSURE_ARG_POINTER(aPrintSettings);
gDialogWasExtended = false;
HGLOBAL hGlobalDevMode = nullptr;
HGLOBAL hDevNames = nullptr;
// Get the Print Name to be used
nsXPIDLString printerName;
aPrintSettings->GetPrinterName(getter_Copies(printerName));
// If there is no name then use the default printer
if (printerName.IsEmpty()) {
GetDefaultPrinterNameFromGlobalPrinters(printerName);
} else {
HANDLE hPrinter = nullptr;
if(!::OpenPrinterW(const_cast<wchar_t*>(printerName.get()), &hPrinter, nullptr)) {
// If the last used printer is not found, we should use default printer.
GetDefaultPrinterNameFromGlobalPrinters(printerName);
} else {
::ClosePrinter(hPrinter);
}
}
// Now create a DEVNAMES struct so the the dialog is initialized correctly.
uint32_t len = printerName.Length();
hDevNames = (HGLOBAL)::GlobalAlloc(GHND, sizeof(wchar_t) * (len + 1) +
sizeof(DEVNAMES));
if (!hDevNames) {
return NS_ERROR_OUT_OF_MEMORY;
}
DEVNAMES* pDevNames = (DEVNAMES*)::GlobalLock(hDevNames);
if (!pDevNames) {
::GlobalFree(hDevNames);
return NS_ERROR_FAILURE;
}
pDevNames->wDriverOffset = sizeof(DEVNAMES)/sizeof(wchar_t);
pDevNames->wDeviceOffset = sizeof(DEVNAMES)/sizeof(wchar_t);
pDevNames->wOutputOffset = sizeof(DEVNAMES)/sizeof(wchar_t)+len;
pDevNames->wDefault = 0;
memcpy(pDevNames+1, printerName, (len + 1) * sizeof(wchar_t));
::GlobalUnlock(hDevNames);
// Create a Moveable Memory Object that holds a new DevMode
// from the Printer Name
// The PRINTDLG.hDevMode requires that it be a moveable memory object
// NOTE: We only need to free hGlobalDevMode when the dialog is cancelled
// When the user prints, it comes back in the printdlg struct and
// is used and cleaned up later
hGlobalDevMode = CreateGlobalDevModeAndInit(printerName, aPrintSettings);
// Prepare to Display the Print Dialog
PRINTDLGW prntdlg;
memset(&prntdlg, 0, sizeof(PRINTDLGW));
prntdlg.lStructSize = sizeof(prntdlg);
prntdlg.hwndOwner = aHWnd;
prntdlg.hDevMode = hGlobalDevMode;
prntdlg.hDevNames = hDevNames;
prntdlg.hDC = nullptr;
prntdlg.Flags = PD_ALLPAGES | PD_RETURNIC |
PD_USEDEVMODECOPIESANDCOLLATE | PD_COLLATE;
// if there is a current selection then enable the "Selection" radio button
int16_t howToEnableFrameUI = nsIPrintSettings::kFrameEnableNone;
bool isOn;
aPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
if (!isOn) {
prntdlg.Flags |= PD_NOSELECTION;
}
aPrintSettings->GetHowToEnableFrameUI(&howToEnableFrameUI);
int32_t pg = 1;
aPrintSettings->GetStartPageRange(&pg);
prntdlg.nFromPage = pg;
aPrintSettings->GetEndPageRange(&pg);
prntdlg.nToPage = pg;
prntdlg.nMinPage = 1;
prntdlg.nMaxPage = 0xFFFF;
prntdlg.nCopies = 1;
prntdlg.lpfnSetupHook = nullptr;
prntdlg.lpSetupTemplateName = nullptr;
prntdlg.hPrintTemplate = nullptr;
prntdlg.hSetupTemplate = nullptr;
prntdlg.hInstance = nullptr;
prntdlg.lpPrintTemplateName = nullptr;
//.........这里部分代码省略.........
示例11: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP
nsNSSDialogs::ChooseCertificate(nsIInterfaceRequestor* ctx,
const nsAString& cnAndPort,
const nsAString& organization,
const nsAString& issuerOrg,
nsIArray* certList,
/*out*/ uint32_t* selectedIndex,
/*out*/ bool* certificateChosen)
{
NS_ENSURE_ARG_POINTER(ctx);
NS_ENSURE_ARG_POINTER(certList);
NS_ENSURE_ARG_POINTER(selectedIndex);
NS_ENSURE_ARG_POINTER(certificateChosen);
*certificateChosen = false;
nsCOMPtr<nsIDialogParamBlock> block =
do_CreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID);
if (!block) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIMutableArray> paramBlockArray = nsArrayBase::Create();
if (!paramBlockArray) {
return NS_ERROR_FAILURE;
}
nsresult rv = paramBlockArray->AppendElement(certList, false);
if (NS_FAILED(rv)) {
return rv;
}
rv = block->SetObjects(paramBlockArray);
if (NS_FAILED(rv)) {
return rv;
}
rv = block->SetNumberStrings(3);
if (NS_FAILED(rv)) {
return rv;
}
rv = block->SetString(0, PromiseFlatString(cnAndPort).get());
if (NS_FAILED(rv)) {
return rv;
}
rv = block->SetString(1, PromiseFlatString(organization).get());
if (NS_FAILED(rv)) {
return rv;
}
rv = block->SetString(2, PromiseFlatString(issuerOrg).get());
if (NS_FAILED(rv)) {
return rv;
}
rv = nsNSSDialogHelper::openDialog(nullptr,
"chrome://pippki/content/clientauthask.xul",
block);
if (NS_FAILED(rv)) {
return rv;
}
int32_t status;
rv = block->GetInt(0, &status);
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIClientAuthUserDecision> extraResult = do_QueryInterface(ctx);
if (extraResult) {
int32_t rememberSelection;
rv = block->GetInt(2, &rememberSelection);
if (NS_SUCCEEDED(rv)) {
extraResult->SetRememberClientAuthCertificate(rememberSelection!=0);
}
}
*certificateChosen = (status != 0);
if (*certificateChosen) {
int32_t index = 0;
rv = block->GetInt(1, &index);
if (NS_FAILED(rv)) {
return rv;
}
if (index < 0) {
MOZ_ASSERT_UNREACHABLE("Selected index should never be negative");
return NS_ERROR_FAILURE;
}
*selectedIndex = mozilla::AssertedCast<uint32_t>(index);
}
return NS_OK;
}
示例12: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP
nsMsgSendLater::RemoveListener(nsIMsgSendLaterListener *aListener)
{
NS_ENSURE_ARG_POINTER(aListener);
return mListenerArray.RemoveElement(aListener) ? NS_OK : NS_ERROR_INVALID_ARG;
}
示例13: NS_ENSURE_ARG_POINTER
nsresult
sbFileSystemTreeState::LoadTreeState(nsID & aSessionID,
nsString & aSessionAbsolutePath,
PRBool *aIsRecursiveWatch,
sbFileSystemNode **aOutRootNode)
{
NS_ENSURE_ARG_POINTER(aOutRootNode);
// Setup and read the serialized data as defined above.
nsresult rv;
nsCOMPtr<nsIFile> savedSessionFile;
rv = GetTreeSessionFile(aSessionID,
PR_FALSE, // don't create
getter_AddRefs(savedSessionFile));
NS_ENSURE_SUCCESS(rv, rv);
// Ensure that the session file exists.
PRBool exists = PR_FALSE;
if (NS_FAILED(savedSessionFile->Exists(&exists)) || !exists) {
NS_WARNING("The saved session file no longer exists!");
return NS_ERROR_UNEXPECTED;
}
nsRefPtr<sbFileObjectInputStream> fileObjectStream =
new sbFileObjectInputStream();
NS_ENSURE_TRUE(fileObjectStream, NS_ERROR_OUT_OF_MEMORY);
rv = fileObjectStream->InitWithFile(savedSessionFile);
NS_ENSURE_SUCCESS(rv, rv);
// Now begin to read in the data in the sequence defined above:
// 1.) The tree schema version.
PRUint32 schemaVersion = 0;
rv = fileObjectStream->ReadUint32(&schemaVersion);
NS_ENSURE_SUCCESS(rv, rv);
// For now, just ensure that the schema version is the same.
// In the future, a migration handler will need to be written.
if (schemaVersion != TREE_SCHEMA_VERSION) {
return NS_ERROR_FAILURE;
}
// 2.) Tree root absolute path
rv = fileObjectStream->ReadString(aSessionAbsolutePath);
NS_ENSURE_SUCCESS(rv, rv);
// 3.) Is tree recursive watch.
rv = fileObjectStream->ReadPRBool(aIsRecursiveWatch);
NS_ENSURE_SUCCESS(rv, rv);
// 4.) Number of nodes
PRUint32 nodeCount = 0;
rv = fileObjectStream->ReadUint32(&nodeCount);
NS_ENSURE_SUCCESS(rv, rv);
// 5.) Node data
// Use the map to store guids to help rebuild the parent/child relationship.
nsRefPtr<sbFileSystemNode> savedRootNode;
sbNodeIDMap nodeIDMap;
for (PRUint32 i = 0; i < nodeCount; i++) {
nsRefPtr<sbFileSystemNode> curNode;
rv = ReadNode(fileObjectStream, getter_AddRefs(curNode));
// If one of the nodes is missing, it could corrupt the entire tree.
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(curNode, NS_ERROR_UNEXPECTED);
// Assign this node into the node ID map.
PRUint32 curNodeID;
rv = curNode->GetNodeID(&curNodeID);
// Once again, this will corrupt the entire tree if it fails.
NS_ENSURE_SUCCESS(rv, rv);
nodeIDMap.insert(sbNodeIDMapPair(curNodeID, curNode));
// If this is the first node read, it is the root node. Simply stash the
// references for later and continue.
if (i == 0) {
savedRootNode = curNode;
continue;
}
// Setup the relationship between parent and child.
rv = AssignRelationships(curNode, nodeIDMap);
// If this fails, it will also corrupt the entire tree.
NS_ENSURE_SUCCESS(rv, rv);
}
rv = fileObjectStream->Close();
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Could not close the file object stream!");
savedRootNode.forget(aOutRootNode);
return NS_OK;
}
示例14: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP
CVE_2014_1482_seamonkey2_9_RasterImage::Draw(gfxContext *aContext,
gfxPattern::GraphicsFilter aFilter,
const gfxMatrix &aUserSpaceToImageSpace,
const gfxRect &aFill,
const nsIntRect &aSubimage,
const nsIntSize& /*aViewportSize - ignored*/,
PRUint32 aFlags)
{
if (mError)
return NS_ERROR_FAILURE;
// Disallowed in the API
if (mInDecoder && (aFlags & imgIContainer::FLAG_SYNC_DECODE))
return NS_ERROR_FAILURE;
// Illegal -- you can't draw with non-default decode flags.
// (Disabling colorspace conversion might make sense to allow, but
// we don't currently.)
if ((aFlags & DECODE_FLAGS_MASK) != DECODE_FLAGS_DEFAULT)
return NS_ERROR_FAILURE;
NS_ENSURE_ARG_POINTER(aContext);
// We can only draw with the default decode flags
if (mFrameDecodeFlags != DECODE_FLAGS_DEFAULT) {
if (!CanForciblyDiscard())
return NS_ERROR_NOT_AVAILABLE;
ForceDiscard();
mFrameDecodeFlags = DECODE_FLAGS_DEFAULT;
}
// We use !mDecoded && mHasSourceData to mean discarded.
if (!mDecoded && mHasSourceData) {
mDrawStartTime = TimeStamp::Now();
}
// If a synchronous draw is requested, flush anything that might be sitting around
if (aFlags & FLAG_SYNC_DECODE) {
nsresult rv = SyncDecode();
NS_ENSURE_SUCCESS(rv, rv);
}
imgFrame *frame = GetCurrentDrawableImgFrame();
if (!frame) {
return NS_OK; // Getting the frame (above) touches the image and kicks off decoding
}
nsIntRect framerect = frame->GetRect();
nsIntMargin padding(framerect.x, framerect.y,
mSize.width - framerect.XMost(),
mSize.height - framerect.YMost());
frame->Draw(aContext, aFilter, aUserSpaceToImageSpace, aFill, padding, aSubimage);
if (mDecoded && !mDrawStartTime.IsNull()) {
TimeDuration drawLatency = TimeStamp::Now() - mDrawStartTime;
Telemetry::Accumulate(Telemetry::IMAGE_DECODE_ON_DRAW_LATENCY, PRInt32(drawLatency.ToMicroseconds()));
// clear the value of mDrawStartTime
mDrawStartTime = TimeStamp();
}
return NS_OK;
}