OLD | NEW |
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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 content::RenderFrameHost* render_frame_host, | 156 content::RenderFrameHost* render_frame_host, |
157 scoped_ptr<content::DesktopNotificationDelegate> delegate, | 157 scoped_ptr<content::DesktopNotificationDelegate> delegate, |
158 base::Closure* cancel_callback) { | 158 base::Closure* cancel_callback) { |
159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
160 const GURL& origin = params.origin; | 160 const GURL& origin = params.origin; |
161 NotificationObjectProxy* proxy = | 161 NotificationObjectProxy* proxy = |
162 new NotificationObjectProxy(render_frame_host, delegate.Pass()); | 162 new NotificationObjectProxy(render_frame_host, delegate.Pass()); |
163 | 163 |
164 base::string16 display_source = DisplayNameForOriginInProcessId( | 164 base::string16 display_source = DisplayNameForOriginInProcessId( |
165 origin, render_frame_host->GetProcess()->GetID()); | 165 origin, render_frame_host->GetProcess()->GetID()); |
166 Notification notification(origin, params.icon_url, params.title, | 166 |
167 params.body, params.direction, display_source, params.replace_id, | 167 // TODO(peter): Icons for Web Notifications are currently always requested for |
168 proxy); | 168 // 1x scale, whereas the displays on which they can be displayed can have a |
| 169 // different pixel density. Be smarter about this when the API gets updated |
| 170 // with a way for developers to specify images of different resolutions. |
| 171 Notification notification(origin, params.title, params.body, |
| 172 gfx::Image::CreateFrom1xBitmap(params.icon), |
| 173 display_source, params.replace_id, proxy); |
169 | 174 |
170 // The webkit notification doesn't timeout. | 175 // The webkit notification doesn't timeout. |
171 notification.set_never_timeout(true); | 176 notification.set_never_timeout(true); |
172 | 177 |
173 g_browser_process->notification_ui_manager()->Add(notification, profile_); | 178 g_browser_process->notification_ui_manager()->Add(notification, profile_); |
174 if (cancel_callback) | 179 if (cancel_callback) |
175 *cancel_callback = base::Bind(&CancelNotification, proxy->id()); | 180 *cancel_callback = base::Bind(&CancelNotification, proxy->id()); |
176 | 181 |
177 DesktopNotificationProfileUtil::UsePermission(profile_, origin); | 182 DesktopNotificationProfileUtil::UsePermission(profile_, origin); |
178 } | 183 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // Tell the IO thread that this extension's permission for notifications | 346 // Tell the IO thread that this extension's permission for notifications |
342 // has changed. | 347 // has changed. |
343 extensions::InfoMap* extension_info_map = | 348 extensions::InfoMap* extension_info_map = |
344 extensions::ExtensionSystem::Get(profile_)->info_map(); | 349 extensions::ExtensionSystem::Get(profile_)->info_map(); |
345 BrowserThread::PostTask( | 350 BrowserThread::PostTask( |
346 BrowserThread::IO, FROM_HERE, | 351 BrowserThread::IO, FROM_HERE, |
347 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 352 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
348 extension_info_map, notifier_id.id, !enabled)); | 353 extension_info_map, notifier_id.id, !enabled)); |
349 #endif | 354 #endif |
350 } | 355 } |
OLD | NEW |