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

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

Issue 479573002: Added a method to check if adding a shortcut to the homescreen is supported. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « no previous file | 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/BookmarkUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/BookmarkUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/BookmarkUtils.java
index 0f318b3e9995e58ee3faab696f059076945c480b..53a491f62ebef5f1def476318d4b16a5cc89b410 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/BookmarkUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/BookmarkUtils.java
@@ -7,6 +7,8 @@ package org.chromium.chrome.browser;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -26,6 +28,8 @@ import android.util.TypedValue;
import org.chromium.chrome.R;
+import java.util.List;
+
/**
* Util class for bookmarks.
*/
@@ -93,6 +97,19 @@ public class BookmarkUtils {
}
/**
+ * Utility method to check if a shortcut can be added to the homescreen.
+ * @param context Context used to get the package manager.
+ * @return if a shortcut can be added to the homescreen under the current profile.
+ */
+ public static boolean isAddToHomeIntentSupported(Context context) {
+ PackageManager pm = context.getPackageManager();
+ Intent i = new Intent(INSTALL_SHORTCUT);
+ List<ResolveInfo> receivers = pm.queryBroadcastReceivers(
+ i, PackageManager.GET_INTENT_FILTERS);
+ return !receivers.isEmpty();
+ }
+
+ /**
* Creates an icon to be associated with this bookmark. If available, the touch icon
* will be used, else we draw our own.
* @param context Context used to create the intent.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698