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

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

Issue 554213003: Request the icon of a Web Notification in the renderer process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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
OLDNEW
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
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): gfx::Image only provides an API to convert a SkBitmap to an
168 proxy); 168 // image using 1x scale. While the Views system will resize is for the
169 // appropriate resolution, doing so immediately should result in icons of
dewittj 2014/09/18 17:46:49 What do you mean immediately? Also gfx::Image doe
Peter Beverloo 2014/09/19 14:15:48 Ah, that's good to know, however, I don't think th
dewittj 2014/09/24 18:28:44 I don't think the "right format" is so simple, sin
170 // higher quality.
171 Notification notification(message_center::NOTIFICATION_TYPE_SIMPLE,
172 origin,
173 params.title,
174 params.body,
Mike West 2014/09/18 19:48:42 This is a huge signature. It looks like you're pa
Peter Beverloo 2014/09/19 14:15:48 We're trying to trim down the number of Notificati
175 gfx::Image::CreateFrom1xBitmap(params.icon),
176 blink::WebTextDirectionDefault,
177 message_center::NotifierId(origin),
178 display_source,
179 params.replace_id,
180 message_center::RichNotificationData(),
181 proxy);
169 182
170 // The webkit notification doesn't timeout. 183 // The webkit notification doesn't timeout.
171 notification.set_never_timeout(true); 184 notification.set_never_timeout(true);
172 185
173 g_browser_process->notification_ui_manager()->Add(notification, profile_); 186 g_browser_process->notification_ui_manager()->Add(notification, profile_);
174 if (cancel_callback) 187 if (cancel_callback)
175 *cancel_callback = base::Bind(&CancelNotification, proxy->id()); 188 *cancel_callback = base::Bind(&CancelNotification, proxy->id());
176 189
177 DesktopNotificationProfileUtil::UsePermission(profile_, origin); 190 DesktopNotificationProfileUtil::UsePermission(profile_, origin);
178 } 191 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // Tell the IO thread that this extension's permission for notifications 354 // Tell the IO thread that this extension's permission for notifications
342 // has changed. 355 // has changed.
343 extensions::InfoMap* extension_info_map = 356 extensions::InfoMap* extension_info_map =
344 extensions::ExtensionSystem::Get(profile_)->info_map(); 357 extensions::ExtensionSystem::Get(profile_)->info_map();
345 BrowserThread::PostTask( 358 BrowserThread::PostTask(
346 BrowserThread::IO, FROM_HERE, 359 BrowserThread::IO, FROM_HERE,
347 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, 360 base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
348 extension_info_map, notifier_id.id, !enabled)); 361 extension_info_map, notifier_id.id, !enabled));
349 #endif 362 #endif
350 } 363 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698