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

Side by Side Diff: chrome/renderer/notification_provider.h

Issue 194079: renderer process notifications support (Closed)
Patch Set: last change for code review Created 11 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
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_RENDERER_NOTIFICATION_PROVIDER_H_
6 #define CHROME_RENDERER_NOTIFICATION_PROVIDER_H_
7
8 #include <map>
9
10 #include "chrome/common/desktop_notifications/active_notification_tracker.h"
11 #include "ipc/ipc_channel.h"
12 #include "ipc/ipc_channel_proxy.h"
13 #include "webkit/api/public/WebNotification.h"
14 #include "webkit/api/public/WebNotificationPresenter.h"
15
16 class RenderView;
17 namespace WebKit {
18 class WebNotificationPermissionCallback;
19 }
20
21 class NotificationProvider : public WebKit::WebNotificationPresenter,
22 public IPC::ChannelProxy::MessageFilter {
23 public:
24 explicit NotificationProvider(RenderView* view);
25 ~NotificationProvider() {}
26
27 // WebKit::WebNotificationPresenter interface. Called from WebKit
28 // on the UI thread.
29 virtual bool show(const WebKit::WebNotification& proxy);
30 virtual void cancel(const WebKit::WebNotification& proxy);
31 virtual void objectDestroyed(const WebKit::WebNotification& proxy);
32 virtual WebKit::WebNotificationPresenter::Permission checkPermission(
33 const WebKit::WebString& origin);
34 virtual void requestPermission(const WebKit::WebString& origin,
35 WebKit::WebNotificationPermissionCallback* callback);
36
37 private:
38 // Internal methods used on the UI thread.
39 bool ShowHTML(const WebKit::WebNotification& notification, int id);
40 bool ShowText(const WebKit::WebNotification& notification, int id);
41
42 // Callback methods invoked when events happen on active notifications.
43 void OnDisplay(int id);
44 void OnError(int id, const WebKit::WebString& message);
45 void OnClose(int id, bool by_user);
46 void OnPermissionRequestComplete(int id);
47
48 // Internal versions of the IPC handlers which run on the UI thread.
49 void HandleOnDisplay(int id);
50 void HandleOnError(int id, const WebKit::WebString& message);
51 void HandleOnClose(int id, bool by_user);
52 void HandleOnPermissionRequestComplete(int id);
53
54 // IPC::ChannelProxy::MessageFilter override
55 virtual bool OnMessageReceived(const IPC::Message& message);
56
57 bool Send(IPC::Message* message);
58
59 // Non-owned pointer to the RenderView object which created and owns
60 // this object.
61 RenderView* view_;
62
63 // A tracker object which manages the active notifications and the IDs
64 // that are used to refer to them over IPC.
65 ActiveNotificationTracker manager_;
66
67 DISALLOW_COPY_AND_ASSIGN(NotificationProvider);
68 };
69
70 #endif // CHROME_RENDERER_NOTIFICATION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698