diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-01-10 19:19:52 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-01-10 19:19:52 +0800 |
commit | 137a5961bbd03f74a90927ae1a03ed5e19e5d666 (patch) | |
tree | 710be6153d725c44fa97993e3dee32aaf74ef9d6 | |
parent | 264834c946c5555c48b1fda985c6513c23773228 (diff) | |
download | gsoc2013-epiphany-137a5961bbd03f74a90927ae1a03ed5e19e5d666.tar.gz gsoc2013-epiphany-137a5961bbd03f74a90927ae1a03ed5e19e5d666.tar.zst gsoc2013-epiphany-137a5961bbd03f74a90927ae1a03ed5e19e5d666.zip |
Use NS_ENSURE_SUCCESS/NS_ENSURE_TRUE at appropriate places.
2004-01-10 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/FilePicker.cpp:
* embed/mozilla/MozDownload.cpp:
* embed/mozilla/MozRegisterComponents.cpp:
* embed/mozilla/MozillaPrivate.cpp:
Use NS_ENSURE_SUCCESS/NS_ENSURE_TRUE at appropriate places.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | embed/mozilla/FilePicker.cpp | 3 | ||||
-rw-r--r-- | embed/mozilla/MozDownload.cpp | 8 | ||||
-rw-r--r-- | embed/mozilla/MozRegisterComponents.cpp | 51 | ||||
-rw-r--r-- | embed/mozilla/MozillaPrivate.cpp | 37 | ||||
-rw-r--r-- | embed/mozilla/PrintingPromptService.cpp | 1 |
6 files changed, 73 insertions, 36 deletions
@@ -1,5 +1,14 @@ 2004-01-10 Christian Persch <chpe@cvs.gnome.org> + * embed/mozilla/FilePicker.cpp: + * embed/mozilla/MozDownload.cpp: + * embed/mozilla/MozRegisterComponents.cpp: + * embed/mozilla/MozillaPrivate.cpp: + + Use NS_ENSURE_SUCCESS/NS_ENSURE_TRUE at appropriate places. + +2004-01-10 Christian Persch <chpe@cvs.gnome.org> + * embed/mozilla/ExternalProtocolHandlers.cpp: Use NS_ENSURE_SUCCESS/NS_ENSURE_TRUE at appropriate places. diff --git a/embed/mozilla/FilePicker.cpp b/embed/mozilla/FilePicker.cpp index 4dd0340b8..71685c958 100644 --- a/embed/mozilla/FilePicker.cpp +++ b/embed/mozilla/FilePicker.cpp @@ -297,7 +297,8 @@ NS_IMETHODIMP GFilePicker::GetFileURL(nsIFileURL **aFileURL) { nsCOMPtr<nsILocalFile> file; GetFile (getter_AddRefs(file)); - + NS_ENSURE_TRUE (file, NS_ERROR_FAILURE); + nsCOMPtr<nsIFileURL> fileURL = do_CreateInstance (NS_STANDARDURL_CONTRACTID); fileURL->SetFile(file); NS_IF_ADDREF(*aFileURL = fileURL); diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp index efe13ab88..31847a3e1 100644 --- a/embed/mozilla/MozDownload.cpp +++ b/embed/mozilla/MozDownload.cpp @@ -41,6 +41,10 @@ * $Id$ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "MozDownload.h" #include "mozilla-download.h" #include "eel-gconf-extensions.h" @@ -409,7 +413,7 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI strcmp (contentType, "application/xhtml+xml") == 0)); nsCOMPtr<nsIWebBrowserPersist> webPersist = do_CreateInstance(persistContractID, &rv); - if (NS_FAILED(rv)) return rv; + NS_ENSURE_SUCCESS (rv, rv); PRInt64 timeNow = PR_Now(); @@ -420,7 +424,7 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI /* dlListener attaches to its progress dialog here, which gains ownership */ rv = downloader->InitForEmbed (inOriginalURI, inDestFile, fileDisplayName.get(), nsnull, timeNow, webPersist, embedPersist); - if (NS_FAILED(rv)) return rv; + NS_ENSURE_SUCCESS (rv, rv); PRInt32 flags = nsIWebBrowserPersist::PERSIST_FLAGS_REPLACE_EXISTING_FILES; if (ephy_flags & EMBED_PERSIST_COPY_PAGE) diff --git a/embed/mozilla/MozRegisterComponents.cpp b/embed/mozilla/MozRegisterComponents.cpp index 57010a22a..6168c82e5 100644 --- a/embed/mozilla/MozRegisterComponents.cpp +++ b/embed/mozilla/MozRegisterComponents.cpp @@ -173,12 +173,6 @@ static const nsModuleComponentInfo sAppComps[] = { { EPHY_ABOUT_REDIRECTOR_CLASSNAME, EPHY_ABOUT_REDIRECTOR_CID, - EPHY_ABOUT_REDIRECTOR_OPTIONS_CONTRACTID, - EphyAboutRedirectorConstructor - }, - { - EPHY_ABOUT_REDIRECTOR_CLASSNAME, - EPHY_ABOUT_REDIRECTOR_CID, EPHY_ABOUT_REDIRECTOR_CONSPIRACY_CONTRACTID, EphyAboutRedirectorConstructor }, @@ -230,16 +224,18 @@ mozilla_register_components (void) nsresult rv; nsCOMPtr<nsIComponentRegistrar> cr; - rv = NS_GetComponentRegistrar(getter_AddRefs(cr)); - NS_ENSURE_SUCCESS(rv, rv); + NS_GetComponentRegistrar(getter_AddRefs(cr)); + NS_ENSURE_TRUE (cr, FALSE); for (int i = 0; i < sNumAppComps; i++) { nsCOMPtr<nsIGenericFactory> componentFactory; rv = NS_NewGenericFactory(getter_AddRefs(componentFactory), &(sAppComps[i])); - if (NS_FAILED(rv)) + if (NS_FAILED(rv) || !componentFactory) { + g_warning ("Failed to make a factory for %s\n", sAppComps[i].mDescription); + ret = FALSE; continue; // don't abort registering other components } @@ -249,7 +245,11 @@ mozilla_register_components (void) sAppComps[i].mContractID, componentFactory); if (NS_FAILED(rv)) + { + g_warning ("Failed to register %s\n", sAppComps[i].mDescription); + ret = FALSE; + } } return ret; @@ -263,34 +263,34 @@ mozilla_register_FtpProtocolHandler (void) { if (ftpRegistered == PR_TRUE) return TRUE; - nsresult rv = NS_OK; + nsresult rv; nsCOMPtr<nsIComponentManager> cm; - rv = NS_GetComponentManager(getter_AddRefs(cm)); - if (NS_FAILED(rv) || !cm) return FALSE; + NS_GetComponentManager(getter_AddRefs(cm)); + NS_ENSURE_TRUE (cm, FALSE); rv = cm->GetClassObject(knsFtpProtocolHandlerCID, NS_GET_IID(nsIFactory), getter_AddRefs(nsFtpFactory)); - if (NS_FAILED(rv)) return FALSE; + if (NS_FAILED (rv)) return FALSE; nsCOMPtr<nsIGenericFactory> ftpFactory; - rv = NS_NewGenericFactory(getter_AddRefs(ftpFactory), - &sFtpComps); - if (NS_FAILED(rv) || !ftpFactory) return FALSE; + NS_NewGenericFactory(getter_AddRefs(ftpFactory), &sFtpComps); + NS_ENSURE_TRUE (ftpFactory, FALSE); nsCOMPtr<nsIComponentRegistrar> cr; - rv = NS_GetComponentRegistrar(getter_AddRefs(cr)); - if (NS_FAILED(rv) || !cr) return FALSE; + NS_GetComponentRegistrar(getter_AddRefs(cr)); + NS_ENSURE_TRUE (cr, FALSE); rv = cr->RegisterFactory(sFtpComps.mCID, sFtpComps.mDescription, sFtpComps.mContractID, ftpFactory); - if (NS_FAILED(rv)) return FALSE; + NS_ENSURE_SUCCESS (rv, FALSE); ftpRegistered = PR_TRUE; - return NS_SUCCEEDED (rv) ? TRUE : FALSE; + + return TRUE; } /** @@ -301,17 +301,18 @@ mozilla_unregister_FtpProtocolHandler (void) { if (ftpRegistered == PR_FALSE) return FALSE; - nsresult rv = NS_OK; - + nsresult rv; nsCOMPtr<nsIComponentRegistrar> cr; - rv = NS_GetComponentRegistrar(getter_AddRefs(cr)); - if (NS_FAILED(rv) || !cr) return FALSE; + NS_GetComponentRegistrar(getter_AddRefs(cr)); + NS_ENSURE_TRUE (cr, FALSE); rv = cr->RegisterFactory(knsFtpProtocolHandlerCID, NS_FTPPROTOCOLHANDLER_CLASSNAME, G_FTP_PROTOCOL_CONTRACTID, nsFtpFactory); + NS_ENSURE_SUCCESS (rv, FALSE); ftpRegistered = PR_FALSE; - return NS_SUCCEEDED (rv) ? TRUE : FALSE; + + return TRUE; } diff --git a/embed/mozilla/MozillaPrivate.cpp b/embed/mozilla/MozillaPrivate.cpp index 17925955f..d83509119 100644 --- a/embed/mozilla/MozillaPrivate.cpp +++ b/embed/mozilla/MozillaPrivate.cpp @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2003 Marco Pesenti Gritti + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "MozillaPrivate.h" #include <nsIServiceManagerUtils.h> @@ -11,8 +35,6 @@ GtkWidget *MozillaFindEmbed (nsIDOMWindow *aDOMWindow) { - nsresult result; - nsCOMPtr<nsIWindowWatcher> wwatch (do_GetService("@mozilla.org/embedcomp/window-watcher;1")); NS_ENSURE_TRUE (wwatch, nsnull); @@ -33,14 +55,13 @@ GtkWidget *MozillaFindEmbed (nsIDOMWindow *aDOMWindow) NS_ENSURE_TRUE (domWindow, nsnull); nsCOMPtr<nsIWebBrowserChrome> windowChrome; - result = wwatch->GetChromeForWindow (domWindow, - getter_AddRefs(windowChrome)); + wwatch->GetChromeForWindow (domWindow, getter_AddRefs(windowChrome)); NS_ENSURE_TRUE (windowChrome, nsnull); - nsCOMPtr<nsIEmbeddingSiteWindow> window - (do_QueryInterface(windowChrome, &result)); + nsCOMPtr<nsIEmbeddingSiteWindow> window (do_QueryInterface(windowChrome)); NS_ENSURE_TRUE (window, nsnull); + nsresult result; GtkWidget *mozembed; result = window->GetSiteWindow ((void **)&mozembed); NS_ENSURE_SUCCESS (result, nsnull); @@ -51,7 +72,7 @@ GtkWidget *MozillaFindEmbed (nsIDOMWindow *aDOMWindow) GtkWidget *MozillaFindGtkParent (nsIDOMWindow *aDOMWindow) { GtkWidget *embed = MozillaFindEmbed (aDOMWindow); - if (!embed) return nsnull; + NS_ENSURE_TRUE (embed, nsnull); return gtk_widget_get_toplevel (GTK_WIDGET (embed)); } @@ -59,7 +80,7 @@ GtkWidget *MozillaFindGtkParent (nsIDOMWindow *aDOMWindow) #define MM_TO_INCH(x) (((double) x) / 25.4) NS_METHOD MozillaCollatePrintSettings (const EmbedPrintInfo *info, - nsIPrintSettings *options) + nsIPrintSettings *options) { const static int frame_types[] = { nsIPrintSettings::kFramesAsIs, diff --git a/embed/mozilla/PrintingPromptService.cpp b/embed/mozilla/PrintingPromptService.cpp index 79059b10f..60eb3b1db 100644 --- a/embed/mozilla/PrintingPromptService.cpp +++ b/embed/mozilla/PrintingPromptService.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2002 Philip Langdale + * Copyright (C) 2003-2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by |