1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_dom_FallbackEncoding_h_
6 #define mozilla_dom_FallbackEncoding_h_
13 class FallbackEncoding
18 * Whether FromTopLevelDomain() should be used.
20 static bool sGuessFallbackFromTopLevelDomain
;
23 * Gets the locale-dependent fallback encoding for legacy HTML and plain
26 * @param aFallback the outparam for the fallback encoding
28 static void FromLocale(nsACString
& aFallback
);
31 * Checks if it is appropriate to call FromTopLevelDomain() for a given TLD.
33 * @param aTLD the top-level domain (in Punycode)
34 * @return true if OK to call FromTopLevelDomain()
36 static bool IsParticipatingTopLevelDomain(const nsACString
& aTLD
);
39 * Gets a top-level domain-depedendent fallback encoding for legacy HTML
40 * and plain text content
42 * @param aTLD the top-level domain (in Punycode)
43 * @param aFallback the outparam for the fallback encoding
45 static void FromTopLevelDomain(const nsACString
& aTLD
, nsACString
& aFallback
);
47 // public API ends here!
50 * Allocate sInstance used by FromLocale().
51 * To be called from nsLayoutStatics only.
53 static void Initialize();
56 * Delete sInstance used by FromLocale().
57 * To be called from nsLayoutStatics only.
59 static void Shutdown();
66 static FallbackEncoding
* sInstance
;
72 * Invalidates the cache.
79 static void PrefChanged(const char*, void*);
82 * Gets the fallback encoding label.
83 * @param aFallback the fallback encoding
85 void Get(nsACString
& aFallback
);
93 #endif // mozilla_dom_FallbackEncoding_h_