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/installedapp/InstalledApp.h" |
| 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptState.h" |
| 11 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 12 #include "core/dom/DOMException.h" |
| 13 #include "core/dom/ExceptionCode.h" |
| 14 #include "public/platform/Platform.h" |
| 15 #include "public/platform/modules/installedapp/WebInstalledApp.h" |
| 16 #include "Source/modules/installedapp/InstalledAppVerificationManager.h" |
| 17 |
| 18 namespace blink { |
| 19 |
| 20 InstalledApp::InstalledApp() |
| 21 { |
| 22 } |
| 23 |
| 24 ScriptPromise InstalledApp::isAppInstalled(ScriptState* scriptState, const Strin
g& asset1, const String& asset2) |
| 25 { |
| 26 WebInstalledApp* webinstalledapp = Platform::current()->installedApp(); |
| 27 // TODO: Make a unittest to ensure that this actually occurs. |
| 28 if (!webinstalledapp) |
| 29 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(NotSupportedError)); |
| 30 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 31 ScriptPromise promise = resolver->promise(); |
| 32 |
| 33 webinstalledapp->isAppInstalled(asset1, asset2, |
| 34 scriptState->executionContext()->url().baseAsString(), |
| 35 new CallbackPromiseAdapter<bool, void>(resolver)); |
| 36 return promise; |
| 37 } |
| 38 |
| 39 ScriptPromise InstalledApp::isNativeAppInstalled(ScriptState* scriptState, const
Dictionary& key) |
| 40 { |
| 41 WebInstalledApp* webinstalledapp = Platform::current()->installedApp(); |
| 42 // TODO: Make a unittest to ensure that this actually occurs. |
| 43 if (!webinstalledapp) |
| 44 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(NotSupportedError)); |
| 45 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 46 ScriptPromise promise = resolver->promise(); |
| 47 |
| 48 webinstalledapp->isNativeAppInstalled(WebInstalledAppVerificationManager(key
), |
| 49 scriptState->executionContext()->url().baseAsString(), |
| 50 new CallbackPromiseAdapter<bool, void>(resolver)); |
| 51 return promise; |
| 52 } |
| 53 |
| 54 } // namespace blink |
OLD | NEW |