Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
*
3
* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "OSPreferences.h"
8
#include "mozilla/Preferences.h"
9
10
#include "FennecJNIWrappers.h"
11
#include "GeneratedJNIWrappers.h"
12
13
using namespace mozilla::intl;
14
15
OSPreferences::OSPreferences() {}
16
17
OSPreferences::~OSPreferences() {}
18
19
bool OSPreferences::ReadSystemLocales(nsTArray<nsCString>& aLocaleList) {
20
if (!mozilla::jni::IsAvailable()) {
21
return false;
22
}
23
24
// XXX: Notice, this value may be empty on an early read. In that case
25
// we won't add anything to the return list so that it doesn't get
26
// cached in mSystemLocales.
27
auto locales = mozilla::jni::IsFennec()
28
? java::BrowserLocaleManager::GetLocales()
29
: java::GeckoAppShell::GetDefaultLocales();
30
if (locales) {
31
for (size_t i = 0; i < locales->Length(); i++) {
32
jni::String::LocalRef locale = locales->GetElement(i);
33
aLocaleList.AppendElement(locale->ToCString());
34
}
35
return true;
36
}
37
return false;
38
}
39
40
bool OSPreferences::ReadRegionalPrefsLocales(nsTArray<nsCString>& aLocaleList) {
41
// For now we're just taking System Locales since we don't know of any better
42
// API for regional prefs.
43
return ReadSystemLocales(aLocaleList);
44
}
45
46
bool OSPreferences::ReadDateTimePattern(DateTimeFormatStyle aDateStyle,
47
DateTimeFormatStyle aTimeStyle,
48
const nsACString& aLocale,
49
nsAString& aRetVal) {
50
return false;
51
}