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

Side by Side Diff: chrome/browser/desktop_notification_handler.cc

Issue 6803012: Profile shouldn't own DesktopNotificationService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/desktop_notification_handler.h" 5 #include "chrome/browser/desktop_notification_handler.h"
6 6
7 #include "chrome/browser/notifications/desktop_notification_service.h" 7 #include "chrome/browser/notifications/desktop_notification_service.h"
8 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
8 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
9 #include "content/browser/renderer_host/render_process_host.h" 10 #include "content/browser/renderer_host/render_process_host.h"
10 #include "content/browser/renderer_host/render_view_host.h" 11 #include "content/browser/renderer_host/render_view_host.h"
11 #include "content/browser/renderer_host/render_view_host_delegate.h" 12 #include "content/browser/renderer_host/render_view_host_delegate.h"
12 #include "content/common/desktop_notification_messages.h" 13 #include "content/common/desktop_notification_messages.h"
13 14
14 DesktopNotificationHandler::DesktopNotificationHandler( 15 DesktopNotificationHandler::DesktopNotificationHandler(
15 RenderViewHost* render_view_host) 16 RenderViewHost* render_view_host)
16 : RenderViewHostObserver(render_view_host) { 17 : RenderViewHostObserver(render_view_host) {
17 } 18 }
(...skipping 13 matching lines...) Expand all
31 IPC_MESSAGE_UNHANDLED(handled = false) 32 IPC_MESSAGE_UNHANDLED(handled = false)
32 IPC_END_MESSAGE_MAP() 33 IPC_END_MESSAGE_MAP()
33 34
34 return handled; 35 return handled;
35 } 36 }
36 37
37 void DesktopNotificationHandler::OnShow( 38 void DesktopNotificationHandler::OnShow(
38 const DesktopNotificationHostMsg_Show_Params& params) { 39 const DesktopNotificationHostMsg_Show_Params& params) {
39 RenderProcessHost* process = render_view_host()->process(); 40 RenderProcessHost* process = render_view_host()->process();
40 DesktopNotificationService* service = 41 DesktopNotificationService* service =
41 process->profile()->GetDesktopNotificationService(); 42 DesktopNotificationServiceFactory::GetForProfile(process->profile());
42 43
43 service->ShowDesktopNotification( 44 service->ShowDesktopNotification(
44 params, 45 params,
45 process->id(), 46 process->id(),
46 routing_id(), 47 routing_id(),
47 DesktopNotificationService::PageNotification); 48 DesktopNotificationService::PageNotification);
48 } 49 }
49 50
50 void DesktopNotificationHandler::OnCancel(int notification_id) { 51 void DesktopNotificationHandler::OnCancel(int notification_id) {
51 RenderProcessHost* process = render_view_host()->process(); 52 RenderProcessHost* process = render_view_host()->process();
52 DesktopNotificationService* service = 53 DesktopNotificationService* service =
53 process->profile()->GetDesktopNotificationService(); 54 DesktopNotificationServiceFactory::GetForProfile(process->profile());
54 55
55 service->CancelDesktopNotification( 56 service->CancelDesktopNotification(
56 process->id(), 57 process->id(),
57 routing_id(), 58 routing_id(),
58 notification_id); 59 notification_id);
59 } 60 }
60 61
61 void DesktopNotificationHandler::OnRequestPermission( 62 void DesktopNotificationHandler::OnRequestPermission(
62 const GURL& source_origin, int callback_context) { 63 const GURL& source_origin, int callback_context) {
63 if (render_view_host()->delegate()->RequestDesktopNotificationPermission( 64 if (render_view_host()->delegate()->RequestDesktopNotificationPermission(
64 source_origin, callback_context)) { 65 source_origin, callback_context)) {
65 return; 66 return;
66 } 67 }
67 68
68 RenderProcessHost* process = render_view_host()->process(); 69 RenderProcessHost* process = render_view_host()->process();
69 DesktopNotificationService* service = 70 DesktopNotificationService* service =
70 process->profile()->GetDesktopNotificationService(); 71 DesktopNotificationServiceFactory::GetForProfile(process->profile());
71 service->RequestPermission( 72 service->RequestPermission(
72 source_origin, process->id(), routing_id(), callback_context, NULL); 73 source_origin, process->id(), routing_id(), callback_context, NULL);
73 } 74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698