summaryrefslogtreecommitdiff
path: root/embed/mozilla/GlobalHistory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'embed/mozilla/GlobalHistory.cpp')
-rw-r--r--embed/mozilla/GlobalHistory.cpp121
1 files changed, 52 insertions, 69 deletions
diff --git a/embed/mozilla/GlobalHistory.cpp b/embed/mozilla/GlobalHistory.cpp
index 4e65161ff..d96417a69 100644
--- a/embed/mozilla/GlobalHistory.cpp
+++ b/embed/mozilla/GlobalHistory.cpp
@@ -28,16 +28,9 @@
#include "GlobalHistory.h"
#include <nsIURI.h>
+#include <nsEmbedString.h>
-#ifdef ALLOW_PRIVATE_STRINGS
-#include <nsString.h>
-#endif
-
-#if MOZILLA_SNAPSHOT > 13
NS_IMPL_ISUPPORTS2(MozGlobalHistory, nsIGlobalHistory2, nsIBrowserHistory)
-#else
-NS_IMPL_ISUPPORTS2(MozGlobalHistory, nsIGlobalHistory, nsIBrowserHistory)
-#endif
MozGlobalHistory::MozGlobalHistory ()
{
@@ -48,13 +41,54 @@ MozGlobalHistory::~MozGlobalHistory ()
{
}
-#if MOZILLA_SNAPSHOT > 13
-
/* void addURI (in nsIURI aURI, in boolean aRedirect, in boolean aToplevel); */
NS_IMETHODIMP MozGlobalHistory::AddURI(nsIURI *aURI, PRBool aRedirect, PRBool aToplevel)
{
- nsCAutoString spec;
- aURI->GetSpec(spec);
+ nsresult rv;
+ NS_ENSURE_ARG_POINTER(aURI);
+
+ PRBool isJavascript;
+ rv = aURI->SchemeIs("javascript", &isJavascript);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ if (isJavascript || aRedirect || !aToplevel)
+ {
+ return NS_OK;
+ }
+
+ // filter out unwanted URIs such as chrome: etc
+ // The model is really if we don't know differently then add which basically
+ // means we are suppose to try all the things we know not to allow in and
+ // then if we don't bail go on and allow it in. But here lets compare
+ // against the most common case we know to allow in and go on and say yes
+ // to it.
+
+ PRBool isHTTP = PR_FALSE;
+ PRBool isHTTPS = PR_FALSE;
+
+ rv = aURI->SchemeIs("http", &isHTTP);
+ rv |= aURI->SchemeIs("https", &isHTTPS);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
+ if (!isHTTP && !isHTTPS)
+ {
+ PRBool isAbout, isViewSource, isChrome, isData;
+
+ rv = aURI->SchemeIs("about", &isAbout);
+ rv |= aURI->SchemeIs("view-source", &isViewSource);
+ rv |= aURI->SchemeIs("chrome", &isChrome);
+ rv |= aURI->SchemeIs("data", &isData);
+ NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
+
+ if (isAbout || isViewSource || isChrome || isData)
+ {
+ return NS_OK;
+ }
+ }
+
+ nsEmbedCString spec;
+ rv = aURI->GetSpec(spec);
+ NS_ENSURE_SUCCESS(rv, rv);
ephy_history_add_page (mGlobalHistory, spec.get());
@@ -64,7 +98,7 @@ NS_IMETHODIMP MozGlobalHistory::AddURI(nsIURI *aURI, PRBool aRedirect, PRBool aT
/* boolean isVisited (in nsIURI aURI); */
NS_IMETHODIMP MozGlobalHistory::IsVisited(nsIURI *aURI, PRBool *_retval)
{
- nsCAutoString spec;
+ nsEmbedCString spec;
aURI->GetSpec(spec);
*_retval = ephy_history_is_page_visited (mGlobalHistory, spec.get());
@@ -75,13 +109,14 @@ NS_IMETHODIMP MozGlobalHistory::IsVisited(nsIURI *aURI, PRBool *_retval)
/* void setPageTitle (in nsIURI aURI, in AString aTitle); */
NS_IMETHODIMP MozGlobalHistory::SetPageTitle(nsIURI *aURI, const nsAString & aTitle)
{
- const nsACString &title = NS_ConvertUTF16toUTF8(aTitle);
+ nsEmbedCString title;
+ NS_UTF16ToCString (nsEmbedString (aTitle),
+ NS_CSTRING_ENCODING_UTF8, title);
- nsCAutoString spec;
+ nsEmbedCString spec;
aURI->GetSpec(spec);
- ephy_history_set_page_title (mGlobalHistory, spec.get(),
- PromiseFlatCString(title).get());
+ ephy_history_set_page_title (mGlobalHistory, spec.get(), title.get());
return NS_OK;
}
@@ -92,43 +127,6 @@ NS_IMETHODIMP MozGlobalHistory::HidePage(nsIURI *url)
return NS_ERROR_NOT_IMPLEMENTED;
}
-#else
-
-/* void addPage (in string aURL); */
-NS_IMETHODIMP MozGlobalHistory::AddPage (const char *aURL)
-{
- ephy_history_add_page (mGlobalHistory, aURL);
-
- return NS_OK;
-}
-
-/* boolean isVisited (in string aURL); */
-NS_IMETHODIMP MozGlobalHistory::IsVisited (const char *aURL, PRBool *_retval)
-{
- *_retval = ephy_history_is_page_visited (mGlobalHistory, aURL);
-
- return NS_OK;
-}
-
-/* void setPageTitle (in string aURL, in wstring aTitle); */
-NS_IMETHODIMP MozGlobalHistory::SetPageTitle (const char *aURL,
- const PRUnichar *aTitle)
-{
- const nsACString &title = NS_ConvertUTF16toUTF8 (aTitle);
-
- ephy_history_set_page_title (mGlobalHistory, aURL, PromiseFlatCString(title).get());
-
- /* done */
- return NS_OK;
-}
-
-NS_IMETHODIMP MozGlobalHistory::HidePage(const char *url)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-
-}
-#endif /* MOZILLA_SNAPSHOT > 13 */
-
/* void removePage (in string aURL); */
NS_IMETHODIMP MozGlobalHistory::RemovePage(const char *aURL)
{
@@ -148,26 +146,11 @@ NS_IMETHODIMP MozGlobalHistory::RemoveAllPages()
return NS_ERROR_NOT_IMPLEMENTED;
}
-#if MOZILLA_SNAPSHOT > 14
/* readonly attribute AUTF8String lastPageVisited; */
NS_IMETHODIMP MozGlobalHistory::GetLastPageVisited(nsACString & aLastPageVisited)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
-#else
-/* readonly attribute string lastPageVisited; */
-NS_IMETHODIMP MozGlobalHistory::GetLastPageVisited(char **aLastPageVisited)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-#endif
-
-#if MOZILLA_SNAPSHOT < 14
-NS_IMETHODIMP MozGlobalHistory::SetLastPageVisited(const char *aLastPageVisited)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-#endif
/* readonly attribute PRUint32 count; */
NS_IMETHODIMP MozGlobalHistory::GetCount(PRUint32 *aCount)