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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java

Issue 2359363004: Add a button to OIB to launch an instant app if it exists. (Closed)
Patch Set: Comments Created 4 years, 3 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/pageinfo/WebsiteSettingsPopup.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java b/chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java
index ddb525452dc8eedbff82a490db6fc124202f5b9e..3d83dec2543a8837fdeeac524dd384912f6595e8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java
@@ -10,6 +10,7 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Dialog;
+import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
@@ -48,6 +49,7 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ContentSettingsType;
+import org.chromium.chrome.browser.instantapps.InstantAppsHandler;
import org.chromium.chrome.browser.offlinepages.OfflinePageItem;
import org.chromium.chrome.browser.offlinepages.OfflinePageUtils;
import org.chromium.chrome.browser.omnibox.OmniboxUrlEmphasizer;
@@ -254,6 +256,7 @@ public class WebsiteSettingsPopup implements OnClickListener {
private final ElidedUrlTextView mUrlTitle;
private final TextView mUrlConnectionMessage;
private final LinearLayout mPermissionsList;
+ private final Button mInstantAppButton;
private final Button mSiteSettingsButton;
// The dialog the container is placed in.
@@ -294,6 +297,9 @@ public class WebsiteSettingsPopup implements OnClickListener {
// The name of the content publisher, if any.
private String mContentPublisher;
+ // The intent associated with the instant app for this URL (or null if one does not exist).
+ private Intent mInstantAppIntent;
+
/**
* Creates the WebsiteSettingsPopup, but does not display it. Also initializes the corresponding
* C++ object and saves a pointer to it.
@@ -352,6 +358,10 @@ public class WebsiteSettingsPopup implements OnClickListener {
mPermissionsList = (LinearLayout) mContainer
.findViewById(R.id.website_settings_permissions_list);
+ mInstantAppButton =
+ (Button) mContainer.findViewById(R.id.website_settings_instant_app_button);
+ mInstantAppButton.setOnClickListener(this);
+
mSiteSettingsButton =
(Button) mContainer.findViewById(R.id.website_settings_site_settings_button);
mSiteSettingsButton.setOnClickListener(this);
@@ -466,6 +476,10 @@ public class WebsiteSettingsPopup implements OnClickListener {
|| mParsedUrl.getScheme().equals("https"))) {
mSiteSettingsButton.setVisibility(View.GONE);
}
+
+ mInstantAppIntent = mIsInternalPage ? null
+ : InstantAppsHandler.getInstance().getInstantAppIntentForUrl(mFullUrl);
+ if (mInstantAppIntent == null) mInstantAppButton.setVisibility(View.GONE);
}
/**
@@ -749,6 +763,13 @@ public class WebsiteSettingsPopup implements OnClickListener {
mContext.startActivity(preferencesIntent);
}
});
+ } else if (view == mInstantAppButton) {
+ try {
+ mContext.startActivity(mInstantAppIntent);
+ RecordUserAction.record("Android.InstantApps.LaunchedFromWebsiteSettingsPopup");
+ } catch (ActivityNotFoundException e) {
+ mInstantAppButton.setEnabled(false);
+ }
} else if (view == mUrlTitle) {
// Expand/collapse the displayed URL title.
mUrlTitle.toggleTruncation();
@@ -809,6 +830,7 @@ public class WebsiteSettingsPopup implements OnClickListener {
List<View> animatableViews = new ArrayList<View>();
animatableViews.add(mUrlTitle);
animatableViews.add(mUrlConnectionMessage);
+ animatableViews.add(mInstantAppButton);
for (int i = 0; i < mPermissionsList.getChildCount(); i++) {
animatableViews.add(mPermissionsList.getChildAt(i));
}

Powered by Google App Engine
This is Rietveld 408576698