base::Bind(&Browser::SetAsDefaultProtocolClient, browser))
.SetMethod("removeAsDefaultProtocolClient",
base::Bind(&Browser::RemoveAsDefaultProtocolClient, browser))
+ .SetMethod("setBadgeCount", base::Bind(&Browser::SetBadgeCount, browser))
+ .SetMethod("getBadgeCount", base::Bind(&Browser::GetBadgeCount, browser))
#if defined(OS_MACOSX)
.SetMethod("hide", base::Bind(&Browser::Hide, browser))
.SetMethod("show", base::Bind(&Browser::Show, browser))
base::Bind(&Browser::GetCurrentActivityType, browser))
#endif
#if defined(OS_WIN)
- .SetMethod("setUserTasks",
- base::Bind(&Browser::SetUserTasks, browser))
+ .SetMethod("setUserTasks", base::Bind(&Browser::SetUserTasks, browser))
+#endif
+#if defined(OS_LINUX)
+ .SetMethod("isUnityRunning",
+ base::Bind(&Browser::IsUnityRunning, browser))
#endif
.SetMethod("setPath", &App::SetPath)
.SetMethod("getPath", &App::GetPath)
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
name_override_ = name;
}
+int Browser::GetBadgeCount() {
+ return current_badge_count_;
+}
+
bool Browser::OpenFile(const std::string& file_path) {
bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver,
// Query the current state of default handler for a protocol.
bool IsDefaultProtocolClient(const std::string& protocol);
+ // Set/Get the badge count.
+ void SetBadgeCount(int count);
+ int GetBadgeCount();
+
#if defined(OS_MACOSX)
// Hide the application.
void Hide();
#endif // defined(OS_WIN)
#if defined(OS_LINUX)
- // Set/Get unity dock's badge counter.
- bool UnityLauncherAvailable();
- void UnityLauncherSetBadgeCount(int count);
- int UnityLauncherGetBadgeCount();
+ // Whether Unity launcher is running.
+ bool IsUnityRunning();
#endif // defined(OS_LINUX)
// Tell the application to open a file.
std::string version_override_;
std::string name_override_;
-#if defined(OS_LINUX)
int current_badge_count_ = 0;
-#endif
#if defined(OS_WIN)
base::string16 app_user_model_id_;
return false;
}
+void Browser::SetBadgeCount(int count) {
+ current_badge_count_ = count;
+ unity::SetDownloadCount(count);
+}
+
std::string Browser::GetExecutableFileVersion() const {
return brightray::GetApplicationVersion();
}
return brightray::GetApplicationName();
}
-bool Browser::UnityLauncherAvailable() {
+bool Browser::IsUnityRunning() {
return unity::IsRunning();
}
-void Browser::UnityLauncherSetBadgeCount(int count) {
- if (UnityLauncherAvailable()) {
- current_badge_count_ = count;
- unity::SetDownloadCount(count);
- }
-}
-
-int Browser::UnityLauncherGetBadgeCount() {
- return current_badge_count_;
-}
-
} // namespace atom
#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
+#include "base/strings/string_number_conversions.h"
#include "brightray/common/application_info.h"
#include "net/base/mac/url_conversions.h"
#include "url/gurl.h"
void Browser::SetAppUserModelID(const base::string16& name) {
}
+void Browser::SetBadgeCount(int count) {
+ current_badge_count_ = count;
+ DockSetBadgeText(count == 0 ? base::IntToString(count) : "");
+}
+
void Browser::SetUserActivity(const std::string& type,
const base::DictionaryValue& user_info,
mate::Arguments* args) {
}
}
+void Browser::SetBadgeCount(int count) {
+ current_badge_count_ = count;
+}
+
PCWSTR Browser::GetAppUserModelID() {
if (app_user_model_id_.empty()) {
SetAppUserModelID(base::ReplaceStringPlaceholders(
})
})
- describe('app.launcher API', function () {
- it('should be available on linux', function () {
- if (process.platform !== 'linux') {
- assert.equal(app.launcher, undefined)
- } else {
- assert.notEqual(app.launcher, undefined)
- }
- })
-
- it('should be possible to set a badge count on supported environments', function () {
- if (process.platform === 'linux' &&
- app.launcher.isCounterBadgeAvailable()) {
- app.launcher.setBadgeCount(42)
- assert.equal(app.launcher.getBadgeCount(), 42)
- }
- })
-
- it('should be possible to set a badge count on unity', function () {
- if (process.platform === 'linux' &&
- app.launcher.isUnityRunning()) {
- assert.equal(app.launcher.isCounterBadgeAvailable(), true)
- }
- })
-
- it('should not be possible to set a badge counter on unsupported environments', function () {
- if (process.platform === 'linux' &&
- !app.launcher.isCounterBadgeAvailable()) {
- app.launcher.setBadgeCount(42)
- assert.equal(app.launcher.getBadgeCount(), 0)
- }
+ describe('app.getBadgeCount API', function () {
+ it('should set a badge count', function () {
+ app.setBadgeCount(42)
+ assert.equal(app.getBadgeCount(), 42)
})
})
})