Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ash / system / ime / tray_ime.cc
index 695e83e..beec2f5 100644 (file)
@@ -190,7 +190,8 @@ TrayIME::TrayIME(SystemTray* system_tray)
       tray_label_(NULL),
       default_(NULL),
       detailed_(NULL),
-      message_shown_(false) {
+      message_shown_(false),
+      weak_factory_(this) {
   Shell::GetInstance()->system_tray_notifier()->AddIMEObserver(this);
 }
 
@@ -202,13 +203,17 @@ TrayIME::~TrayIME() {
 
 void TrayIME::UpdateTrayLabel(const IMEInfo& current, size_t count) {
   if (tray_label_) {
+    bool visible = count > 1;
+    tray_label_->SetVisible(visible);
+    // Do not change label before hiding because this change is noticeable.
+    if (!visible)
+      return;
     if (current.third_party) {
       tray_label_->label()->SetText(
           current.short_name + base::UTF8ToUTF16("*"));
     } else {
       tray_label_->label()->SetText(current.short_name);
     }
-    tray_label_->SetVisible(count > 1);
     SetTrayLabelItemBorder(tray_label_, system_tray()->shelf_alignment());
     tray_label_->Layout();
   }
@@ -243,7 +248,7 @@ void TrayIME::UpdateOrCreateNotification() {
       message_center::RichNotificationData(),
       new message_center::HandleNotificationClickedDelegate(
           base::Bind(&TrayIME::PopupDetailedView,
-                     base::Unretained(this), 0, true))));
+                     weak_factory_.GetWeakPtr(), 0, true))));
   message_center->AddNotification(notification.Pass());
   message_shown_ = true;
 }