mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 708176 - Part 1: Add nsContentUtils::URIIsChromeOrInPref. r=mounir
--HG-- extra : rebase_source : 9073217bd7a34a5bcd710d7d0671bd021df93164
This commit is contained in:
parent
56dd519e14
commit
0055d0f36c
@ -1836,6 +1836,18 @@ public:
|
||||
*/
|
||||
static bool IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput);
|
||||
|
||||
/**
|
||||
* If the URI is chrome, return true unconditionarlly.
|
||||
*
|
||||
* Otherwise, get the contents of the given pref, and treat it as a
|
||||
* comma-separated list of URIs. Return true if the given URI's prepath is
|
||||
* in the list, and false otherwise.
|
||||
*
|
||||
* Comparisons are case-insensitive, and whitespace between elements of the
|
||||
* comma-separated list is ignored.
|
||||
*/
|
||||
static bool URIIsChromeOrInPref(nsIURI *aURI, const char *aPref);
|
||||
|
||||
private:
|
||||
static bool InitializeEventTable();
|
||||
|
||||
|
@ -211,6 +211,8 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::layers;
|
||||
@ -674,6 +676,40 @@ nsContentUtils::IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput)
|
||||
return autocomplete.EqualsLiteral("on");
|
||||
}
|
||||
|
||||
bool
|
||||
nsContentUtils::URIIsChromeOrInPref(nsIURI *aURI, const char *aPref)
|
||||
{
|
||||
if (!aURI) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCAutoString scheme;
|
||||
aURI->GetScheme(scheme);
|
||||
if (scheme.EqualsLiteral("chrome")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCAutoString prePathUTF8;
|
||||
aURI->GetPrePath(prePathUTF8);
|
||||
NS_ConvertUTF8toUTF16 prePath(prePathUTF8);
|
||||
|
||||
const nsAdoptingString& whitelist = Preferences::GetString(aPref);
|
||||
|
||||
// This tokenizer also strips off whitespace around tokens, as desired.
|
||||
nsCharSeparatedTokenizer tokenizer(whitelist, ',',
|
||||
nsCharSeparatedTokenizerTemplate<>::SEPARATOR_OPTIONAL);
|
||||
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
const nsSubstring& whitelistItem = tokenizer.nextToken();
|
||||
|
||||
if (whitelistItem.Equals(prePath, nsCaseInsensitiveStringComparator())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access a cached parser service. Don't addref. We need only one
|
||||
* reference to it and this class has that one.
|
||||
|
Loading…
Reference in New Issue
Block a user