Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / notifications / desktop_notification_service_win.cc
blobcc41eb4f98836b41c47c32ec44a7dc8106037e56
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
3 // found in the LICENSE file.
5 #include "chrome/browser/notifications/desktop_notification_service.h"
7 #include "base/logging.h"
8 #include "base/win/metro.h"
9 #include "chrome/browser/notifications/notification.h"
10 #include "chrome/browser/notifications/notification_object_proxy.h"
11 #include "chrome/browser/notifications/notification_ui_manager.h"
12 #include "chrome/browser/notifications/notification_ui_manager.h"
13 #include "win8/util/win8_util.h"
15 bool DesktopNotificationService::CancelDesktopNotification(
16 int process_id, int route_id, int notification_id) {
17 scoped_refptr<NotificationObjectProxy> proxy(
18 new NotificationObjectProxy(process_id, route_id, notification_id,
19 false));
20 if (win8::IsSingleWindowMetroMode()) {
21 base::win::MetroCancelNotification cancel_metro_notification =
22 reinterpret_cast<base::win::MetroCancelNotification>(GetProcAddress(
23 base::win::GetMetroModule(), "CancelNotification"));
24 DCHECK(cancel_metro_notification);
25 if (cancel_metro_notification(proxy->id().c_str()))
26 return true;
28 return GetUIManager()->CancelById(proxy->id());
31 void DesktopNotificationService::ShowNotification(
32 const Notification& notification) {
33 if (win8::IsSingleWindowMetroMode()) {
34 base::win::MetroNotification display_metro_notification =
35 reinterpret_cast<base::win::MetroNotification>(GetProcAddress(
36 base::win::GetMetroModule(), "DisplayNotification"));
37 DCHECK(display_metro_notification);
38 if (!notification.is_html()) {
39 display_metro_notification(notification.origin_url().spec().c_str(),
40 notification.content_url().spec().c_str(),
41 notification.title().c_str(),
42 notification.message().c_str(),
43 notification.display_source().c_str(),
44 notification.notification_id().c_str(),
45 NULL, NULL);
46 return;
47 } else {
48 NOTREACHED() << "We don't support HTML notifications in Windows 8 metro";
51 GetUIManager()->Add(notification, profile_);