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

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

Issue 342043: Connect the various pieces for notifications... hook up NotificationUIManager... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove stale TODO Created 11 years, 1 month 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_list.h" 12 #include "chrome/browser/browser_list.h"
13 #include "chrome/browser/chrome_thread.h" 13 #include "chrome/browser/chrome_thread.h"
14 #include "chrome/browser/notifications/notification_object_proxy.h" 14 #include "chrome/browser/notifications/notification_object_proxy.h"
15 #include "chrome/browser/notifications/notification_ui_manager.h"
15 #include "chrome/browser/renderer_host/render_process_host.h" 16 #include "chrome/browser/renderer_host/render_process_host.h"
16 #include "chrome/browser/renderer_host/site_instance.h" 17 #include "chrome/browser/renderer_host/site_instance.h"
17 #include "chrome/browser/worker_host/worker_process_host.h"
18 #include "chrome/common/child_process_host.h" 18 #include "chrome/common/child_process_host.h"
19 #include "grit/browser_resources.h" 19 #include "grit/browser_resources.h"
20 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
21 21
22 // Creates a data:xxxx URL which contains the full HTML for a notification 22 // Creates a data:xxxx URL which contains the full HTML for a notification
23 // using supplied icon, title, and text, run through a template which contains 23 // using supplied icon, title, and text, run through a template which contains
24 // the standard formatting for notifications. 24 // the standard formatting for notifications.
25 static string16 CreateDataUrl(const GURL& icon_url, const string16& title, 25 static string16 CreateDataUrl(const GURL& icon_url, const string16& title,
26 const string16& body) { 26 const string16& body) {
27 const base::StringPiece template_html( 27 const base::StringPiece template_html(
(...skipping 24 matching lines...) Expand all
52 52
53 string16 format_string = ASCIIToUTF16("data:text/html;charset=utf-8," 53 string16 format_string = ASCIIToUTF16("data:text/html;charset=utf-8,"
54 + template_html.as_string()); 54 + template_html.as_string());
55 return ReplaceStringPlaceholders(format_string, subst, NULL); 55 return ReplaceStringPlaceholders(format_string, subst, NULL);
56 } 56 }
57 57
58 // This will call the notification manager on the UI thread to actually 58 // This will call the notification manager on the UI thread to actually
59 // put the notification with the requested parameters on the desktop. 59 // put the notification with the requested parameters on the desktop.
60 void DesktopNotificationService::ShowNotification( 60 void DesktopNotificationService::ShowNotification(
61 const Notification& notification) { 61 const Notification& notification) {
62 SiteInstance* site_instance = SiteInstance::CreateSiteInstance(profile_); 62 ui_manager_->Add(notification, profile_);
63 // TODO(johnnyg): When UI Manager is available, add from here.
64 // ui_manager_->Add(notification, profile_, site_instance);
65 } 63 }
66 64
67 // Shows a notification bubble which contains the contents of url. 65 // Shows a notification bubble which contains the contents of url.
68 bool DesktopNotificationService::ShowDesktopNotification( 66 bool DesktopNotificationService::ShowDesktopNotification(
69 const GURL& origin, const GURL& url, int process_id, int route_id, 67 const GURL& origin, const GURL& url, int process_id, int route_id,
70 NotificationSource source, int notification_id) { 68 NotificationSource source, int notification_id) {
71 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 69 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
72 NotificationObjectProxy* proxy = 70 NotificationObjectProxy* proxy =
73 new NotificationObjectProxy(process_id, route_id, 71 new NotificationObjectProxy(process_id, route_id,
74 notification_id, 72 notification_id,
(...skipping 12 matching lines...) Expand all
87 NotificationObjectProxy* proxy = 85 NotificationObjectProxy* proxy =
88 new NotificationObjectProxy(process_id, route_id, 86 new NotificationObjectProxy(process_id, route_id,
89 notification_id, 87 notification_id,
90 source == WorkerNotification); 88 source == WorkerNotification);
91 // "upconvert" the string parameters to a data: URL. 89 // "upconvert" the string parameters to a data: URL.
92 string16 data_url = CreateDataUrl(icon, title, text); 90 string16 data_url = CreateDataUrl(icon, title, text);
93 Notification notif(origin, GURL(data_url), proxy); 91 Notification notif(origin, GURL(data_url), proxy);
94 ShowNotification(notif); 92 ShowNotification(notif);
95 return true; 93 return true;
96 } 94 }
97
OLDNEW
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | chrome/browser/notifications/notification_ui_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698