1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #include "nsCOMPtr.h"
7 #include "nsILanguageAtomService.h"
8 #include "nsIStringBundle.h"
9 #include "nsInterfaceHashtable.h"
10 #include "nsIAtom.h"
11 #include "nsUConvPropertySearch.h"
12 #include "mozilla/Attributes.h"
13 
14 #define NS_LANGUAGEATOMSERVICE_CID \
15   {0xB7C65853, 0x2996, 0x435E, {0x96, 0x54, 0xDC, 0xC1, 0x78, 0xAA, 0xB4, 0x8C}}
16 
17 class nsLanguageAtomService final : public nsILanguageAtomService
18 {
19 public:
20   NS_DECL_ISUPPORTS
21 
22   // nsILanguageAtomService
23   virtual nsIAtom*
24     LookupLanguage(const nsACString &aLanguage, nsresult *aError) override;
25 
26   virtual already_AddRefed<nsIAtom>
27     LookupCharSet(const nsACString& aCharSet) override;
28 
29   virtual nsIAtom* GetLocaleLanguage(nsresult *aError) override;
30 
31   virtual nsIAtom* GetLanguageGroup(nsIAtom *aLanguage,
32                                                 nsresult *aError) override;
33 
34   nsLanguageAtomService();
35 
36 private:
~nsLanguageAtomService()37   ~nsLanguageAtomService() { }
38 
39 protected:
40   nsInterfaceHashtable<nsISupportsHashKey, nsIAtom> mLangToGroup;
41   nsCOMPtr<nsIAtom> mLocaleLanguage;
42 };
43