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..da4204db5c3ed8aec9e437a75955f8358fb1953b |
--- /dev/null |
+++ b/content/public/android/java/src/org/chromium/content/browser/installedapp/InstalledAppProviderFactory.java |
@@ -0,0 +1,45 @@ |
+// 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 PageUrlDelegateImpl mPageUrlDelegate; |
+ |
+ private static final class PageUrlDelegateImpl |
+ implements InstalledAppProviderImpl.PageUrlDelegate { |
+ private final RenderFrameHost mRenderFrameHost; |
+ |
+ public PageUrlDelegateImpl(RenderFrameHost renderFrameHost) { |
+ mRenderFrameHost = renderFrameHost; |
+ } |
+ |
+ @Override |
+ public URI getUrl() { |
+ try { |
+ return new URI(mRenderFrameHost.getLastCommittedURL()); |
dcheng
2017/03/21 07:37:50
Nit: seems like the RenderFrameHost interface shou
Matt Giuca
2017/03/21 07:46:01
Yes, I agree. I looked at doing this, but the only
boliu
2017/03/21 15:36:59
getLastCommittedURL can legitimately return null,
Matt Giuca
2017/03/22 00:28:47
Done.
(If this returns null, it's handled in isAp
|
+ } catch (URISyntaxException e) { |
+ throw new AssertionError(e); |
+ } |
+ } |
+ } |
+ |
+ public InstalledAppProviderFactory(RenderFrameHost renderFrameHost) { |
+ mPageUrlDelegate = new PageUrlDelegateImpl(renderFrameHost); |
+ } |
+ |
+ @Override |
+ public InstalledAppProvider createImpl() { |
+ return new InstalledAppProviderImpl(mPageUrlDelegate, ContextUtils.getApplicationContext()); |
+ } |
+} |