aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--embed/mozilla/EphyBrowser.cpp48
-rw-r--r--embed/mozilla/EphyBrowser.h4
-rw-r--r--embed/mozilla/mozilla-embed.cpp24
4 files changed, 45 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index bb19b73f7..9b7ee4ae3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-05-03 Christian Persch <chpe@cvs.gnome.org>
+
+ * embed/mozilla/EphyBrowser.cpp:
+ * embed/mozilla/EphyBrowser.h:
+ * embed/mozilla/mozilla-embed.cpp:
+
+ Use the web navigation to get the URI, not the document.
+ Fixes bug #301044.
+
2005-05-01 Christian Persch <chpe@cvs.gnome.org>
* data/default-prefs-common.js:
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index aa2d639bc..91bfca09d 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -965,48 +965,38 @@ nsresult EphyBrowser::GetDOMWindow (nsIDOMWindow **aDOMWindow)
return NS_OK;
}
-nsresult EphyBrowser::GetDocumentUrl (nsACString &url)
+nsresult EphyBrowser::GetDocumentURI (nsIURI **aURI)
{
- nsresult rv;
-
- NS_ENSURE_TRUE (mDOMWindow, NS_ERROR_FAILURE);
-
- nsCOMPtr<nsIDOMDocument> DOMDocument;
- mDOMWindow->GetDocument (getter_AddRefs(DOMDocument));
- NS_ENSURE_TRUE (DOMDocument, NS_ERROR_FAILURE);
+ if (!mDOMWindow) return NS_ERROR_NOT_INITIALIZED;
- nsCOMPtr<nsIDOM3Document> doc = do_QueryInterface(DOMDocument);
- NS_ENSURE_TRUE (doc, NS_ERROR_FAILURE);
-
- nsEmbedString docURI;
- rv = doc->GetDocumentURI (docURI);
+ nsresult rv;
+ nsCOMPtr<nsIWebNavigation> webNav (do_GetInterface (mDOMWindow, &rv));
NS_ENSURE_SUCCESS (rv, rv);
- NS_UTF16ToCString (docURI, NS_CSTRING_ENCODING_UTF8, url);
-
- return NS_OK;
+ return webNav->GetCurrentURI (aURI);
}
-nsresult EphyBrowser::GetTargetDocumentUrl (nsACString &url)
+nsresult EphyBrowser::GetTargetDocumentURI (nsIURI **aURI)
{
- nsresult rv;
+ if (!mWebBrowser) return NS_ERROR_NOT_INITIALIZED;
- NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
+ nsCOMPtr<nsIDOMDocument> domDoc;
+ GetTargetDocument (getter_AddRefs(domDoc));
+ NS_ENSURE_TRUE (domDoc, NS_ERROR_FAILURE);
- nsCOMPtr<nsIDOMDocument> DOMDocument;
- GetTargetDocument (getter_AddRefs(DOMDocument));
- NS_ENSURE_TRUE (DOMDocument, NS_ERROR_FAILURE);
+ nsCOMPtr<nsIDOMDocumentView> docView (do_QueryInterface (domDoc));
+ NS_ENSURE_TRUE (docView, NS_ERROR_FAILURE);
- nsCOMPtr<nsIDOM3Document> doc = do_QueryInterface(DOMDocument);
- NS_ENSURE_TRUE (doc, NS_ERROR_FAILURE);
+ nsCOMPtr<nsIDOMAbstractView> abstractView;
+ docView->GetDefaultView (getter_AddRefs (abstractView));
+ NS_ENSURE_TRUE (abstractView, NS_ERROR_FAILURE);
+ /* the abstract view is really the DOM window */
- nsEmbedString docURI;
- rv = doc->GetDocumentURI (docURI);
+ nsresult rv;
+ nsCOMPtr<nsIWebNavigation> webNav (do_GetInterface (abstractView, &rv));
NS_ENSURE_SUCCESS (rv, rv);
- NS_UTF16ToCString (docURI, NS_CSTRING_ENCODING_UTF8, url);
-
- return NS_OK;
+ return webNav->GetCurrentURI (aURI);
}
nsresult EphyBrowser::ForceEncoding (const char *encoding)
diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h
index c594e7f7c..ffb11e11f 100644
--- a/embed/mozilla/EphyBrowser.h
+++ b/embed/mozilla/EphyBrowser.h
@@ -163,8 +163,8 @@ public:
nsresult GetDocument (nsIDOMDocument **aDOMDocument);
nsresult GetTargetDocument (nsIDOMDocument **aDOMDocument);
- nsresult GetDocumentUrl (nsACString &url);
- nsresult GetTargetDocumentUrl (nsACString &url);
+ nsresult GetDocumentURI (nsIURI **aURI);
+ nsresult GetTargetDocumentURI (nsIURI **aURI);
nsresult GetDOMWindow (nsIDOMWindow **window);
nsresult GetHasModifiedForms (PRBool *modified);
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 016820e14..6afcdf82d 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -479,24 +479,30 @@ impl_get_location (EphyEmbed *embed,
gboolean toplevel)
{
MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
- char *l;
nsresult rv;
- nsEmbedCString url;
+ nsCOMPtr<nsIURI> uri;
if (toplevel)
{
- rv = mpriv->browser->GetDocumentUrl (url);
- l = (NS_SUCCEEDED (rv) && url.Length()) ?
- g_strdup (url.get()) : NULL;
+ rv = mpriv->browser->GetDocumentURI (getter_AddRefs (uri));
}
else
{
- rv = mpriv->browser->GetTargetDocumentUrl (url);
- l = (NS_SUCCEEDED (rv) && url.Length()) ?
- g_strdup (url.get()) : NULL;
+ rv = mpriv->browser->GetTargetDocumentURI (getter_AddRefs (uri));
}
- return l;
+ if (NS_FAILED (rv)) return NULL;
+
+ nsCOMPtr<nsIURI> furi;
+ rv = uri->Clone (getter_AddRefs (furi));
+ if (NS_FAILED (rv)) return NULL;
+
+ furi->SetPassword (nsEmbedCString());
+
+ nsEmbedCString url;
+ furi->GetSpec (url);
+
+ return url.Length() ? g_strdup (url.get()) : NULL;
}
static void