Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Adding functionality which can be used with brave/browser-laptop#14647
Browse files Browse the repository at this point in the history
Works correctly on Windows; need to do macOS/Linux implementation

Auditors: @darkdh, @bridiver
  • Loading branch information
bsclifton committed Aug 31, 2018
1 parent 246b9fa commit 48f8e40
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions atom/browser/api/atom_api_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,26 @@ void App::SetLocale(std::string locale) {
g_browser_process->SetApplicationLocale(locale);
}

std::string App::GetCountryName() {
std::string country = "";

#if defined(OS_WIN)
WCHAR localized_country_name[80];

int country_name_length = GetLocaleInfoEx(
LOCALE_NAME_USER_DEFAULT,
LOCALE_SLOCALIZEDCOUNTRYNAME,
(LPWSTR)&localized_country_name,
sizeof(localized_country_name) / sizeof(WCHAR));

base::WideToUTF8(localized_country_name,
country_name_length,
&country);
#endif

return country;
}

bool App::GetBooleanPref(const std::string& path) {
return g_browser_process->local_state()->GetBoolean(path);
}
Expand Down Expand Up @@ -954,6 +974,7 @@ void App::BuildPrototype(
.SetMethod("setDesktopName", &App::SetDesktopName)
.SetMethod("getLocale", &App::GetLocale)
.SetMethod("setLocale", &App::SetLocale)
.SetMethod("getCountryName", &App::GetCountryName)
.SetMethod("getBooleanPref", &App::GetBooleanPref)
.SetMethod("setBooleanPref", &App::SetBooleanPref)
.SetMethod("makeSingleInstance", &App::MakeSingleInstance)
Expand Down
1 change: 1 addition & 0 deletions atom/browser/api/atom_api_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class App : public AtomBrowserClient::Delegate,
void SetDesktopName(const std::string& desktop_name);
void SetLocale(std::string);
std::string GetLocale();
std::string GetCountryName();
void SetBooleanPref(const std::string& path, bool value);
bool GetBooleanPref(const std::string& path);
bool MakeSingleInstance(
Expand Down

0 comments on commit 48f8e40

Please sign in to comment.