aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/EphyBrowser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'embed/mozilla/EphyBrowser.cpp')
-rw-r--r--embed/mozilla/EphyBrowser.cpp48
1 files changed, 19 insertions, 29 deletions
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)