Implement libunity launcher badge counter to be set via electron, fixes #4193

This commit is contained in:
Jonas Schwabe 2016-06-26 01:55:24 +02:00
Родитель 90ea0a365c
Коммит b22ce93477
4 изменённых файлов: 41 добавлений и 1 удалений

Просмотреть файл

@ -614,6 +614,16 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
dict.SetMethod("dockSetMenu", &DockSetMenu);
dict.SetMethod("dockSetIcon", base::Bind(&Browser::DockSetIcon, browser));
#endif
#if defined(OS_LINUX)
auto browser = base::Unretained(Browser::Get());
dict.SetMethod("unityLauncherAvailable",
base::Bind(&Browser::UnityLauncherAvailable, browser));
dict.SetMethod("unityLauncherSetBadgeCount",
base::Bind(&Browser::UnityLauncherSetBadgeCount, browser));
dict.SetMethod("unityLauncherGetBadgeCount",
base::Bind(&Browser::UnityLauncherGetBadgeCount, browser));
#endif
}
} // namespace

Просмотреть файл

@ -149,7 +149,14 @@ class Browser : public WindowListObserver {
// one from app's name.
// The returned string managed by Browser, and should not be modified.
PCWSTR GetAppUserModelID();
#endif
#endif // defined(OS_WIN)
#if defined(OS_LINUX)
// Set/Get unity dock's badge counter.
bool UnityLauncherAvailable();
void UnityLauncherSetBadgeCount(int count);
int UnityLauncherGetBadgeCount();
#endif // defined(OS_LINUX)
// Tell the application to open a file.
bool OpenFile(const std::string& file_path);
@ -216,6 +223,8 @@ class Browser : public WindowListObserver {
std::string version_override_;
std::string name_override_;
int current_badge_count_ = 0;
#if defined(OS_WIN)
base::string16 app_user_model_id_;
#endif

Просмотреть файл

@ -10,6 +10,7 @@
#include "atom/browser/window_list.h"
#include "atom/common/atom_version.h"
#include "brightray/common/application_info.h"
#include "chrome/browser/ui/libgtk2ui/unity_service.h"
namespace atom {
@ -54,4 +55,17 @@ std::string Browser::GetExecutableFileProductName() const {
return brightray::GetApplicationName();
}
bool Browser::UnityLauncherAvailable() {
return unity::IsRunning();
}
void Browser::UnityLauncherSetBadgeCount(int count) {
current_badge_count_ = count;
unity::SetDownloadCount(count);
}
int Browser::UnityLauncherGetBadgeCount() {
return current_badge_count_;
}
} // namespace atom

Просмотреть файл

@ -45,6 +45,13 @@ if (process.platform === 'darwin') {
}
}
if (process.platform === 'linux' && bindings.unityLauncherAvailable()) {
app.unityLauncher = {
setBadgeCount: bindings.unityLauncherSetBadgeCount,
getBadgeCount: bindings.unityLauncherGetBadgeCount
};
}
app.allowNTLMCredentialsForAllDomains = function (allow) {
if (!process.noDeprecations) {
deprecate.warn('app.allowNTLMCredentialsForAllDomains', 'session.allowNTLMCredentialsForDomains')