Index: third_party/WebKit/Source/modules/installedapp/InstalledApp.cpp |
diff --git a/third_party/WebKit/Source/modules/installedapp/InstalledApp.cpp b/third_party/WebKit/Source/modules/installedapp/InstalledApp.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..34085d1845de47bcb7e7141d708daec2a259c213 |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/installedapp/InstalledApp.cpp |
@@ -0,0 +1,54 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "modules/installedapp/InstalledApp.h" |
+ |
+#include "bindings/core/v8/CallbackPromiseAdapter.h" |
+#include "bindings/core/v8/ScriptPromise.h" |
+#include "bindings/core/v8/ScriptState.h" |
+#include "bindings/core/v8/ScriptPromiseResolver.h" |
+#include "core/dom/DOMException.h" |
+#include "core/dom/ExceptionCode.h" |
+#include "public/platform/Platform.h" |
+#include "public/platform/modules/installedapp/WebInstalledApp.h" |
+#include "Source/modules/installedapp/InstalledAppVerificationManager.h" |
+ |
+namespace blink { |
+ |
+InstalledApp::InstalledApp() |
+{ |
+} |
+ |
+ScriptPromise InstalledApp::isAppInstalled(ScriptState* scriptState, const String& asset1, const String& asset2) |
+{ |
+ WebInstalledApp* webinstalledapp = Platform::current()->installedApp(); |
+ // TODO: Make a unittest to ensure that this actually occurs. |
+ if (!webinstalledapp) |
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError)); |
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ |
+ webinstalledapp->isAppInstalled(asset1, asset2, |
+ scriptState->executionContext()->url().baseAsString(), |
+ new CallbackPromiseAdapter<bool, void>(resolver)); |
+ return promise; |
+} |
+ |
+ScriptPromise InstalledApp::isNativeAppInstalled(ScriptState* scriptState, const Dictionary& key) |
+{ |
+ WebInstalledApp* webinstalledapp = Platform::current()->installedApp(); |
+ // TODO: Make a unittest to ensure that this actually occurs. |
+ if (!webinstalledapp) |
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError)); |
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ |
+ webinstalledapp->isNativeAppInstalled(WebInstalledAppVerificationManager(key), |
+ scriptState->executionContext()->url().baseAsString(), |
+ new CallbackPromiseAdapter<bool, void>(resolver)); |
+ return promise; |
+} |
+ |
+} // namespace blink |