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

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

Issue 794633002: Remove ShowDesktopNotificationHostMsgParams in favor of PlatformNotificationData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 6 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/platform_notification_service_impl.h" 5 #include "chrome/browser/notifications/platform_notification_service_impl.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/notifications/notification.h" 9 #include "chrome/browser/notifications/notification.h"
10 #include "chrome/browser/notifications/notification_object_proxy.h" 10 #include "chrome/browser/notifications/notification_object_proxy.h"
11 #include "chrome/browser/notifications/notification_ui_manager.h" 11 #include "chrome/browser/notifications/notification_ui_manager.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_io_data.h" 13 #include "chrome/browser/profiles/profile_io_data.h"
14 #include "components/content_settings/core/browser/host_content_settings_map.h" 14 #include "components/content_settings/core/browser/host_content_settings_map.h"
15 #include "components/content_settings/core/common/content_settings.h" 15 #include "components/content_settings/core/common/content_settings.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/desktop_notification_delegate.h" 17 #include "content/public/browser/desktop_notification_delegate.h"
18 #include "content/public/common/show_desktop_notification_params.h" 18 #include "content/public/common/platform_notification_data.h"
19 #include "ui/message_center/notifier_settings.h" 19 #include "ui/message_center/notifier_settings.h"
20 20
21 #if defined(ENABLE_EXTENSIONS) 21 #if defined(ENABLE_EXTENSIONS)
22 #include "chrome/browser/notifications/desktop_notification_service.h" 22 #include "chrome/browser/notifications/desktop_notification_service.h"
23 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 23 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
24 #include "extensions/browser/extension_system.h" 24 #include "extensions/browser/extension_system.h"
25 #include "extensions/browser/info_map.h" 25 #include "extensions/browser/info_map.h"
26 #include "extensions/common/constants.h" 26 #include "extensions/common/constants.h"
27 #include "extensions/common/extension_set.h" 27 #include "extensions/common/extension_set.h"
28 #include "extensions/common/permissions/api_permission.h" 28 #include "extensions/common/permissions/api_permission.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 if (setting == CONTENT_SETTING_ALLOW) 89 if (setting == CONTENT_SETTING_ALLOW)
90 return blink::WebNotificationPermissionAllowed; 90 return blink::WebNotificationPermissionAllowed;
91 if (setting == CONTENT_SETTING_BLOCK) 91 if (setting == CONTENT_SETTING_BLOCK)
92 return blink::WebNotificationPermissionDenied; 92 return blink::WebNotificationPermissionDenied;
93 93
94 return blink::WebNotificationPermissionDefault; 94 return blink::WebNotificationPermissionDefault;
95 } 95 }
96 96
97 void PlatformNotificationServiceImpl::DisplayNotification( 97 void PlatformNotificationServiceImpl::DisplayNotification(
98 content::BrowserContext* browser_context, 98 content::BrowserContext* browser_context,
99 const content::ShowDesktopNotificationHostMsgParams& params, 99 const GURL& origin,
100 const SkBitmap& icon,
101 const content::PlatformNotificationData& notification_data,
100 scoped_ptr<content::DesktopNotificationDelegate> delegate, 102 scoped_ptr<content::DesktopNotificationDelegate> delegate,
101 int render_process_id, 103 int render_process_id,
102 base::Closure* cancel_callback) { 104 base::Closure* cancel_callback) {
103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
104 106
105 Profile* profile = Profile::FromBrowserContext(browser_context); 107 Profile* profile = Profile::FromBrowserContext(browser_context);
106 DCHECK(profile); 108 DCHECK(profile);
107 109
108 NotificationObjectProxy* proxy = new NotificationObjectProxy(delegate.Pass()); 110 NotificationObjectProxy* proxy = new NotificationObjectProxy(delegate.Pass());
109 base::string16 display_source = DisplayNameForOriginInProcessId( 111 base::string16 display_source = DisplayNameForOriginInProcessId(
110 profile, params.origin, render_process_id); 112 profile, origin, render_process_id);
111 113
112 // TODO(peter): Icons for Web Notifications are currently always requested for 114 // TODO(peter): Icons for Web Notifications are currently always requested for
113 // 1x scale, whereas the displays on which they can be displayed can have a 115 // 1x scale, whereas the displays on which they can be displayed can have a
114 // different pixel density. Be smarter about this when the API gets updated 116 // different pixel density. Be smarter about this when the API gets updated
115 // with a way for developers to specify images of different resolutions. 117 // with a way for developers to specify images of different resolutions.
116 Notification notification(params.origin, params.title, params.body, 118 Notification notification(origin, notification_data.title,
117 gfx::Image::CreateFrom1xBitmap(params.icon), 119 notification_data.body, gfx::Image::CreateFrom1xBitmap(icon),
118 display_source, params.replace_id, proxy); 120 display_source, notification_data.tag, proxy);
119 121
120 // Web Notifications do not timeout. 122 // Web Notifications do not timeout.
121 notification.set_never_timeout(true); 123 notification.set_never_timeout(true);
122 124
123 GetNotificationUIManager()->Add(notification, profile); 125 GetNotificationUIManager()->Add(notification, profile);
124 if (cancel_callback) 126 if (cancel_callback)
125 *cancel_callback = 127 *cancel_callback =
126 base::Bind(&CancelNotification, 128 base::Bind(&CancelNotification,
127 proxy->id(), 129 proxy->id(),
128 NotificationUIManager::GetProfileID(profile)); 130 NotificationUIManager::GetProfileID(profile));
129 131
130 profile->GetHostContentSettingsMap()->UpdateLastUsage( 132 profile->GetHostContentSettingsMap()->UpdateLastUsage(
131 params.origin, params.origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 133 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
132 } 134 }
133 135
134 void PlatformNotificationServiceImpl::DisplayPersistentNotification( 136 void PlatformNotificationServiceImpl::DisplayPersistentNotification(
135 content::BrowserContext* browser_context, 137 content::BrowserContext* browser_context,
136 int64 service_worker_registration_id, 138 int64 service_worker_registration_id,
137 const content::ShowDesktopNotificationHostMsgParams& params, 139 const GURL& origin,
140 const SkBitmap& icon,
141 const content::PlatformNotificationData& notification_data,
138 int render_process_id) { 142 int render_process_id) {
139 NOTIMPLEMENTED(); 143 NOTIMPLEMENTED();
140 } 144 }
141 145
142 void PlatformNotificationServiceImpl::ClosePersistentNotification( 146 void PlatformNotificationServiceImpl::ClosePersistentNotification(
143 content::BrowserContext* browser_context, 147 content::BrowserContext* browser_context,
144 const std::string& persistent_notification_id) { 148 const std::string& persistent_notification_id) {
145 NOTIMPLEMENTED(); 149 NOTIMPLEMENTED();
146 } 150 }
147 151
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); 184 NotifierId notifier_id(NotifierId::APPLICATION, extension->id());
181 if (desktop_notification_service->IsNotifierEnabled(notifier_id)) 185 if (desktop_notification_service->IsNotifierEnabled(notifier_id))
182 return base::UTF8ToUTF16(extension->name()); 186 return base::UTF8ToUTF16(extension->name());
183 } 187 }
184 } 188 }
185 } 189 }
186 #endif 190 #endif
187 191
188 return base::UTF8ToUTF16(origin.host()); 192 return base::UTF8ToUTF16(origin.host());
189 } 193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698