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

Side by Side Diff: win8/metro_driver/toast_notification_handler.cc

Issue 11096013: Add functionality to the Windows 8 notification display functionality to invoke a caller specified … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « win8/metro_driver/toast_notification_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "win8/metro_driver/stdafx.h" 7 #include "win8/metro_driver/stdafx.h"
8 #include "win8/metro_driver/toast_notification_handler.h" 8 #include "win8/metro_driver/toast_notification_handler.h"
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 } // namespace 95 } // namespace
96 96
97 ToastNotificationHandler::DesktopNotification::DesktopNotification( 97 ToastNotificationHandler::DesktopNotification::DesktopNotification(
98 const char* notification_origin, 98 const char* notification_origin,
99 const char* notification_icon, 99 const char* notification_icon,
100 const wchar_t* notification_title, 100 const wchar_t* notification_title,
101 const wchar_t* notification_body, 101 const wchar_t* notification_body,
102 const wchar_t* notification_display_source, 102 const wchar_t* notification_display_source,
103 const char* notification_id) 103 const char* notification_id,
104 base::win::MetroNotificationClickedHandler handler,
105 const wchar_t* handler_context)
104 : origin_url(notification_origin), 106 : origin_url(notification_origin),
105 icon_url(notification_icon), 107 icon_url(notification_icon),
106 title(notification_title), 108 title(notification_title),
107 body(notification_body), 109 body(notification_body),
108 display_source(notification_display_source), 110 display_source(notification_display_source),
109 id(notification_id) { 111 id(notification_id),
112 notification_handler(handler) {
113 if (handler_context)
114 notification_context = handler_context;
110 } 115 }
111 116
117 ToastNotificationHandler::DesktopNotification::DesktopNotification()
118 : notification_handler(NULL) {
119 }
112 120
113 ToastNotificationHandler::ToastNotificationHandler() { 121 ToastNotificationHandler::ToastNotificationHandler() {
114 DVLOG(1) << __FUNCTION__; 122 DVLOG(1) << __FUNCTION__;
115 } 123 }
116 124
117 ToastNotificationHandler::~ToastNotificationHandler() { 125 ToastNotificationHandler::~ToastNotificationHandler() {
118 DVLOG(1) << __FUNCTION__; 126 DVLOG(1) << __FUNCTION__;
119 127
120 if (notifier_ && notification_) 128 if (notifier_ && notification_)
121 CancelNotification(); 129 CancelNotification();
122 } 130 }
123 131
124 void ToastNotificationHandler::DisplayNotification( 132 void ToastNotificationHandler::DisplayNotification(
125 const DesktopNotification& notification) { 133 const DesktopNotification& notification) {
126 DVLOG(1) << __FUNCTION__; 134 DVLOG(1) << __FUNCTION__;
127 135
128 DCHECK(notifier_.Get() == NULL); 136 DCHECK(notifier_.Get() == NULL);
129 DCHECK(notification_.Get() == NULL); 137 DCHECK(notification_.Get() == NULL);
130 138
139 notification_info_ = notification;
140
131 mswr::ComPtr<winui::Notifications::IToastNotificationManagerStatics> 141 mswr::ComPtr<winui::Notifications::IToastNotificationManagerStatics>
132 toast_manager; 142 toast_manager;
133 143
134 HRESULT hr = winrt_utils::CreateActivationFactory( 144 HRESULT hr = winrt_utils::CreateActivationFactory(
135 RuntimeClass_Windows_UI_Notifications_ToastNotificationManager, 145 RuntimeClass_Windows_UI_Notifications_ToastNotificationManager,
136 toast_manager.GetAddressOf()); 146 toast_manager.GetAddressOf());
137 CheckHR(hr); 147 CheckHR(hr);
138 148
139 mswr::ComPtr<winxml::Dom::IXmlDocument> toast_xml; 149 mswr::ComPtr<winxml::Dom::IXmlDocument> toast_xml;
140 hr = toast_manager->GetTemplateContent( 150 hr = toast_manager->GetTemplateContent(
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 233 }
224 234
225 HRESULT ToastNotificationHandler::OnActivate( 235 HRESULT ToastNotificationHandler::OnActivate(
226 winui::Notifications::IToastNotification* notification, 236 winui::Notifications::IToastNotification* notification,
227 IInspectable* inspectable) { 237 IInspectable* inspectable) {
228 // TODO(ananta) 238 // TODO(ananta)
229 // We should pass back information from the notification like the source url 239 // We should pass back information from the notification like the source url
230 // etc to ChromeAppView which would enable it to ensure that the 240 // etc to ChromeAppView which would enable it to ensure that the
231 // correct tab in chrome is activated. 241 // correct tab in chrome is activated.
232 DVLOG(1) << __FUNCTION__; 242 DVLOG(1) << __FUNCTION__;
243
244 if (notification_info_.notification_handler) {
245 notification_info_.notification_handler(
246 notification_info_.notification_context.c_str());
247 }
233 return S_OK; 248 return S_OK;
234 } 249 }
OLDNEW
« no previous file with comments | « win8/metro_driver/toast_notification_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698