From c922c7b6817055cdfd036f4aa43748dbf76fe9a4 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sun, 19 Oct 2003 00:27:47 +0000 Subject: cleanup. Fix warning when fetching favicons. 2003-10-19 Marco Pesenti Gritti * embed/mozilla/mozilla-embed-persist.cpp: cleanup. Fix warning when fetching favicons. --- ChangeLog | 6 ++++ embed/mozilla/mozilla-embed-persist.cpp | 59 ++++++++++++++++++--------------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 05610ebdf..eb6aaad23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-10-19 Marco Pesenti Gritti + + * embed/mozilla/mozilla-embed-persist.cpp: + + cleanup. Fix warning when fetching favicons. + 2003-10-18 Marco Pesenti Gritti * embed/mozilla/EphyHeaderSniffer.cpp: diff --git a/embed/mozilla/mozilla-embed-persist.cpp b/embed/mozilla/mozilla-embed-persist.cpp index d374eb3f0..846b63c8d 100644 --- a/embed/mozilla/mozilla-embed-persist.cpp +++ b/embed/mozilla/mozilla-embed-persist.cpp @@ -168,15 +168,15 @@ impl_save (EphyEmbedPersist *persist) g_return_val_if_fail (filename != NULL, G_FAILED); - EphyWrapper *wrapper; - - g_return_val_if_fail (embed != NULL, G_FAILED); - wrapper = (EphyWrapper *) mozilla_embed_get_ephy_wrapper (MOZILLA_EMBED(embed)); - g_return_val_if_fail (wrapper != NULL, G_FAILED); + EphyWrapper *wrapper = NULL; + if (embed) + { + wrapper = (EphyWrapper *) mozilla_embed_get_ephy_wrapper (MOZILLA_EMBED(embed)); + g_return_val_if_fail (wrapper != NULL, G_FAILED); + } - nsCOMPtr webPersist = - MOZILLA_EMBED_PERSIST (persist)->priv->mPersist; - if (!webPersist) return G_FAILED; + /* we must have one of uri or wrapper */ + g_assert (wrapper != NULL || uri != NULL); /* Get a temp filename to save to */ nsCOMPtr dirService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv)); @@ -194,7 +194,6 @@ impl_save (EphyEmbedPersist *persist) /* Get the uri to save to */ nsCOMPtr inURI; nsCAutoString sURI; - if (uri) { sURI.Assign (uri); @@ -204,7 +203,6 @@ impl_save (EphyEmbedPersist *persist) rv = wrapper->GetDocumentUrl (sURI); if (NS_FAILED(rv)) return G_FAILED; } - rv = NS_NewURI(getter_AddRefs(inURI), sURI); if (NS_FAILED(rv) || !inURI) return G_FAILED; @@ -212,28 +210,16 @@ impl_save (EphyEmbedPersist *persist) nsAutoString inFilename; inFilename.AssignWithConversion (filename); - nsCOMPtr DOMDocument; + /* Get post data */ nsCOMPtr postData; - if (!uri) - { - /* Get the DOM document */ - if (flags & EMBED_PERSIST_MAINDOC) - { - rv = wrapper->GetMainDOMDocument (getter_AddRefs(DOMDocument)); - } - else - { - rv = wrapper->GetDOMDocument (getter_AddRefs(DOMDocument)); - } - if (NS_FAILED(rv) || !DOMDocument) return G_FAILED; + if (wrapper) + { + PRInt32 sindex; nsCOMPtr webNav(do_QueryInterface(wrapper->mWebBrowser)); nsCOMPtr sessionHistory; webNav->GetSessionHistory(getter_AddRefs(sessionHistory)); nsCOMPtr entry; - - /* Get post data */ - PRInt32 sindex; sessionHistory->GetIndex(&sindex); sessionHistory->GetEntryAtIndex(sindex, PR_FALSE, getter_AddRefs(entry)); nsCOMPtr shEntry(do_QueryInterface(entry)); @@ -243,6 +229,26 @@ impl_save (EphyEmbedPersist *persist) } } + /* Get the DOM document if a uri is not specified */ + nsCOMPtr DOMDocument; + if (!uri) + { + if (flags & EMBED_PERSIST_MAINDOC) + { + rv = wrapper->GetMainDOMDocument (getter_AddRefs(DOMDocument)); + } + else + { + rv = wrapper->GetDOMDocument (getter_AddRefs(DOMDocument)); + } + if (NS_FAILED(rv) || !DOMDocument) return G_FAILED; + } + + /* Create an header sniffer and do the save */ + nsCOMPtr webPersist = + MOZILLA_EMBED_PERSIST (persist)->priv->mPersist; + if (!webPersist) return G_FAILED; + EphyHeaderSniffer* sniffer = new EphyHeaderSniffer (webPersist, MOZILLA_EMBED_PERSIST (persist), tmpFile, inURI, DOMDocument, postData, @@ -250,7 +256,6 @@ impl_save (EphyEmbedPersist *persist) if (!sniffer) return G_FAILED; webPersist->SetProgressListener(sniffer); - rv = webPersist->SaveURI(inURI, nsnull, nsnull, nsnull, nsnull, tmpFile); if (NS_FAILED (rv)) return G_FAILED; -- cgit v1.2.3