Use fixed ID for app indicators
authorCheng Zhao <zcbenz@gmail.com>
Mon, 20 Jun 2016 08:35:45 +0000 (17:35 +0900)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 20 Jun 2016 08:35:45 +0000 (17:35 +0900)
atom/browser/ui/tray_icon_gtk.cc

index 666e641..3e53390 100644 (file)
@@ -4,7 +4,8 @@
 
 #include "atom/browser/ui/tray_icon_gtk.h"
 
-#include "base/guid.h"
+#include "atom/browser/browser.h"
+#include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h"
 #include "chrome/browser/ui/libgtk2ui/gtk2_status_icon.h"
 
 namespace atom {
 
+namespace {
+
+// Number of app indicators used (used as part of app-indicator id).
+int indicators_count;
+
+}  // namespace
+
 TrayIconGtk::TrayIconGtk() {
 }
 
@@ -25,11 +33,16 @@ void TrayIconGtk::SetImage(const gfx::Image& image) {
   }
 
   base::string16 empty;
-  if (libgtk2ui::AppIndicatorIcon::CouldOpen())
+  if (libgtk2ui::AppIndicatorIcon::CouldOpen()) {
+    ++indicators_count;
     icon_.reset(new libgtk2ui::AppIndicatorIcon(
-        base::GenerateGUID(), image.AsImageSkia(), empty));
-  else
+        base::StringPrintf(
+            "%s%d", Browser::Get()->GetName().c_str(), indicators_count),
+        image.AsImageSkia(),
+        empty));
+  } else {
     icon_.reset(new libgtk2ui::Gtk2StatusIcon(image.AsImageSkia(), empty));
+  }
   icon_->set_delegate(this);
 }