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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java

Issue 1683533002: Herb: Show an icon allowing the user to open a tab in Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix back button Created 4 years, 10 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/document/ChromeLauncherActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java
index a97feb44cf0f24b294ec1e14f213937bfbd015ec..95a6d8cd199e844ba0e9435944a31947edd14368 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java
@@ -18,6 +18,8 @@ import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -31,6 +33,7 @@ import org.chromium.base.ApplicationStatus;
import org.chromium.base.CommandLineInitUtil;
import org.chromium.base.Log;
import org.chromium.base.TraceEvent;
+import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeApplication;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.ChromeTabbedActivity;
@@ -41,6 +44,7 @@ import org.chromium.chrome.browser.ShortcutSource;
import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.WarmupManager;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
+import org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider;
import org.chromium.chrome.browser.externalnav.IntentWithGesturesHandler;
import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer;
import org.chromium.chrome.browser.metrics.LaunchMetrics;
@@ -81,6 +85,12 @@ public class ChromeLauncherActivity extends Activity
"com.google.android.apps.chrome.EXTRA_LAUNCH_MODE";
/**
+ * Whether or not the toolbar should indicate that a tab was spawned by another Activity.
+ */
+ public static final String EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT =
Ian Wen 2016/02/09 20:30:49 So if this extra is set to false, when the user hi
gone 2016/02/09 21:21:32 Changed the behavior according to Chris' comment o
+ "org.chromium.chrome.browser.document.IS_ALLOWED_TO_RETURN_TO_PARENT";
+
+ /**
* Action fired when the user selects the "Close all incognito tabs" notification.
*/
static final String ACTION_CLOSE_ALL_INCOGNITO =
@@ -314,6 +324,28 @@ public class ChromeLauncherActivity extends Activity
}
}
+ private void addHerbIntentExtras(Intent newIntent, Uri uri) {
+ Bundle herbBundle = new Bundle();
+
+ Bitmap herbIcon =
+ BitmapFactory.decodeResource(getResources(), R.drawable.btn_open_in_chrome);
+ herbBundle.putParcelable(CustomTabsIntent.KEY_ICON, herbIcon);
+
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.putExtra(EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, false);
+
+ PendingIntent pendingIntent =
+ PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
+ herbBundle.putParcelable(CustomTabsIntent.KEY_PENDING_INTENT, pendingIntent);
+
+ herbBundle.putString(CustomTabsIntent.KEY_DESCRIPTION,
+ getResources().getString(R.string.menu_open_in_chrome));
+
+ newIntent.putExtra(CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE, herbBundle);
+ newIntent.putExtra(CustomTabIntentDataProvider.EXTRA_FINISH_ACTIVITY_ON_ACTION, true);
+ }
+
/**
* @return Whether the intent sent is for launching a Custom Tab.
*/
@@ -340,10 +372,14 @@ public class ChromeLauncherActivity extends Activity
// Create and fire a launch intent. Use the copy constructor to carry over the myriad of
// extras.
+ Uri uri = Uri.parse(IntentHandler.getUrlFromIntent(getIntent()));
+
Intent newIntent = new Intent(getIntent());
newIntent.setAction(Intent.ACTION_VIEW);
newIntent.setClassName(this, CustomTabActivity.class.getName());
- newIntent.setData(Uri.parse(IntentHandler.getUrlFromIntent(getIntent())));
+ newIntent.setData(uri);
+ if (isIntentHandledByHerb()) addHerbIntentExtras(newIntent, uri);
+
startActivity(newIntent);
}

Powered by Google App Engine
This is Rietveld 408576698