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

Side by Side Diff: chrome/browser/notifications/desktop_notification_service_win.cc

Issue 10560015: Implement base::win::IsMetroProcess. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 8 years, 6 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
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 "chrome/browser/notifications/desktop_notification_service.h" 5 #include "chrome/browser/notifications/desktop_notification_service.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/win/metro.h" 8 #include "base/win/metro.h"
9 #include "chrome/browser/notifications/notification.h" 9 #include "chrome/browser/notifications/notification.h"
10 #include "chrome/browser/notifications/notification_object_proxy.h" 10 #include "chrome/browser/notifications/notification_object_proxy.h"
11 #include "chrome/browser/notifications/notification_ui_manager.h" 11 #include "chrome/browser/notifications/notification_ui_manager.h"
12 #include "chrome/browser/notifications/notification_ui_manager.h" 12 #include "chrome/browser/notifications/notification_ui_manager.h"
13 13
14 typedef void (*MetroDisplayNotification)( 14 typedef void (*MetroDisplayNotification)(
15 const char* origin_url, const char* icon_url, const wchar_t* title, 15 const char* origin_url, const char* icon_url, const wchar_t* title,
16 const wchar_t* body, const wchar_t* display_source, 16 const wchar_t* body, const wchar_t* display_source,
17 const char* notification_id); 17 const char* notification_id);
18 18
19 typedef bool (*MetroCancelNotification)(const char* notification_id); 19 typedef bool (*MetroCancelNotification)(const char* notification_id);
20 20
21 bool DesktopNotificationService::CancelDesktopNotification( 21 bool DesktopNotificationService::CancelDesktopNotification(
22 int process_id, int route_id, int notification_id) { 22 int process_id, int route_id, int notification_id) {
23 scoped_refptr<NotificationObjectProxy> proxy( 23 scoped_refptr<NotificationObjectProxy> proxy(
24 new NotificationObjectProxy(process_id, route_id, notification_id, 24 new NotificationObjectProxy(process_id, route_id, notification_id,
25 false)); 25 false));
26 if (base::win::GetMetroModule()) { 26 if (base::win::IsMetroProcess()) {
27 MetroCancelNotification cancel_metro_notification = 27 MetroCancelNotification cancel_metro_notification =
28 reinterpret_cast<MetroCancelNotification>(GetProcAddress( 28 reinterpret_cast<MetroCancelNotification>(GetProcAddress(
29 base::win::GetMetroModule(), "CancelNotification")); 29 base::win::GetMetroModule(), "CancelNotification"));
30 DCHECK(cancel_metro_notification); 30 DCHECK(cancel_metro_notification);
31 if (cancel_metro_notification(proxy->id().c_str())) 31 if (cancel_metro_notification(proxy->id().c_str()))
32 return true; 32 return true;
33 } 33 }
34 return GetUIManager()->CancelById(proxy->id()); 34 return GetUIManager()->CancelById(proxy->id());
35 } 35 }
36 36
37 void DesktopNotificationService::ShowNotification( 37 void DesktopNotificationService::ShowNotification(
38 const Notification& notification) { 38 const Notification& notification) {
39 if (base::win::GetMetroModule()) { 39 if (base::win::IsMetroProcess()) {
40 MetroDisplayNotification display_metro_notification = 40 MetroDisplayNotification display_metro_notification =
41 reinterpret_cast<MetroDisplayNotification>(GetProcAddress( 41 reinterpret_cast<MetroDisplayNotification>(GetProcAddress(
42 base::win::GetMetroModule(), "DisplayNotification")); 42 base::win::GetMetroModule(), "DisplayNotification"));
43 DCHECK(display_metro_notification); 43 DCHECK(display_metro_notification);
44 if (!notification.is_html()) { 44 if (!notification.is_html()) {
45 display_metro_notification(notification.origin_url().spec().c_str(), 45 display_metro_notification(notification.origin_url().spec().c_str(),
46 notification.content_url().spec().c_str(), 46 notification.content_url().spec().c_str(),
47 notification.title().c_str(), 47 notification.title().c_str(),
48 notification.body().c_str(), 48 notification.body().c_str(),
49 notification.display_source().c_str(), 49 notification.display_source().c_str(),
50 notification.notification_id().c_str()); 50 notification.notification_id().c_str());
51 return; 51 return;
52 } else { 52 } else {
53 NOTREACHED() << "We don't support HTML notifications in Windows 8 metro"; 53 NOTREACHED() << "We don't support HTML notifications in Windows 8 metro";
54 } 54 }
55 } 55 }
56 GetUIManager()->Add(notification, profile_); 56 GetUIManager()->Add(notification, profile_);
57 } 57 }
OLDNEW
« no previous file with comments | « chrome/browser/first_run/upgrade_util_win.cc ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698