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

Unified Diff: content/renderer/installedapp/web_installed_app_impl.cc

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: content/renderer/installedapp/web_installed_app_impl.cc
diff --git a/content/renderer/installedapp/web_installed_app_impl.cc b/content/renderer/installedapp/web_installed_app_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b7a796fd419b9f2de996889b282e758ddc651c0d
--- /dev/null
+++ b/content/renderer/installedapp/web_installed_app_impl.cc
@@ -0,0 +1,114 @@
+// 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 "base/logging.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/renderer/render_thread_impl.h"
+#include "content/renderer/installedapp/web_installed_app_impl.h"
+
+namespace content {
+
+WebInstalledAppImpl::WebInstalledAppImpl() {}
+
+WebInstalledAppImpl::~WebInstalledAppImpl() {}
+
+void WebInstalledAppImpl::isAppInstalled(
+ const blink::WebString& asset1,
+ const blink::WebString& asset2,
+ const blink::WebString& origin,
+ blink::AppInstalledCallbacks* raw_callbacks) {
+ scoped_ptr<blink::AppInstalledCallbacks> callbacks(raw_callbacks);
+ LOG(WARNING) << asset1.utf8();
+ LOG(WARNING) << asset2.utf8();
+
+ GetProvider()->IsAppInstalled(
+ mojo::String(asset1.utf8()), mojo::String(asset2.utf8()),
+ mojo::String(origin.utf8()),
+ base::Bind(&WebInstalledAppImpl::OnIsAppInstalled, base::Unretained(this),
+ base::Passed(&callbacks)));
+}
+
+void WebInstalledAppImpl::isNativeAppInstalled(
+ const blink::WebInstalledAppVerificationManager& manager,
+ const blink::WebString& origin,
+ blink::AppInstalledCallbacks* raw_callbacks) {
+ scoped_ptr<blink::AppInstalledCallbacks> callbacks(raw_callbacks);
+ mojo::Map<mojo::String, mojo::Array<mojo::String>> validStrings;
+ // We can collate these into just an array of interesting string names.
+ // This will allow us to send a smaller Mojo map into Mojo.
+ blink::WebString packageName = manager.androidPackageName();
+ mojo::Array<mojo::String> androidPackageName;
+ androidPackageName.push_back(mojo::String(packageName.utf8()));
+ validStrings.insert(mojo::String("packageName"),
+ std::move(androidPackageName));
+
+ blink::WebVector<blink::WebString> signingKeyArray =
+ manager.androidSigningKeys();
+ mojo::Array<mojo::String> keys;
+ for (blink::WebVector<blink::WebString>::iterator it =
+ signingKeyArray.begin();
+ it != signingKeyArray.end(); ++it) {
+ keys.push_back(it->utf8());
+ LOG(WARNING) << it->utf8();
+ }
+ validStrings.insert(mojo::String("signingKey"), std::move(keys));
+ // // We need to make this able to handle the possibility of it being an
+ // array.
+ // if (manager.get("packageName", packageName)) {
+ // LOG(WARNING) << packageName.utf8();
+ // mojo::Array<mojo::String> keys;
+ // keys.push_back(mojo::String(packageName.utf8()));
+ // validStrings.insert(mojo::String("packageName"), std::move(keys));
+ // }
+ //
+ // blink::WebString signingKey;
+ // blink::WebVector<blink::WebString> signingKeyArray;
+ // if (manager.get("signingKey", signingKeyArray)) {
+ // LOG(WARNING) << "Found a signing key array.";
+ // mojo::Array<mojo::String> keys;
+ // for (blink::WebVector<blink::WebString>::iterator it =
+ // signingKeyArray.begin(); it != signingKeyArray.end(); ++it) {
+ // keys.push_back(it->utf8());
+ // LOG(WARNING) << it->utf8();
+ // }
+ // validStrings.insert(mojo::String("signingKey"), std::move(keys));
+ // }
+ // else if (manager.get("signingKey", signingKey)) {
+ // LOG(WARNING) << signingKey.utf8();
+ // mojo::Array<mojo::String> keys;
+ // keys.push_back(mojo::String(signingKey.utf8()));
+ // validStrings.insert(mojo::String("signingKey"), std::move(keys));
+ // }
+ //
+ // LOG(WARNING) << packageName.utf8();
+ // LOG(WARNING) << signingKey.utf8();
+
+ GetProvider()->IsNativeAppInstalled(
+ std::move(validStrings), mojo::String(origin.utf8()),
+ base::Bind(&WebInstalledAppImpl::OnIsNativeAppInstalled,
+ base::Unretained(this), base::Passed(&callbacks)));
+}
+
+components::InstalledAppProviderPtr& WebInstalledAppImpl::GetProvider() {
+ if (!provider_) {
+ RenderThread::Get()->GetServiceRegistry()->ConnectToRemoteService(
+ mojo::GetProxy(&provider_));
+ }
+ return provider_;
+}
+
+void WebInstalledAppImpl::OnIsAppInstalled(
+ scoped_ptr<blink::AppInstalledCallbacks> callbacks,
+ bool result) {
+ callbacks->onSuccess(result);
+}
+
+void WebInstalledAppImpl::OnIsNativeAppInstalled(
+ scoped_ptr<blink::AppInstalledCallbacks> callbacks,
+ bool result) {
+ LOG(WARNING) << "aww yeah";
+ callbacks->onSuccess(result);
+}
+
+} // namespace content
« no previous file with comments | « content/renderer/installedapp/web_installed_app_impl.h ('k') | content/renderer/renderer_blink_platform_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698