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

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: Fix the tests Created 6 years, 2 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = base::Bind(&CancelNotification, proxy->id()); 181 *cancel_callback = base::Bind(&CancelNotification, proxy->id());
177 182
178 DesktopNotificationProfileUtil::UsePermission(profile_, origin); 183 DesktopNotificationProfileUtil::UsePermission(profile_, origin);
179 } 184 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // Tell the IO thread that this extension's permission for notifications 351 // Tell the IO thread that this extension's permission for notifications
347 // has changed. 352 // has changed.
348 extensions::InfoMap* extension_info_map = 353 extensions::InfoMap* extension_info_map =
349 extensions::ExtensionSystem::Get(profile_)->info_map(); 354 extensions::ExtensionSystem::Get(profile_)->info_map();
350 BrowserThread::PostTask( 355 BrowserThread::PostTask(
351 BrowserThread::IO, FROM_HERE, 356 BrowserThread::IO, FROM_HERE,
352 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, 357 base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
353 extension_info_map, notifier_id.id, !enabled)); 358 extension_info_map, notifier_id.id, !enabled));
354 #endif 359 #endif
355 } 360 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698