Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(992)

Unified Diff: chrome/browser/background/background_mode_manager.cc

Issue 1420163003: Fixed Windows system tray icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@profile-icon-imagefamily
Patch Set: Revert changes to start in a delayed task. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/background/background_mode_manager.cc
diff --git a/chrome/browser/background/background_mode_manager.cc b/chrome/browser/background/background_mode_manager.cc
index 7cd746708b3c3ce691492e25eb8333998d96fe41..d7d18bbdeb1443d6c94c6a00db3c2f1d19e8df41 100644
--- a/chrome/browser/background/background_mode_manager.cc
+++ b/chrome/browser/background/background_mode_manager.cc
@@ -61,6 +61,10 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+#if defined(OS_WIN)
+#include "chrome/browser/app_icon_win.h"
+#endif
+
using base::UserMetricsAction;
using extensions::Extension;
@@ -856,6 +860,33 @@ void BackgroundModeManager::OnBackgroundClientInstalled(
DisplayClientInstalledNotification(name);
}
+// Gets the image for the status tray icon, at the correct size for the current
+// platform and display settings.
+gfx::ImageSkia GetStatusTrayIcon() {
+#if defined(OS_WIN)
+ // On Windows, use GetSmallAppIconSize to get the correct image size. The
+ // user's "text size" setting in Windows determines how large the system tray
+ // icon should be.
+ gfx::Size size = GetSmallAppIconSize();
+
+ // This loads all of the icon images, which is a bit wasteful because we're
+ // going to pick one and throw the rest away, but that is the price of using
+ // the ImageFamily abstraction. Note: We could just use the LoadImage function
+ // from the Windows API, but that does a *terrible* job scaling images.
+ // Therefore, we fetch the images and do our own high-quality scaling.
+ scoped_ptr<gfx::ImageFamily> family = GetAppIconImageFamily();
+ DCHECK(family);
+ if (!family)
+ return gfx::ImageSkia();
+
+ return family->CreateExact(size).AsImageSkia();
+#else
+ // On other platforms, just get a static resource image.
+ return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
+ IDR_STATUS_TRAY_ICON);
+#endif
+}
+
void BackgroundModeManager::CreateStatusTrayIcon() {
// Only need status icons on windows/linux. ChromeOS doesn't allow exiting
// Chrome and Mac can use the dock icon instead.
@@ -872,12 +903,8 @@ void BackgroundModeManager::CreateStatusTrayIcon() {
if (!status_tray_ || status_icon_)
return;
- gfx::ImageSkia* image_skia = ui::ResourceBundle::GetSharedInstance().
- GetImageSkiaNamed(IDR_STATUS_TRAY_ICON);
-
status_icon_ = status_tray_->CreateStatusIcon(
- StatusTray::BACKGROUND_MODE_ICON,
- *image_skia,
+ StatusTray::BACKGROUND_MODE_ICON, GetStatusTrayIcon(),
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
if (!status_icon_)
return;
« no previous file with comments | « chrome/app/theme/chrome_unscaled_resources.grd ('k') | chrome/browser/status_icons/status_icon_menu_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698