diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2003-10-19 08:27:47 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2003-10-19 08:27:47 +0800 |
commit | c922c7b6817055cdfd036f4aa43748dbf76fe9a4 (patch) | |
tree | 8a0f4bc63dd89d546de3f0612faf7ed5a45f54e5 | |
parent | 8a90973ba893d84946c898f137fd2efb3ced96ac (diff) | |
download | gsoc2013-epiphany-c922c7b6817055cdfd036f4aa43748dbf76fe9a4.tar gsoc2013-epiphany-c922c7b6817055cdfd036f4aa43748dbf76fe9a4.tar.gz gsoc2013-epiphany-c922c7b6817055cdfd036f4aa43748dbf76fe9a4.tar.bz2 gsoc2013-epiphany-c922c7b6817055cdfd036f4aa43748dbf76fe9a4.tar.lz gsoc2013-epiphany-c922c7b6817055cdfd036f4aa43748dbf76fe9a4.tar.xz gsoc2013-epiphany-c922c7b6817055cdfd036f4aa43748dbf76fe9a4.tar.zst gsoc2013-epiphany-c922c7b6817055cdfd036f4aa43748dbf76fe9a4.zip |
cleanup. Fix warning when fetching favicons.
2003-10-19 Marco Pesenti Gritti <marco@gnome.org>
* embed/mozilla/mozilla-embed-persist.cpp:
cleanup. Fix warning when fetching favicons.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-persist.cpp | 59 |
2 files changed, 38 insertions, 27 deletions
@@ -1,3 +1,9 @@ +2003-10-19 Marco Pesenti Gritti <marco@gnome.org> + + * embed/mozilla/mozilla-embed-persist.cpp: + + cleanup. Fix warning when fetching favicons. + 2003-10-18 Marco Pesenti Gritti <marco@gnome.org> * 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<nsIWebBrowserPersist> 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<nsIProperties> dirService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv)); @@ -194,7 +194,6 @@ impl_save (EphyEmbedPersist *persist) /* Get the uri to save to */ nsCOMPtr<nsIURI> 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<nsIDOMDocument> DOMDocument; + /* Get post data */ nsCOMPtr<nsIInputStream> 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<nsIWebNavigation> webNav(do_QueryInterface(wrapper->mWebBrowser)); nsCOMPtr<nsISHistory> sessionHistory; webNav->GetSessionHistory(getter_AddRefs(sessionHistory)); nsCOMPtr<nsIHistoryEntry> entry; - - /* Get post data */ - PRInt32 sindex; sessionHistory->GetIndex(&sindex); sessionHistory->GetEntryAtIndex(sindex, PR_FALSE, getter_AddRefs(entry)); nsCOMPtr<nsISHEntry> shEntry(do_QueryInterface(entry)); @@ -243,6 +229,26 @@ impl_save (EphyEmbedPersist *persist) } } + /* Get the DOM document if a uri is not specified */ + nsCOMPtr<nsIDOMDocument> 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<nsIWebBrowserPersist> 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; |