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