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

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

Issue 6151011: Introduce RenderView::Observer interface so that RenderView doesn't have to k... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « chrome/renderer/geolocation_dispatcher.cc ('k') | chrome/renderer/notification_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_RENDERER_NOTIFICATION_PROVIDER_H_ 5 #ifndef CHROME_RENDERER_NOTIFICATION_PROVIDER_H_
6 #define CHROME_RENDERER_NOTIFICATION_PROVIDER_H_ 6 #define CHROME_RENDERER_NOTIFICATION_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/common/desktop_notifications/active_notification_tracker.h" 9 #include "chrome/common/desktop_notifications/active_notification_tracker.h"
10 #include "ipc/ipc_channel.h" 10 #include "chrome/renderer/render_view_observer.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebNotification.h" 11 #include "third_party/WebKit/WebKit/chromium/public/WebNotification.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h"
13 13
14 class RenderView;
15 namespace WebKit { 14 namespace WebKit {
16 class WebNotificationPermissionCallback; 15 class WebNotificationPermissionCallback;
17 } 16 }
18 17
19 // NotificationProvider class is owned by the RenderView. Only 18 // NotificationProvider class is owned by the RenderView. Only
20 // to be used on the UI thread. 19 // to be used on the main thread.
21 class NotificationProvider : public WebKit::WebNotificationPresenter, 20 class NotificationProvider : public RenderViewObserver,
22 public IPC::Channel::Listener { 21 public WebKit::WebNotificationPresenter {
23 public: 22 public:
24 explicit NotificationProvider(RenderView* view); 23 explicit NotificationProvider(RenderView* render_view);
25 virtual ~NotificationProvider(); 24 virtual ~NotificationProvider();
26 25
26 private:
27 // RenderView::Observer implementation.
28 bool OnMessageReceived(const IPC::Message& message);
29
27 // WebKit::WebNotificationPresenter interface. 30 // WebKit::WebNotificationPresenter interface.
28 virtual bool show(const WebKit::WebNotification& proxy); 31 virtual bool show(const WebKit::WebNotification& proxy);
29 virtual void cancel(const WebKit::WebNotification& proxy); 32 virtual void cancel(const WebKit::WebNotification& proxy);
30 virtual void objectDestroyed(const WebKit::WebNotification& proxy); 33 virtual void objectDestroyed(const WebKit::WebNotification& proxy);
31 virtual WebKit::WebNotificationPresenter::Permission checkPermission( 34 virtual WebKit::WebNotificationPresenter::Permission checkPermission(
32 const WebKit::WebURL& url); 35 const WebKit::WebURL& url);
33 virtual void requestPermission(const WebKit::WebSecurityOrigin& origin, 36 virtual void requestPermission(const WebKit::WebSecurityOrigin& origin,
34 WebKit::WebNotificationPermissionCallback* callback); 37 WebKit::WebNotificationPermissionCallback* callback);
35 38
36 // IPC::Channel::Listener implementation.
37 bool OnMessageReceived(const IPC::Message& message);
38
39 // Called when the RenderView navigates.
40 void OnNavigate();
41
42 private:
43 // Internal methods used to show notifications. 39 // Internal methods used to show notifications.
44 bool ShowHTML(const WebKit::WebNotification& notification, int id); 40 bool ShowHTML(const WebKit::WebNotification& notification, int id);
45 bool ShowText(const WebKit::WebNotification& notification, int id); 41 bool ShowText(const WebKit::WebNotification& notification, int id);
46 42
47 // IPC handlers. 43 // IPC handlers.
48 void OnDisplay(int id); 44 void OnDisplay(int id);
49 void OnError(int id, const WebKit::WebString& message); 45 void OnError(int id, const WebKit::WebString& message);
50 void OnClose(int id, bool by_user); 46 void OnClose(int id, bool by_user);
51 void OnClick(int id); 47 void OnClick(int id);
52 void OnPermissionRequestComplete(int id); 48 void OnPermissionRequestComplete(int id);
53 49 void OnNavigate();
54 bool Send(IPC::Message* message);
55
56 // Non-owned pointer to the RenderView object which created and owns
57 // this object.
58 RenderView* view_;
59 50
60 // A tracker object which manages the active notifications and the IDs 51 // A tracker object which manages the active notifications and the IDs
61 // that are used to refer to them over IPC. 52 // that are used to refer to them over IPC.
62 ActiveNotificationTracker manager_; 53 ActiveNotificationTracker manager_;
63 54
64 DISALLOW_COPY_AND_ASSIGN(NotificationProvider); 55 DISALLOW_COPY_AND_ASSIGN(NotificationProvider);
65 }; 56 };
66 57
67 #endif // CHROME_RENDERER_NOTIFICATION_PROVIDER_H_ 58 #endif // CHROME_RENDERER_NOTIFICATION_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/geolocation_dispatcher.cc ('k') | chrome/renderer/notification_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698