Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/ui/views/message_center/web_notification_tray.h" |
| 6 | |
| 7 | #include <windows.h> |
| 8 | |
| 9 | #include "base/win/windows_version.h" |
| 10 | #include "chrome/browser/app_icon_win.h" |
| 11 | #include "chrome/browser/profiles/profile_manager.h" |
| 12 | #include "chrome/browser/status_icons/status_icon.h" |
| 13 | #include "chrome/browser/ui/browser.h" |
| 14 | #include "chrome/browser/ui/browser_finder.h" |
| 15 | #include "chrome/browser/ui/host_desktop.h" |
| 16 | #include "chrome/browser/ui/singleton_tabs.h" |
| 17 | #include "chrome/common/url_constants.h" |
| 18 | #include "grit/chromium_strings.h" |
| 19 | #include "third_party/skia/include/core/SkBitmap.h" |
| 20 | #include "ui/base/l10n/l10n_util.h" |
| 21 | #include "ui/base/resource/resource_bundle.h" |
| 22 | #include "ui/gfx/image/image_skia.h" |
| 23 | |
| 24 | namespace message_center { |
| 25 | void WebNotificationTray::OnBalloonClicked() { |
| 26 | Browser* browser = chrome::FindOrCreateTabbedBrowser( |
| 27 | ProfileManager::GetLastUsedProfileAllowedByPolicy(), |
| 28 | chrome::GetActiveDesktop()); |
| 29 | chrome::ShowSingletonTab(browser, GURL(chrome::kNotificationsHelpURL)); |
| 30 | } |
| 31 | |
| 32 | void WebNotificationTray::DisplayFirstRunBalloon() { |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 33 | // We should never be calling DisplayFirstRunBalloon without a status icon. |
| 34 | // The status icon must have been created before this call. |
| 35 | DCHECK(status_icon_); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 36 | |
| 37 | base::win::Version win_version = base::win::GetVersion(); |
| 38 | if (win_version == base::win::VERSION_PRE_XP) |
| 39 | return; |
| 40 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 41 | // StatusIconWin uses NIIF_LARGE_ICON if the version is >= vista. According |
| 42 | // to http://msdn.microsoft.com/en-us/library/windows/desktop/bb773352.aspx: |
| 43 | // This corresponds to the icon with dimensions SM_CXICON x SM_CYICON. If |
| 44 | // this flag is not set, the icon with dimensions SM_CXSMICON x SM_CYSMICON |
| 45 | // is used. |
| 46 | int icon_size = GetSystemMetrics(SM_CXICON); |
| 47 | if (win_version < base::win::VERSION_VISTA) |
| 48 | icon_size = GetSystemMetrics(SM_CXSMICON); |
| 49 | |
| 50 | scoped_ptr<SkBitmap> sized_app_icon_bitmap = GetAppIconForSize(icon_size); |
| 51 | gfx::ImageSkia sized_app_icon_skia = |
| 52 | gfx::ImageSkia::CreateFrom1xBitmap(*sized_app_icon_bitmap); |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 53 | status_icon_->DisplayBalloon( |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 54 | sized_app_icon_skia, |
| 55 | l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_BALLOON_TITLE), |
| 56 | l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_BALLOON_TEXT)); |
| 57 | } |
| 58 | } // namespace message_center |