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

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

Issue 433273002: NotificationObjectProxy should own the DesktopNotificationDelegateImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pass as scoped_ptr Created 6 years, 4 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 | Annotate | Revision Log
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"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/content_settings/content_settings_details.h" 14 #include "chrome/browser/content_settings/content_settings_details.h"
15 #include "chrome/browser/content_settings/content_settings_provider.h" 15 #include "chrome/browser/content_settings/content_settings_provider.h"
16 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 16 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
17 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 17 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
18 #include "chrome/browser/notifications/notification.h" 18 #include "chrome/browser/notifications/notification.h"
19 #include "chrome/browser/notifications/notification_object_proxy.h" 19 #include "chrome/browser/notifications/notification_object_proxy.h"
20 #include "chrome/browser/notifications/notification_ui_manager.h" 20 #include "chrome/browser/notifications/notification_ui_manager.h"
21 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" 21 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
22 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac tory.h" 22 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac tory.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
27 #include "components/pref_registry/pref_registry_syncable.h" 27 #include "components/pref_registry/pref_registry_syncable.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/desktop_notification_delegate.h"
29 #include "content/public/browser/notification_service.h" 30 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/render_frame_host.h" 31 #include "content/public/browser/render_frame_host.h"
31 #include "content/public/browser/render_process_host.h" 32 #include "content/public/browser/render_process_host.h"
32 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
33 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
34 #include "content/public/common/show_desktop_notification_params.h" 35 #include "content/public/common/show_desktop_notification_params.h"
35 #include "grit/browser_resources.h" 36 #include "grit/browser_resources.h"
36 #include "grit/chromium_strings.h" 37 #include "grit/chromium_strings.h"
37 #include "grit/generated_resources.h" 38 #include "grit/generated_resources.h"
38 #include "grit/theme_resources.h" 39 #include "grit/theme_resources.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 requesting_frame, 206 requesting_frame,
206 user_gesture, 207 user_gesture,
207 base::Bind(&DesktopNotificationService::OnNotificationPermissionRequested, 208 base::Bind(&DesktopNotificationService::OnNotificationPermissionRequested,
208 weak_factory_.GetWeakPtr(), 209 weak_factory_.GetWeakPtr(),
209 callback)); 210 callback));
210 } 211 }
211 212
212 void DesktopNotificationService::ShowDesktopNotification( 213 void DesktopNotificationService::ShowDesktopNotification(
213 const content::ShowDesktopNotificationHostMsgParams& params, 214 const content::ShowDesktopNotificationHostMsgParams& params,
214 content::RenderFrameHost* render_frame_host, 215 content::RenderFrameHost* render_frame_host,
215 content::DesktopNotificationDelegate* delegate, 216 scoped_ptr<content::DesktopNotificationDelegate> delegate,
216 base::Closure* cancel_callback) { 217 base::Closure* cancel_callback) {
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
218 const GURL& origin = params.origin; 219 const GURL& origin = params.origin;
219 NotificationObjectProxy* proxy = 220 NotificationObjectProxy* proxy =
220 new NotificationObjectProxy(render_frame_host, delegate); 221 new NotificationObjectProxy(render_frame_host, delegate.Pass());
221 222
222 base::string16 display_source = DisplayNameForOriginInProcessId( 223 base::string16 display_source = DisplayNameForOriginInProcessId(
223 origin, render_frame_host->GetProcess()->GetID()); 224 origin, render_frame_host->GetProcess()->GetID());
224 Notification notification(origin, params.icon_url, params.title, 225 Notification notification(origin, params.icon_url, params.title,
225 params.body, params.direction, display_source, params.replace_id, 226 params.body, params.direction, display_source, params.replace_id,
226 proxy); 227 proxy);
227 228
228 // The webkit notification doesn't timeout. 229 // The webkit notification doesn't timeout.
229 notification.set_never_timeout(true); 230 notification.set_never_timeout(true);
230 231
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // Tell the IO thread that this extension's permission for notifications 408 // Tell the IO thread that this extension's permission for notifications
408 // has changed. 409 // has changed.
409 extensions::InfoMap* extension_info_map = 410 extensions::InfoMap* extension_info_map =
410 extensions::ExtensionSystem::Get(profile_)->info_map(); 411 extensions::ExtensionSystem::Get(profile_)->info_map();
411 BrowserThread::PostTask( 412 BrowserThread::PostTask(
412 BrowserThread::IO, FROM_HERE, 413 BrowserThread::IO, FROM_HERE,
413 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, 414 base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
414 extension_info_map, notifier_id.id, !enabled)); 415 extension_info_map, notifier_id.id, !enabled));
415 #endif 416 #endif
416 } 417 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | chrome/browser/notifications/notification_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698