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

Side by Side Diff: content/renderer/notification_provider.cc

Issue 433433002: Remove code for the old Web Notification permission-path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 "content/renderer/notification_provider.h" 5 #include "content/renderer/notification_provider.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "content/common/desktop_notification_messages.h" 8 #include "content/common/desktop_notification_messages.h"
9 #include "content/common/frame_messages.h" 9 #include "content/common/frame_messages.h"
10 #include "content/renderer/render_frame_impl.h" 10 #include "content/renderer/render_frame_impl.h"
11 #include "third_party/WebKit/public/platform/WebURL.h" 11 #include "third_party/WebKit/public/platform/WebURL.h"
12 #include "third_party/WebKit/public/web/WebDocument.h" 12 #include "third_party/WebKit/public/web/WebDocument.h"
13 #include "third_party/WebKit/public/web/WebFrame.h" 13 #include "third_party/WebKit/public/web/WebFrame.h"
14 #include "third_party/WebKit/public/web/WebNotificationPermissionCallback.h"
15 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" 14 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
16 15
17 using blink::WebDocument; 16 using blink::WebDocument;
18 using blink::WebNotification; 17 using blink::WebNotification;
19 using blink::WebNotificationPresenter; 18 using blink::WebNotificationPresenter;
20 using blink::WebNotificationPermissionCallback;
21 using blink::WebSecurityOrigin; 19 using blink::WebSecurityOrigin;
22 using blink::WebString; 20 using blink::WebString;
23 using blink::WebURL; 21 using blink::WebURL;
24 using blink::WebUserGestureIndicator; 22 using blink::WebUserGestureIndicator;
25 23
26 namespace content { 24 namespace content {
27 25
28
29 NotificationProvider::NotificationProvider(RenderFrame* render_frame) 26 NotificationProvider::NotificationProvider(RenderFrame* render_frame)
30 : RenderFrameObserver(render_frame) { 27 : RenderFrameObserver(render_frame) {
31 } 28 }
32 29
33 NotificationProvider::~NotificationProvider() { 30 NotificationProvider::~NotificationProvider() {
34 } 31 }
35 32
36 bool NotificationProvider::show(const WebNotification& notification) { 33 bool NotificationProvider::show(const WebNotification& notification) {
37 WebDocument document = render_frame()->GetWebFrame()->document(); 34 WebDocument document = render_frame()->GetWebFrame()->document();
38 int notification_id = manager_.RegisterNotification(notification); 35 int notification_id = manager_.RegisterNotification(notification);
(...skipping 29 matching lines...) Expand all
68 WebNotificationPresenter::Permission NotificationProvider::checkPermission( 65 WebNotificationPresenter::Permission NotificationProvider::checkPermission(
69 const WebSecurityOrigin& origin) { 66 const WebSecurityOrigin& origin) {
70 int permission = WebNotificationPresenter::PermissionNotAllowed; 67 int permission = WebNotificationPresenter::PermissionNotAllowed;
71 Send(new DesktopNotificationHostMsg_CheckPermission( 68 Send(new DesktopNotificationHostMsg_CheckPermission(
72 routing_id(), 69 routing_id(),
73 GURL(origin.toString()), 70 GURL(origin.toString()),
74 &permission)); 71 &permission));
75 return static_cast<WebNotificationPresenter::Permission>(permission); 72 return static_cast<WebNotificationPresenter::Permission>(permission);
76 } 73 }
77 74
78 void NotificationProvider::requestPermission(
79 const WebSecurityOrigin& origin,
80 WebNotificationPermissionCallback* callback) {
81 int id = manager_.RegisterPermissionRequest(callback);
82
83 Send(new DesktopNotificationHostMsg_RequestPermission(
84 routing_id(), GURL(origin.toString()), id));
85 }
86
87 bool NotificationProvider::OnMessageReceived(const IPC::Message& message) { 75 bool NotificationProvider::OnMessageReceived(const IPC::Message& message) {
88 bool handled = true; 76 bool handled = true;
89 IPC_BEGIN_MESSAGE_MAP(NotificationProvider, message) 77 IPC_BEGIN_MESSAGE_MAP(NotificationProvider, message)
90 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostDisplay, OnDisplay); 78 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostDisplay, OnDisplay);
91 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostError, OnError); 79 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostError, OnError);
92 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClose, OnClose); 80 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClose, OnClose);
93 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClick, OnClick); 81 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClick, OnClick);
94 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PermissionRequestDone,
95 OnPermissionRequestComplete);
96 IPC_MESSAGE_UNHANDLED(handled = false) 82 IPC_MESSAGE_UNHANDLED(handled = false)
97 IPC_END_MESSAGE_MAP() 83 IPC_END_MESSAGE_MAP()
98 84
99 if (message.type() == FrameMsg_Navigate::ID) 85 if (message.type() == FrameMsg_Navigate::ID)
100 OnNavigate(); // Don't want to swallow the message. 86 OnNavigate(); // Don't want to swallow the message.
101 87
102 return handled; 88 return handled;
103 } 89 }
104 90
105 void NotificationProvider::OnDisplay(int id) { 91 void NotificationProvider::OnDisplay(int id) {
(...skipping 27 matching lines...) Expand all
133 119
134 void NotificationProvider::OnClick(int id) { 120 void NotificationProvider::OnClick(int id) {
135 WebNotification notification; 121 WebNotification notification;
136 bool found = manager_.GetNotification(id, &notification); 122 bool found = manager_.GetNotification(id, &notification);
137 // |found| may be false if the WebNotification went out of scope in 123 // |found| may be false if the WebNotification went out of scope in
138 // the page before the associated toast was clicked on. 124 // the page before the associated toast was clicked on.
139 if (found) 125 if (found)
140 notification.dispatchClickEvent(); 126 notification.dispatchClickEvent();
141 } 127 }
142 128
143 void NotificationProvider::OnPermissionRequestComplete(int id) {
144 WebNotificationPermissionCallback* callback = manager_.GetCallback(id);
145 DCHECK(callback);
146 callback->permissionRequestComplete();
147 manager_.OnPermissionRequestComplete(id);
148 }
149
150 void NotificationProvider::OnNavigate() { 129 void NotificationProvider::OnNavigate() {
151 manager_.Clear(); 130 manager_.Clear();
152 } 131 }
153 132
154 } // namespace content 133 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/notification_provider.h ('k') | content/shell/renderer/test_runner/notification_presenter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698