OLD | NEW |
---|---|
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 blink::WebPushPermissionStatusCallbacks* callbacks = | 272 blink::WebPushPermissionStatusCallbacks* callbacks = |
273 permission_status_callbacks_.Lookup(request_id); | 273 permission_status_callbacks_.Lookup(request_id); |
274 if (!callbacks) | 274 if (!callbacks) |
275 return; | 275 return; |
276 | 276 |
277 callbacks->onSuccess(&status); | 277 callbacks->onSuccess(&status); |
278 | 278 |
279 permission_status_callbacks_.Remove(request_id); | 279 permission_status_callbacks_.Remove(request_id); |
280 } | 280 } |
281 | 281 |
282 void PushProvider::OnGetPermissionStatusError(int request_id) { | 282 void PushProvider::OnGetPermissionStatusError( |
283 int request_id, | |
284 blink::WebPushError::ErrorType error) { | |
283 blink::WebPushPermissionStatusCallbacks* callbacks = | 285 blink::WebPushPermissionStatusCallbacks* callbacks = |
284 permission_status_callbacks_.Lookup(request_id); | 286 permission_status_callbacks_.Lookup(request_id); |
285 if (!callbacks) | 287 if (!callbacks) |
286 return; | 288 return; |
287 | 289 |
288 callbacks->onError(); | 290 std::string error_message; |
291 if (error == blink::WebPushError::ErrorTypeNotSupported) { | |
292 error_message = | |
293 "push subscriptions that don't enable userVisibleOnly are not " | |
294 "supported."; | |
Peter Beverloo
2015/05/11 12:56:07
Capitalization - it's a sentence.
Miguel Garcia
2015/05/11 13:50:38
Done.
| |
295 } else { | |
296 error_message = ""; | |
Peter Beverloo
2015/05/11 12:56:07
No need to set it to an empty string - the constru
Miguel Garcia
2015/05/11 13:50:38
Done.
| |
297 } | |
298 | |
299 scoped_ptr<blink::WebPushError> web_error(new blink::WebPushError( | |
300 error, blink::WebString::fromUTF8(error_message))); | |
301 | |
302 callbacks->onError(web_error.release()); | |
289 | 303 |
290 permission_status_callbacks_.Remove(request_id); | 304 permission_status_callbacks_.Remove(request_id); |
291 } | 305 } |
292 | 306 |
293 } // namespace content | 307 } // namespace content |
OLD | NEW |