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 #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 | |
| OLD | NEW |