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

Unified Diff: third_party/WebKit/Source/modules/installedapp/InstalledApp.cpp

Issue 1586563009: IsNativeAppInstalled Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698