Chromium Code Reviews| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 content::RenderFrameHost* render_frame_host, | 150 content::RenderFrameHost* render_frame_host, |
| 151 scoped_ptr<content::DesktopNotificationDelegate> delegate, | 151 scoped_ptr<content::DesktopNotificationDelegate> delegate, |
| 152 base::Closure* cancel_callback) { | 152 base::Closure* cancel_callback) { |
| 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 154 const GURL& origin = params.origin; | 154 const GURL& origin = params.origin; |
| 155 NotificationObjectProxy* proxy = | 155 NotificationObjectProxy* proxy = |
| 156 new NotificationObjectProxy(render_frame_host, delegate.Pass()); | 156 new NotificationObjectProxy(render_frame_host, delegate.Pass()); |
| 157 | 157 |
| 158 base::string16 display_source = DisplayNameForOriginInProcessId( | 158 base::string16 display_source = DisplayNameForOriginInProcessId( |
| 159 origin, render_frame_host->GetProcess()->GetID()); | 159 origin, render_frame_host->GetProcess()->GetID()); |
| 160 Notification notification(origin, params.icon_url, params.title, | 160 |
| 161 params.body, params.direction, display_source, params.replace_id, | 161 Notification notification(origin, |
| 162 proxy); | 162 gfx::Image::CreateFrom1xBitmap(params.icon), |
|
dewittj
2014/09/17 16:36:20
I think that today, this will work for 1x and 2x d
Jun Mukai
2014/09/17 16:57:47
Using CreateFrom1xBitmap is not bad by itself, it
Peter Beverloo
2014/09/18 16:54:37
I agree that it would be good for the Notification
| |
| 163 params.title, | |
| 164 params.body, | |
| 165 params.direction, | |
| 166 display_source, | |
| 167 params.replace_id, | |
| 168 proxy); | |
| 163 | 169 |
| 164 // The webkit notification doesn't timeout. | 170 // The webkit notification doesn't timeout. |
| 165 notification.set_never_timeout(true); | 171 notification.set_never_timeout(true); |
| 166 | 172 |
| 167 g_browser_process->notification_ui_manager()->Add(notification, profile_); | 173 g_browser_process->notification_ui_manager()->Add(notification, profile_); |
| 168 if (cancel_callback) | 174 if (cancel_callback) |
| 169 *cancel_callback = base::Bind(&CancelNotification, proxy->id()); | 175 *cancel_callback = base::Bind(&CancelNotification, proxy->id()); |
| 170 | 176 |
| 171 DesktopNotificationProfileUtil::UsePermission(profile_, origin); | 177 DesktopNotificationProfileUtil::UsePermission(profile_, origin); |
| 172 } | 178 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 // Tell the IO thread that this extension's permission for notifications | 341 // Tell the IO thread that this extension's permission for notifications |
| 336 // has changed. | 342 // has changed. |
| 337 extensions::InfoMap* extension_info_map = | 343 extensions::InfoMap* extension_info_map = |
| 338 extensions::ExtensionSystem::Get(profile_)->info_map(); | 344 extensions::ExtensionSystem::Get(profile_)->info_map(); |
| 339 BrowserThread::PostTask( | 345 BrowserThread::PostTask( |
| 340 BrowserThread::IO, FROM_HERE, | 346 BrowserThread::IO, FROM_HERE, |
| 341 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 347 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
| 342 extension_info_map, notifier_id.id, !enabled)); | 348 extension_info_map, notifier_id.id, !enabled)); |
| 343 #endif | 349 #endif |
| 344 } | 350 } |
| OLD | NEW |