Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
|
mlamouri (slow - plz ping)
2014/10/17 09:22:01
nit: no new line between "config.h" and the header
Miguel Garcia
2014/10/20 09:58:10
Done.
| |
| 7 #include "modules/push_messaging/PushPermissionCallback.h" | |
| 8 | |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
| 10 #include "core/dom/DOMException.h" | |
| 11 #include "core/dom/ExceptionCode.h" | |
| 12 #include "wtf/text/WTFString.h" | |
| 13 | |
| 14 | |
| 15 namespace blink { | |
| 16 | |
| 17 PushPermissionCallback::PushPermissionCallback(PassRefPtr<ScriptPromiseResolver> script_resolver) : | |
| 18 m_resolver(script_resolver) | |
| 19 { | |
| 20 } | |
| 21 | |
| 22 PushPermissionCallback::~PushPermissionCallback() | |
| 23 { | |
| 24 } | |
| 25 | |
| 26 | |
| 27 /* static */ const String& PushPermissionCallback::permissionString(PushPermissi onStatus type) | |
| 28 { | |
| 29 DEFINE_STATIC_LOCAL(const String, grantedPermission, ("granted")); | |
| 30 DEFINE_STATIC_LOCAL(const String, deniedPermission, ("denied")); | |
| 31 DEFINE_STATIC_LOCAL(const String, defaultPermission, ("default")); | |
|
mlamouri (slow - plz ping)
2014/10/17 09:22:01
I think "default" is an unfortunate name :(
Miguel Garcia
2014/10/20 09:58:10
not much I can do here talk to Michael, he is a sp
| |
| 32 | |
| 33 switch (type) { | |
| 34 case PushPermissionStatus::PushPermissionGranted: | |
| 35 return grantedPermission; | |
| 36 case PushPermissionStatus::PushPermissionDenied: | |
| 37 return deniedPermission; | |
| 38 case PushPermissionStatus::PushPermissionDefault: | |
| 39 return defaultPermission; | |
| 40 } | |
| 41 | |
| 42 ASSERT_NOT_REACHED(); | |
| 43 return deniedPermission; | |
| 44 } | |
| 45 | |
| 46 void PushPermissionCallback::onSuccess(PushPermissionStatus type) | |
| 47 { | |
| 48 m_resolver->resolve(permissionString(type)); | |
|
mlamouri (slow - plz ping)
2014/10/17 09:22:01
Actually, do you really need permissionString() to
Miguel Garcia
2014/10/20 09:58:10
It seems nicer but this is just a matter of tase (
| |
| 49 } | |
| 50 | |
| 51 void PushPermissionCallback::onError() | |
| 52 { | |
| 53 m_resolver->reject(DOMException::create(SecurityError, "Could not check perm ission")); | |
|
mlamouri (slow - plz ping)
2014/10/17 09:22:01
I would not use SecurityError because this isn't a
Miguel Garcia
2014/10/20 09:58:10
OperationError ?
| |
| 54 } | |
| 55 | |
| 56 } // namespace blink | |
| OLD | NEW |