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

Side by Side Diff: Source/modules/push_messaging/PushPermissionCallback.cpp

Issue 658723003: Blink implementation of PushManager#hasPermission() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "modules/push_messaging/PushPermissionCallback.h"
7
8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/DOMException.h"
10 #include "core/dom/ExceptionCode.h"
11 #include "wtf/text/WTFString.h"
12
Peter Beverloo 2014/10/20 12:23:49 nit: excess newline.
Miguel Garcia 2014/10/22 12:58:43 Acknowledged.
13
14 namespace blink {
15
16 PushPermissionCallback::PushPermissionCallback(PassRefPtr<ScriptPromiseResolver> script_resolver) :
Peter Beverloo 2014/10/20 12:23:49 nit: The colon needs to be on the next line.
Miguel Garcia 2014/10/22 12:58:43 Acknowledged.
17 m_resolver(script_resolver)
18 {
19 }
20
21 PushPermissionCallback::~PushPermissionCallback()
22 {
23 }
24
Peter Beverloo 2014/10/20 12:23:49 nit: excess newline.
Miguel Garcia 2014/10/22 12:58:43 Acknowledged.
25
26 /* static */ const String& PushPermissionCallback::permissionString(PushPermissi onStatus type)
Michael van Ouwerkerk 2014/10/20 11:25:42 We don't tend to comment on static in cpp files in
Peter Beverloo 2014/10/20 12:23:49 s/type/status/.
Miguel Garcia 2014/10/22 12:58:43 Done.
Miguel Garcia 2014/10/22 12:58:43 Done.
27 {
28 DEFINE_STATIC_LOCAL(const String, grantedPermission, ("granted"));
29 DEFINE_STATIC_LOCAL(const String, deniedPermission, ("denied"));
30 DEFINE_STATIC_LOCAL(const String, defaultPermission, ("default"));
31
32 switch (type) {
33 case PushPermissionStatus::PushPermissionGranted:
34 return grantedPermission;
35 case PushPermissionStatus::PushPermissionDenied:
36 return deniedPermission;
37 case PushPermissionStatus::PushPermissionDefault:
38 return defaultPermission;
39 }
40
41 ASSERT_NOT_REACHED();
42 return deniedPermission;
43 }
44
45 void PushPermissionCallback::onSuccess(PushPermissionStatus type)
Peter Beverloo 2014/10/20 12:23:49 s/type/status/.
Miguel Garcia 2014/10/22 12:58:43 Done.
46 {
47 m_resolver->resolve(permissionString(type));
48 }
49
50 void PushPermissionCallback::onError()
51 {
52 m_resolver->reject(DOMException::create(OperationError, "Could not check per mission"));
Michael van Ouwerkerk 2014/10/20 11:25:42 Again, this diverges from the spec so please open
Peter Beverloo 2014/10/20 12:23:49 I don't think having an OperationError saying "Cou
Miguel Garcia 2014/10/22 12:58:43 I will just reject here for now then. On 2014/10/
Miguel Garcia 2014/10/22 12:58:43 Acknowledged.
53 }
54
55 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698