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

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

Issue 267363008: Drop non-standard user gesture requirement from notification.requestPermission (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 6 years, 7 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/test/data/notifications/notifications_request_inline.html ('k') | no next file » | 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) 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"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 Send(new DesktopNotificationHostMsg_CheckPermission( 71 Send(new DesktopNotificationHostMsg_CheckPermission(
72 routing_id(), 72 routing_id(),
73 GURL(origin.toString()), 73 GURL(origin.toString()),
74 &permission)); 74 &permission));
75 return static_cast<WebNotificationPresenter::Permission>(permission); 75 return static_cast<WebNotificationPresenter::Permission>(permission);
76 } 76 }
77 77
78 void NotificationProvider::requestPermission( 78 void NotificationProvider::requestPermission(
79 const WebSecurityOrigin& origin, 79 const WebSecurityOrigin& origin,
80 WebNotificationPermissionCallback* callback) { 80 WebNotificationPermissionCallback* callback) {
81 // We only request permission in response to a user gesture.
82 if (!WebUserGestureIndicator::isProcessingUserGesture())
83 return;
84
85 int id = manager_.RegisterPermissionRequest(callback); 81 int id = manager_.RegisterPermissionRequest(callback);
86 82
87 Send(new DesktopNotificationHostMsg_RequestPermission( 83 Send(new DesktopNotificationHostMsg_RequestPermission(
88 routing_id(), GURL(origin.toString()), id)); 84 routing_id(), GURL(origin.toString()), id));
89 } 85 }
90 86
91 bool NotificationProvider::OnMessageReceived(const IPC::Message& message) { 87 bool NotificationProvider::OnMessageReceived(const IPC::Message& message) {
92 bool handled = true; 88 bool handled = true;
93 IPC_BEGIN_MESSAGE_MAP(NotificationProvider, message) 89 IPC_BEGIN_MESSAGE_MAP(NotificationProvider, message)
94 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostDisplay, OnDisplay); 90 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostDisplay, OnDisplay);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 DCHECK(callback); 145 DCHECK(callback);
150 callback->permissionRequestComplete(); 146 callback->permissionRequestComplete();
151 manager_.OnPermissionRequestComplete(id); 147 manager_.OnPermissionRequestComplete(id);
152 } 148 }
153 149
154 void NotificationProvider::OnNavigate() { 150 void NotificationProvider::OnNavigate() {
155 manager_.Clear(); 151 manager_.Clear();
156 } 152 }
157 153
158 } // namespace content 154 } // namespace content
OLDNEW
« no previous file with comments | « chrome/test/data/notifications/notifications_request_inline.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698