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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/InstantAppsInfoBarDelegate.java

Issue 2267463002: Implement instant apps infobar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix an import Created 4 years, 4 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: chrome/android/java/src/org/chromium/chrome/browser/infobar/InstantAppsInfoBarDelegate.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InstantAppsInfoBarDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InstantAppsInfoBarDelegate.java
new file mode 100644
index 0000000000000000000000000000000000000000..1a6d8145a737e886412a5ad5aa5d266ce9bb7ed7
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InstantAppsInfoBarDelegate.java
@@ -0,0 +1,47 @@
+// Copyright 2016 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.chrome.browser.infobar;
+
+import android.graphics.Bitmap;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.chrome.browser.instantapps.InstantAppsBannerData;
+import org.chromium.content_public.browser.WebContents;
+
+import java.net.URI;
+
+/**
+ * Delegate for {@link InstantAppsInfoBar}. Use launch() method to display the infobar.
+ */
+public class InstantAppsInfoBarDelegate {
+
+ private InstantAppsBannerData mData;
+
+ public static void launch(WebContents webContents, String appName, Bitmap appIcon) {
+ String hostname = "";
+ try {
+ URI uri = URI.create(webContents.getUrl());
+ hostname = uri.getRawAuthority();
+ } catch (IllegalArgumentException e) {
+ // not able to parse the URL.
+ }
+ InstantAppsBannerData data = new InstantAppsBannerData(appName, appIcon, hostname);
+ nativeLaunch(webContents, data);
+ }
+
+ @CalledByNative
+ private static InstantAppsInfoBarDelegate create() {
+ return new InstantAppsInfoBarDelegate();
+ }
+
+ private InstantAppsInfoBarDelegate() {}
+
+ @CalledByNative
+ private void openInstantApp() {
+ // TODO(mariakhomenko): launch instant app intent
+ }
+
+ private static native void nativeLaunch(WebContents webContents, InstantAppsBannerData data);
+}

Powered by Google App Engine
This is Rietveld 408576698