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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/installedapp/InstalledAppProviderFactory.java

Issue 2706403014: Add Android implementation of navigator.getInstalledRelatedApps. (Closed)
Patch Set: Fixed iframes (now has the correct origin of the frame, not the tab). Created 3 years, 9 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/public/android/java/src/org/chromium/content/browser/installedapp/InstalledAppProviderFactory.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/installedapp/InstalledAppProviderFactory.java b/content/public/android/java/src/org/chromium/content/browser/installedapp/InstalledAppProviderFactory.java
new file mode 100644
index 0000000000000000000000000000000000000000..751b3e39036ec27ec3967f6661ee37fcc09b5173
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/installedapp/InstalledAppProviderFactory.java
@@ -0,0 +1,33 @@
+// Copyright 2017 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.
+
+package org.chromium.content.browser.installedapp;
+
+import org.chromium.content.browser.ContentViewCore;
+import org.chromium.content_public.browser.RenderFrameHost;
+import org.chromium.content_public.browser.WebContentsStatics;
+import org.chromium.installedapp.mojom.InstalledAppProvider;
+import org.chromium.services.service_manager.InterfaceFactory;
+
+/** Factory to create instances of the InstalledAppProvider Mojo service. */
+public class InstalledAppProviderFactory implements InterfaceFactory<InstalledAppProvider> {
+ private final RenderFrameHost mRenderFrameHost;
+
+ public InstalledAppProviderFactory(RenderFrameHost renderFrameHost) {
+ mRenderFrameHost = renderFrameHost;
+ }
+
+ @Override
+ public InstalledAppProvider createImpl() {
+ // Get Android application context from web contents.
+ ContentViewCore contentViewCore = ContentViewCore.fromWebContents(
+ WebContentsStatics.fromRenderFrameHost(mRenderFrameHost));
+ if (contentViewCore == null) {
+ return null;
+ }
+
+ String pageUrl = mRenderFrameHost.getLastCommittedURL();
boliu 2017/03/17 18:02:55 hmm, can the RFH navigate? in which case, caching
Matt Giuca 2017/03/20 06:31:56 I don't think so; I logged this code path and it g
boliu 2017/03/20 16:56:20 I don't think that testing is good enough here. n
Matt Giuca 2017/03/21 04:16:13 Ah, you're right. https://cs.chromium.org/chromiu
dcheng 2017/03/21 07:19:42 A RenderFrameHost is tied to a specific process ID
+ return new InstalledAppProviderImpl(pageUrl, contentViewCore.getContext());
boliu 2017/03/17 18:02:55 this is the application context in chrome iirc, is
Matt Giuca 2017/03/20 06:31:56 Done. Cool idea, that simplifies the code (I am pr
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698