Use the appname as the tray icon's default tooltip (#12388)

This makes an upstream DCHECK happy in AppIndicatorIcon::SetToolTip.
Empty tooltip strings are discouraged, as discussed in commit log
b6c510aa543193337041517c2d70113840189b06.

Fixes #12386.
This commit is contained in:
Charles Kerr 2018-03-21 12:15:30 -05:00 committed by GitHub
parent 6fa4ec22c5
commit 0d7becff87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@
#include "atom/browser/browser.h" #include "atom/browser/browser.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "brightray/common/application_info.h"
#include "chrome/browser/ui/libgtkui/app_indicator_icon.h" #include "chrome/browser/ui/libgtkui/app_indicator_icon.h"
#include "chrome/browser/ui/libgtkui/gtk_status_icon.h" #include "chrome/browser/ui/libgtkui/gtk_status_icon.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
@ -32,16 +33,17 @@ void TrayIconGtk::SetImage(const gfx::Image& image) {
return; return;
} }
base::string16 empty; const auto toolTip = base::UTF8ToUTF16(brightray::GetApplicationName());
if (libgtkui::AppIndicatorIcon::CouldOpen()) { if (libgtkui::AppIndicatorIcon::CouldOpen()) {
++indicators_count; ++indicators_count;
icon_.reset(new libgtkui::AppIndicatorIcon( icon_.reset(new libgtkui::AppIndicatorIcon(
base::StringPrintf( base::StringPrintf(
"%s%d", Browser::Get()->GetName().c_str(), indicators_count), "%s%d", Browser::Get()->GetName().c_str(), indicators_count),
image.AsImageSkia(), image.AsImageSkia(),
empty)); toolTip));
} else { } else {
icon_.reset(new libgtkui::Gtk2StatusIcon(image.AsImageSkia(), empty)); icon_.reset(new libgtkui::Gtk2StatusIcon(image.AsImageSkia(), toolTip));
} }
icon_->set_delegate(this); icon_->set_delegate(this);
} }