OLD | NEW |
| (Empty) |
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 #include "base/win/windows_version.h" | |
9 #include "chrome/browser/app_icon_win.h" | |
10 #include "chrome/browser/profiles/profile_manager.h" | |
11 #include "chrome/browser/status_icons/status_icon.h" | |
12 #include "chrome/browser/ui/browser.h" | |
13 #include "chrome/browser/ui/host_desktop.h" | |
14 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | |
15 #include "chrome/browser/ui/singleton_tabs.h" | |
16 #include "chrome/common/url_constants.h" | |
17 #include "chrome/grit/chromium_strings.h" | |
18 #include "third_party/skia/include/core/SkBitmap.h" | |
19 #include "ui/base/l10n/l10n_util.h" | |
20 #include "ui/gfx/image/image_skia.h" | |
21 | |
22 namespace message_center { | |
23 void WebNotificationTray::OnBalloonClicked() { | |
24 chrome::ScopedTabbedBrowserDisplayer displayer( | |
25 ProfileManager::GetLastUsedProfileAllowedByPolicy(), | |
26 chrome::GetActiveDesktop()); | |
27 chrome::ShowSingletonTab(displayer.browser(), | |
28 GURL(chrome::kNotificationsHelpURL)); | |
29 } | |
30 | |
31 void WebNotificationTray::DisplayFirstRunBalloon() { | |
32 // We should never be calling DisplayFirstRunBalloon without a status icon. | |
33 // The status icon must have been created before this call. | |
34 DCHECK(status_icon_); | |
35 | |
36 base::win::Version win_version = base::win::GetVersion(); | |
37 if (win_version == base::win::VERSION_PRE_XP) | |
38 return; | |
39 | |
40 // StatusIconWin uses NIIF_LARGE_ICON if the version is >= vista. According | |
41 // to http://msdn.microsoft.com/en-us/library/windows/desktop/bb773352.aspx: | |
42 // This corresponds to the icon with dimensions SM_CXICON x SM_CYICON. If | |
43 // this flag is not set, the icon with dimensions SM_CXSMICON x SM_CYSMICON | |
44 // is used. | |
45 int icon_size = GetSystemMetrics(SM_CXICON); | |
46 if (win_version < base::win::VERSION_VISTA) | |
47 icon_size = GetSystemMetrics(SM_CXSMICON); | |
48 | |
49 scoped_ptr<SkBitmap> sized_app_icon_bitmap = GetAppIconForSize(icon_size); | |
50 gfx::ImageSkia sized_app_icon_skia = | |
51 gfx::ImageSkia::CreateFrom1xBitmap(*sized_app_icon_bitmap); | |
52 status_icon_->DisplayBalloon( | |
53 sized_app_icon_skia, | |
54 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_BALLOON_TITLE), | |
55 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_BALLOON_TEXT)); | |
56 } | |
57 | |
58 void WebNotificationTray::EnforceStatusIconVisible() { | |
59 DCHECK(status_icon_); | |
60 status_icon_->ForceVisible(); | |
61 } | |
62 | |
63 } // namespace message_center | |
OLD | NEW |