Bumping manifests a=b2g-bump
[gecko.git] / dom / encoding / FallbackEncoding.h
blob431dd4ee8d80a4aee87b916690c14eb993966cd0
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_
8 #include "nsString.h"
10 namespace mozilla {
11 namespace dom {
13 class FallbackEncoding
15 public:
17 /**
18 * Whether FromTopLevelDomain() should be used.
20 static bool sGuessFallbackFromTopLevelDomain;
22 /**
23 * Gets the locale-dependent fallback encoding for legacy HTML and plain
24 * text content.
26 * @param aFallback the outparam for the fallback encoding
28 static void FromLocale(nsACString& aFallback);
30 /**
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);
38 /**
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!
49 /**
50 * Allocate sInstance used by FromLocale().
51 * To be called from nsLayoutStatics only.
53 static void Initialize();
55 /**
56 * Delete sInstance used by FromLocale().
57 * To be called from nsLayoutStatics only.
59 static void Shutdown();
61 private:
63 /**
64 * The fallback cache.
66 static FallbackEncoding* sInstance;
68 FallbackEncoding();
69 ~FallbackEncoding();
71 /**
72 * Invalidates the cache.
74 void Invalidate()
76 mFallback.Truncate();
79 static void PrefChanged(const char*, void*);
81 /**
82 * Gets the fallback encoding label.
83 * @param aFallback the fallback encoding
85 void Get(nsACString& aFallback);
87 nsCString mFallback;
90 } // dom
91 } // mozilla
93 #endif // mozilla_dom_FallbackEncoding_h_