summaryrefslogtreecommitdiffstats
path: root/win8
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 00:08:42 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 00:08:42 +0000
commitda7c6b51086d02e35f7240f619704d7f4ede7493 (patch)
tree6300b59d17e275682e492861953b24bea23eab79 /win8
parentf58b6b6dbbec20b456b0b6f02347ff5fc5e0c2b6 (diff)
downloadchromium_src-da7c6b51086d02e35f7240f619704d7f4ede7493.zip
chromium_src-da7c6b51086d02e35f7240f619704d7f4ede7493.tar.gz
chromium_src-da7c6b51086d02e35f7240f619704d7f4ede7493.tar.bz2
Add functionality to the Windows 8 notification display functionality to invoke a caller specified handler function
with a string parameter. Currently the only consumer of this functionality is the download notification display code which when invoked displays the downloaded file in the shell. BUG=151141 R=cpu Review URL: https://codereview.chromium.org/11096013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160988 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8')
-rw-r--r--win8/metro_driver/chrome_app_view.cc13
-rw-r--r--win8/metro_driver/toast_notification_handler.cc19
-rw-r--r--win8/metro_driver/toast_notification_handler.h11
3 files changed, 36 insertions, 7 deletions
diff --git a/win8/metro_driver/chrome_app_view.cc b/win8/metro_driver/chrome_app_view.cc
index 71392d0..28e9e76 100644
--- a/win8/metro_driver/chrome_app_view.cc
+++ b/win8/metro_driver/chrome_app_view.cc
@@ -519,7 +519,9 @@ extern "C" __declspec(dllexport)
void DisplayNotification(const char* origin_url, const char* icon_url,
const wchar_t* title, const wchar_t* body,
const wchar_t* display_source,
- const char* notification_id) {
+ const char* notification_id,
+ base::win::MetroNotificationClickedHandler handler,
+ const wchar_t* handler_context) {
// TODO(ananta)
// Needs implementation.
DVLOG(1) << __FUNCTION__;
@@ -529,7 +531,9 @@ void DisplayNotification(const char* origin_url, const char* icon_url,
title,
body,
display_source,
- notification_id);
+ notification_id,
+ handler,
+ handler_context);
globals.appview_msg_loop->PostTask(
FROM_HERE, base::Bind(&ChromeAppView::DisplayNotification,
globals.view, notification));
@@ -843,6 +847,9 @@ ChromeAppView::Run() {
options.message_loop_type = MessageLoop::TYPE_IO;
thread.StartWithOptions(options);
+ // The viewer channel opened below only applies when we are launched as an
+ // AURA viewer process.
+#if defined(USE_AURA)
ChromeChannelListener channel_listener;
IPC::ChannelProxy chan("viewer", IPC::Channel::MODE_NAMED_CLIENT,
&channel_listener, thread.message_loop_proxy());
@@ -851,7 +858,7 @@ ChromeAppView::Run() {
gfx::NativeViewId(globals.core_window)));
DVLOG(1) << "ICoreWindow sent " << globals.core_window;
-
+#endif
// And post the task that'll do the inner Metro message pumping to it.
msg_loop.PostTask(FROM_HERE, base::Bind(&RunMessageLoop, dispatcher.Get()));
diff --git a/win8/metro_driver/toast_notification_handler.cc b/win8/metro_driver/toast_notification_handler.cc
index 36bddd5..5545cd2 100644
--- a/win8/metro_driver/toast_notification_handler.cc
+++ b/win8/metro_driver/toast_notification_handler.cc
@@ -100,15 +100,23 @@ ToastNotificationHandler::DesktopNotification::DesktopNotification(
const wchar_t* notification_title,
const wchar_t* notification_body,
const wchar_t* notification_display_source,
- const char* notification_id)
+ const char* notification_id,
+ base::win::MetroNotificationClickedHandler handler,
+ const wchar_t* handler_context)
: origin_url(notification_origin),
icon_url(notification_icon),
title(notification_title),
body(notification_body),
display_source(notification_display_source),
- id(notification_id) {
+ id(notification_id),
+ notification_handler(handler) {
+ if (handler_context)
+ notification_context = handler_context;
}
+ToastNotificationHandler::DesktopNotification::DesktopNotification()
+ : notification_handler(NULL) {
+}
ToastNotificationHandler::ToastNotificationHandler() {
DVLOG(1) << __FUNCTION__;
@@ -128,6 +136,8 @@ void ToastNotificationHandler::DisplayNotification(
DCHECK(notifier_.Get() == NULL);
DCHECK(notification_.Get() == NULL);
+ notification_info_ = notification;
+
mswr::ComPtr<winui::Notifications::IToastNotificationManagerStatics>
toast_manager;
@@ -230,5 +240,10 @@ HRESULT ToastNotificationHandler::OnActivate(
// etc to ChromeAppView which would enable it to ensure that the
// correct tab in chrome is activated.
DVLOG(1) << __FUNCTION__;
+
+ if (notification_info_.notification_handler) {
+ notification_info_.notification_handler(
+ notification_info_.notification_context.c_str());
+ }
return S_OK;
}
diff --git a/win8/metro_driver/toast_notification_handler.h b/win8/metro_driver/toast_notification_handler.h
index f560e34..b1ef338 100644
--- a/win8/metro_driver/toast_notification_handler.h
+++ b/win8/metro_driver/toast_notification_handler.h
@@ -8,6 +8,7 @@
#include <windows.ui.notifications.h>
#include "base/string16.h"
+#include "base/win/metro.h"
// Provides functionality to display a metro style toast notification.
class ToastNotificationHandler {
@@ -20,13 +21,19 @@ class ToastNotificationHandler {
string16 body;
string16 display_source;
std::string id;
+ base::win::MetroNotificationClickedHandler notification_handler;
+ string16 notification_context;
DesktopNotification(const char* notification_origin,
const char* notification_icon,
const wchar_t* notification_title,
const wchar_t* notification_body,
const wchar_t* notification_display_source,
- const char* notification_id);
+ const char* notification_id,
+ base::win::MetroNotificationClickedHandler handler,
+ const wchar_t* handler_context);
+
+ DesktopNotification();
};
ToastNotificationHandler();
@@ -41,8 +48,8 @@ class ToastNotificationHandler {
private:
mswr::ComPtr<winui::Notifications::IToastNotifier> notifier_;
mswr::ComPtr<winui::Notifications::IToastNotification> notification_;
-
EventRegistrationToken activated_token_;
+ DesktopNotification notification_info_;
};
#endif // CHROME_BROWSER_UI_METRO_DRIVER_TOAST_NOTIFICATION_HANDLER_H_