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

Side by Side Diff: content/child/push_messaging/push_provider.cc

Issue 1133083002: Reject the permissionState promise with NotSupported Exception (2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix failing test Created 5 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
« no previous file with comments | « content/child/push_messaging/push_provider.h ('k') | content/common/push_messaging_messages.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/child/push_messaging/push_provider.h" 5 #include "content/child/push_messaging/push_provider.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 blink::WebPushPermissionStatusCallbacks* callbacks = 244 blink::WebPushPermissionStatusCallbacks* callbacks =
245 permission_status_callbacks_.Lookup(request_id); 245 permission_status_callbacks_.Lookup(request_id);
246 if (!callbacks) 246 if (!callbacks)
247 return; 247 return;
248 248
249 callbacks->onSuccess(&status); 249 callbacks->onSuccess(&status);
250 250
251 permission_status_callbacks_.Remove(request_id); 251 permission_status_callbacks_.Remove(request_id);
252 } 252 }
253 253
254 void PushProvider::OnGetPermissionStatusError(int request_id) { 254 void PushProvider::OnGetPermissionStatusError(
255 int request_id,
256 blink::WebPushError::ErrorType error) {
255 blink::WebPushPermissionStatusCallbacks* callbacks = 257 blink::WebPushPermissionStatusCallbacks* callbacks =
256 permission_status_callbacks_.Lookup(request_id); 258 permission_status_callbacks_.Lookup(request_id);
257 if (!callbacks) 259 if (!callbacks)
258 return; 260 return;
259 261
260 callbacks->onError(); 262 std::string error_message;
263 if (error == blink::WebPushError::ErrorTypeNotSupported) {
264 error_message =
265 "Push subscriptions that don't enable userVisibleOnly are not "
266 "supported.";
267 }
268
269 scoped_ptr<blink::WebPushError> web_error(new blink::WebPushError(
270 error, blink::WebString::fromUTF8(error_message)));
271
272 callbacks->onError(web_error.release());
Avi (use Gerrit) 2015/05/13 15:44:31 This bothers me because the definition of onError
261 273
262 permission_status_callbacks_.Remove(request_id); 274 permission_status_callbacks_.Remove(request_id);
263 } 275 }
264 276
265 } // namespace content 277 } // namespace content
OLDNEW
« no previous file with comments | « content/child/push_messaging/push_provider.h ('k') | content/common/push_messaging_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698