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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkUtils.java

Issue 1915353002: Include a ComponentName in bookmark intents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use correct package in intent extra Created 4 years, 8 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/IntentHandler.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkUtils.java
index 6e3a2ddd84fe8ae9ecb58bfede56583963fb5548..bf57228e3f3d7c40e22d0bd765ae0747d5389d0c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkUtils.java
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.bookmarks;
import android.app.Activity;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -20,13 +21,13 @@ import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.UrlConstants;
-import org.chromium.chrome.browser.document.ChromeLauncherActivity;
import org.chromium.chrome.browser.ntp.NewTabPageUma;
import org.chromium.chrome.browser.snackbar.Snackbar;
import org.chromium.chrome.browser.snackbar.SnackbarManager;
import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.util.FeatureUtilities;
+import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.components.bookmarks.BookmarkId;
import org.chromium.components.bookmarks.BookmarkType;
import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils;
@@ -147,10 +148,11 @@ public class BookmarkUtils {
String url = getFirstUrlToLoad(activity);
if (DeviceFormFactor.isTablet(activity)) {
- openUrl(activity, url);
+ openUrl(activity, url, activity.getComponentName());
} else {
Intent intent = new Intent(activity, BookmarkActivity.class);
intent.setData(Uri.parse(url));
+ intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getComponentName());
activity.startActivity(intent);
}
}
@@ -231,17 +233,28 @@ public class BookmarkUtils {
RecordHistogram.recordEnumeratedHistogram(
"Stars.LaunchLocation", launchLocation, BookmarkLaunchLocation.COUNT);
- openUrl(activity, url);
+ if (DeviceFormFactor.isTablet(activity)) {
+ // For tablets, the bookmark manager is open in a tab in the ChromeActivity. Use
+ // the ComponentName of the ChromeActivity passed into this method.
+ openUrl(activity, url, activity.getComponentName());
+ } else {
+ // For phones, the bookmark manager is a separate activity. When the activity is
+ // launched, an intent extra is set specifying the parent component.
+ ComponentName parentComponent = IntentUtils.safeGetParcelableExtra(
+ activity.getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT);
+ openUrl(activity, url, parentComponent);
+ }
+
return true;
}
- private static void openUrl(Activity activity, String url) {
+ private static void openUrl(Activity activity, String url, ComponentName componentName) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
- intent.setClassName(activity.getApplicationContext().getPackageName(),
- ChromeLauncherActivity.class.getName());
intent.putExtra(Browser.EXTRA_APPLICATION_ID,
activity.getApplicationContext().getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setComponent(componentName);
+
IntentHandler.startActivityForTrustedIntent(intent, activity);
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/IntentHandler.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698