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

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: Rebase. 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..82bf8be2a8d6c3bd4dea4761cf4a2d89649379d3
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/installedapp/InstalledAppProviderFactory.java
@@ -0,0 +1,49 @@
+// 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.base.ContextUtils;
+import org.chromium.content_public.browser.RenderFrameHost;
+import org.chromium.installedapp.mojom.InstalledAppProvider;
+import org.chromium.services.service_manager.InterfaceFactory;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/** Factory to create instances of the InstalledAppProvider Mojo service. */
+public class InstalledAppProviderFactory implements InterfaceFactory<InstalledAppProvider> {
+ private final FrameUrlDelegateImpl mFrameUrlDelegate;
+
+ private static final class FrameUrlDelegateImpl
+ implements InstalledAppProviderImpl.FrameUrlDelegate {
+ private final RenderFrameHost mRenderFrameHost;
+
+ public FrameUrlDelegateImpl(RenderFrameHost renderFrameHost) {
+ mRenderFrameHost = renderFrameHost;
+ }
+
+ @Override
+ public URI getUrl() {
+ String url = mRenderFrameHost.getLastCommittedURL();
+ if (url == null) return null;
+
+ try {
+ return new URI(url);
+ } catch (URISyntaxException e) {
+ throw new AssertionError(e);
+ }
+ }
+ }
+
+ public InstalledAppProviderFactory(RenderFrameHost renderFrameHost) {
+ mFrameUrlDelegate = new FrameUrlDelegateImpl(renderFrameHost);
+ }
+
+ @Override
+ public InstalledAppProvider createImpl() {
+ return new InstalledAppProviderImpl(
+ mFrameUrlDelegate, ContextUtils.getApplicationContext());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698