Index: chrome/browser/ui/views/message_center/web_notification_tray_win.cc |
diff --git a/chrome/browser/ui/views/message_center/web_notification_tray_win.cc b/chrome/browser/ui/views/message_center/web_notification_tray_win.cc |
index 8df1becd7227e6fdbbb736bbe79ecd2ce9d19855..937143b1f8c1f23e089b07c99fa008878de4fe6a 100644 |
--- a/chrome/browser/ui/views/message_center/web_notification_tray_win.cc |
+++ b/chrome/browser/ui/views/message_center/web_notification_tray_win.cc |
@@ -5,7 +5,11 @@ |
#include "chrome/browser/ui/views/message_center/web_notification_tray.h" |
#include <windows.h> |
+#include <objbase.h> |
+#include "base/memory/ref_counted.h" |
+#include "base/threading/worker_pool.h" |
+#include "base/win/scoped_com_initializer.h" |
#include "base/win/windows_version.h" |
#include "chrome/browser/app_icon_win.h" |
#include "chrome/browser/profiles/profile_manager.h" |
@@ -14,6 +18,8 @@ |
#include "chrome/browser/ui/host_desktop.h" |
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
#include "chrome/browser/ui/singleton_tabs.h" |
+#include "chrome/browser/ui/views/message_center/tray_watcher_win.h" |
+#include "chrome/browser/ui/views/status_icons/status_icon_win.h" |
#include "chrome/common/url_constants.h" |
#include "grit/chromium_strings.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
@@ -21,6 +27,21 @@ |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/gfx/image/image_skia.h" |
+namespace { |
+ |
+// This method is called on a worker pool thread. |
+void PromoteMatchingTrayIcon(UINT icon_id, HWND window) { |
+ // It appears that IUnknowns are coincidentally compatible with |
+ // scoped_refptr. Normally I wouldn't depend on that but it seems that |
+ // base::win::IUnknownImpl itself depends on that coincidence so it's |
+ // already being assumed elsewhere. |
+ scoped_refptr<message_center::TrayWatcherWin> tray_watcher( |
+ new message_center::TrayWatcherWin(icon_id, window)); |
+ tray_watcher->EnsureTrayIconVisible(); |
+} |
+ |
+} // namespace |
+ |
namespace message_center { |
void WebNotificationTray::OnBalloonClicked() { |
chrome::ScopedTabbedBrowserDisplayer displayer( |
@@ -56,4 +77,31 @@ void WebNotificationTray::DisplayFirstRunBalloon() { |
l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_BALLOON_TITLE), |
l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_BALLOON_TEXT)); |
} |
+ |
+void WebNotificationTray::EnforceStatusIconVisible() { |
+ DCHECK(status_icon_); |
+ StatusIconWin* status_icon_win = status_icon_->AsStatusIconWin(); |
+ // If we are in single-window metro mode, can't really do anything |
+ // here. |
+ if (status_icon_win == NULL) |
+ return; |
+ |
+ worker_thread_.reset(new base::Thread("COMWorkerThread")); |
+ worker_thread_->init_com_with_mta(false); |
+ worker_thread_->Start(); |
+ worker_thread_->message_loop_proxy()->PostTaskAndReply( |
+ FROM_HERE, |
+ base::Bind(PromoteMatchingTrayIcon, |
+ status_icon_win->icon_id(), |
+ status_icon_win->hwnd()), |
+ base::Bind(&WebNotificationTray::JoinWorkerThread, AsWeakPtr())); |
+} |
+ |
+void WebNotificationTray::JoinWorkerThread() { |
+ if (worker_thread_) { |
+ worker_thread_->Stop(); |
+ worker_thread_.reset(); |
+ } |
+} |
+ |
} // namespace message_center |