зеркало из https://github.com/electron/electron.git
Implement libunity launcher badge counter to be set via electron, fixes #4193
This commit is contained in:
Родитель
90ea0a365c
Коммит
b22ce93477
|
@ -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')
|
||||
|
|
Загрузка…
Ссылка в новой задаче