Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/AppBannerInfoBar.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AppBannerInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AppBannerInfoBar.java |
index 297c3d74732b502de82039c391f1b106f6524880..5600d68c7f70ce1d373c4f9c1585a389bed3d84c 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AppBannerInfoBar.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AppBannerInfoBar.java |
@@ -4,32 +4,64 @@ |
package org.chromium.chrome.browser.infobar; |
+import android.content.Context; |
import android.graphics.Bitmap; |
import android.widget.TextView; |
import org.chromium.base.ApplicationStatus; |
import org.chromium.base.CalledByNative; |
import org.chromium.chrome.R; |
+import org.chromium.chrome.browser.banners.AppData; |
/** |
* Infobar informing the user about an app related to this page. |
*/ |
public class AppBannerInfoBar extends ConfirmInfoBar { |
- /** Web app: URL pointing to the web app. */ |
+ private final String mAppTitle; |
+ |
+ // Data for native app installs. |
+ private final AppData mAppData; |
+ |
+ // Data for web app installs. |
private final String mAppUrl; |
+ // Banner for native apps. |
+ private AppBannerInfoBar(long nativeInfoBar, String appTitle, Bitmap iconBitmap, AppData data) { |
+ super(nativeInfoBar, null, 0, iconBitmap, appTitle, null, data.installButtonText(), null); |
+ mAppTitle = appTitle; |
+ mAppData = data; |
+ mAppUrl = null; |
+ } |
+ |
// Banner for web apps. |
- public AppBannerInfoBar(long nativeInfoBar, String appTitle, Bitmap iconBitmap, String url) { |
+ private AppBannerInfoBar(long nativeInfoBar, String appTitle, Bitmap iconBitmap, String url) { |
super(nativeInfoBar, null, 0, iconBitmap, appTitle, null, getAddToHomescreenText(), null); |
+ mAppTitle = appTitle; |
+ mAppData = null; |
mAppUrl = url; |
} |
@Override |
public void createContent(InfoBarLayout layout) { |
- TextView url = new TextView(layout.getContext()); |
- url.setText(mAppUrl); |
- layout.setCustomContent(url); |
+ if (mAppUrl != null) { |
+ TextView url = new TextView(layout.getContext()); |
+ url.setText(mAppUrl); |
+ layout.setCustomContent(url); |
+ } |
+ |
super.createContent(layout); |
+ |
+ // Set up accessibility text. |
+ Context context = getContext(); |
+ if (mAppData != null) { |
+ layout.setContentDescription(context.getString( |
+ R.string.app_banner_view_native_app_accessibility, mAppTitle, |
+ mAppData.rating())); |
+ } else { |
+ layout.setContentDescription(context.getString( |
+ R.string.app_banner_view_web_app_accessibility, mAppTitle, |
+ mAppUrl)); |
+ } |
} |
private static String getAddToHomescreenText() { |
@@ -37,8 +69,14 @@ public class AppBannerInfoBar extends ConfirmInfoBar { |
} |
@CalledByNative |
+ private static InfoBar createNativeAppInfoBar( |
+ long nativeInfoBar, String appTitle, Bitmap iconBitmap, AppData appData) { |
+ return new AppBannerInfoBar(nativeInfoBar, appTitle, iconBitmap, appData); |
+ } |
+ |
+ @CalledByNative |
private static InfoBar createWebAppInfoBar( |
long nativeInfoBar, String appTitle, Bitmap iconBitmap, String url) { |
return new AppBannerInfoBar(nativeInfoBar, appTitle, iconBitmap, url); |
} |
-} |
+} |