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

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

Issue 2671683002: getInstalledRelatedApps: Add browser-side Mojo service (stub). (Closed)
Patch Set: Remove m_frame and use supplementable(). Created 3 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/InstalledAppController.cpp
diff --git a/third_party/WebKit/Source/modules/installedapp/InstalledAppController.cpp b/third_party/WebKit/Source/modules/installedapp/InstalledAppController.cpp
index 66ac9ff72ff4fa788e2cbf77050c09d5d9e58cb8..3e7b235061bb01cb93b486e1b76c02e1ef166ca6 100644
--- a/third_party/WebKit/Source/modules/installedapp/InstalledAppController.cpp
+++ b/third_party/WebKit/Source/modules/installedapp/InstalledAppController.cpp
@@ -100,13 +100,49 @@ void InstalledAppController::contextDestroyed(ExecutionContext*) {
}
void InstalledAppController::filterByInstalledApps(
- WTF::RefPtr<SecurityOrigin> /*origin*/,
- const WebVector<WebRelatedApplication>& /*relatedApps*/,
- std::unique_ptr<AppInstalledCallbacks> callbacks) {
- // TODO(mgiuca): Call through to the browser to filter the list of
- // applications down to just those that are installed on the device.
- // For now, just return the empty list (no applications are installed).
- callbacks->onSuccess(WebVector<WebRelatedApplication>());
+ WTF::RefPtr<SecurityOrigin> origin,
+ const blink::WebVector<blink::WebRelatedApplication>& relatedApps,
+ std::unique_ptr<blink::AppInstalledCallbacks> callbacks) {
+ WTF::Vector<mojom::blink::RelatedApplicationPtr> mojoRelatedApps;
+ for (const auto& relatedApplication : relatedApps) {
+ mojom::blink::RelatedApplicationPtr convertedApplication(
+ mojom::blink::RelatedApplication::New());
+ DCHECK(!relatedApplication.platform.isEmpty());
+ convertedApplication->platform = relatedApplication.platform;
+ convertedApplication->id = relatedApplication.id;
+ convertedApplication->url = relatedApplication.url;
+ mojoRelatedApps.push_back(std::move(convertedApplication));
+ }
+
+ if (!m_provider) {
+ supplementable()->interfaceProvider()->getInterface(
+ mojo::MakeRequest(&m_provider));
dcheng 2017/03/02 07:41:51 We should close m_provider in contextDestroyed(),
Matt Giuca 2017/03/10 03:35:47 Done.
+ // TODO(mgiuca): Set a connection error handler. This requires a refactor to
+ // work like NavigatorShare.cpp (retain a persistent list of clients to
+ // reject all of their promises).
+ DCHECK(m_provider);
+ }
+
+ m_provider->FilterInstalledApps(
+ std::move(mojoRelatedApps), origin->toString(),
+ convertToBaseCallback(
+ WTF::bind(&InstalledAppController::OnFilterInstalledApps,
+ wrapPersistent(this), WTF::passed(std::move(callbacks)))));
dcheng 2017/03/02 07:41:51 Nit: WTF::passed(&callbacks)
Matt Giuca 2017/03/10 03:35:47 This doesn't work (no viable conversion from 'std:
+}
+
+void InstalledAppController::OnFilterInstalledApps(
+ std::unique_ptr<blink::AppInstalledCallbacks> callbacks,
+ WTF::Vector<mojom::blink::RelatedApplicationPtr> result) {
haraken 2017/03/02 07:33:28 dcheng@: Is there any way to type-map mojom::blink
dcheng 2017/03/02 07:41:51 Yeah, this should be pretty easy to typemap, and +
Matt Giuca 2017/03/10 03:35:47 This is all going to change... I'm planning to ref
dcheng 2017/03/13 06:16:51 Honestly, I'd prefer if the last step (mojom -> ID
Matt Giuca 2017/03/14 06:38:11 I'm happy to play with it after this feature is wo
dcheng 2017/03/14 06:41:53 I wouldn't really say 3 is not a high priority; ma
Matt Giuca 2017/03/14 06:53:57 Sure; but I'm going to prioritize it behind actual
+ std::vector<blink::WebRelatedApplication> applications;
+ for (const auto& res : result) {
+ blink::WebRelatedApplication app;
+ app.platform = res->platform;
+ app.url = res->url;
+ app.id = res->id;
+ applications.push_back(app);
+ }
+ callbacks->onSuccess(
+ blink::WebVector<blink::WebRelatedApplication>(applications));
}
DEFINE_TRACE(InstalledAppController) {

Powered by Google App Engine
This is Rietveld 408576698