Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / message_center / web_notification_tray.cc
index fd62ea4..fec2615 100644 (file)
 #include "ui/strings/grit/ui_strings.h"
 #include "ui/views/widget/widget.h"
 
+#if defined(OS_LINUX)
+#include "base/environment.h"
+#include "base/nix/xdg_util.h"
+#endif
+
 namespace {
 
 // Tray constants
@@ -60,6 +65,20 @@ gfx::ImageSkia* GetIcon(int unread_count, bool is_quiet_mode) {
   return rb.GetImageSkiaNamed(resource_id);
 }
 
+bool CanDestroyStatusIcon() {
+#if defined(OS_LINUX)
+  // Avoid creating multiple system tray icons on KDE4 and newer versions of KDE
+  // because the OS does not support removing system tray icons.
+  // TODO(pkotwicz): This is a hack for the sake of M40. Fix this properly.
+  scoped_ptr<base::Environment> env(base::Environment::Create());
+  base::nix::DesktopEnvironment desktop_environment =
+      base::nix::GetDesktopEnvironment(env.get());
+  return desktop_environment != base::nix::DESKTOP_ENVIRONMENT_KDE4;
+#else
+  return true;
+#endif
+}
+
 }  // namespace
 
 namespace message_center {
@@ -276,7 +295,8 @@ void WebNotificationTray::UpdateStatusIcon() {
     tool_tip = l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_TOOLTIP);
   }
 
-  if (message_center()->GetVisibleNotifications().empty()) {
+  if (message_center()->GetVisibleNotifications().empty() &&
+      CanDestroyStatusIcon()) {
     DestroyStatusIcon();
     return;
   }