| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.bookmarks; | 5 package org.chromium.chrome.browser.bookmarks; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.ComponentName; | 8 import android.content.ComponentName; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| 11 import android.content.SharedPreferences; | 11 import android.content.SharedPreferences; |
| 12 import android.net.Uri; | 12 import android.net.Uri; |
| 13 import android.provider.Browser; | 13 import android.provider.Browser; |
| 14 import android.text.TextUtils; | 14 import android.text.TextUtils; |
| 15 | 15 |
| 16 import org.chromium.base.ApiCompatibilityUtils; | |
| 17 import org.chromium.base.ContextUtils; | 16 import org.chromium.base.ContextUtils; |
| 18 import org.chromium.base.VisibleForTesting; | 17 import org.chromium.base.VisibleForTesting; |
| 19 import org.chromium.base.metrics.RecordHistogram; | 18 import org.chromium.base.metrics.RecordHistogram; |
| 20 import org.chromium.base.metrics.RecordUserAction; | 19 import org.chromium.base.metrics.RecordUserAction; |
| 21 import org.chromium.chrome.R; | 20 import org.chromium.chrome.R; |
| 22 import org.chromium.chrome.browser.ChromeFeatureList; | 21 import org.chromium.chrome.browser.ChromeFeatureList; |
| 23 import org.chromium.chrome.browser.IntentHandler; | 22 import org.chromium.chrome.browser.IntentHandler; |
| 24 import org.chromium.chrome.browser.UrlConstants; | 23 import org.chromium.chrome.browser.UrlConstants; |
| 25 import org.chromium.chrome.browser.document.ChromeLauncherActivity; | 24 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
| 26 import org.chromium.chrome.browser.ntp.NewTabPageUma; | 25 import org.chromium.chrome.browser.ntp.NewTabPageUma; |
| 27 import org.chromium.chrome.browser.snackbar.Snackbar; | 26 import org.chromium.chrome.browser.snackbar.Snackbar; |
| 28 import org.chromium.chrome.browser.snackbar.SnackbarManager; | 27 import org.chromium.chrome.browser.snackbar.SnackbarManager; |
| 29 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; | 28 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; |
| 30 import org.chromium.chrome.browser.tab.Tab; | 29 import org.chromium.chrome.browser.tab.Tab; |
| 31 import org.chromium.chrome.browser.util.FeatureUtilities; | |
| 32 import org.chromium.chrome.browser.util.IntentUtils; | 30 import org.chromium.chrome.browser.util.IntentUtils; |
| 33 import org.chromium.components.bookmarks.BookmarkId; | 31 import org.chromium.components.bookmarks.BookmarkId; |
| 34 import org.chromium.components.bookmarks.BookmarkType; | 32 import org.chromium.components.bookmarks.BookmarkType; |
| 35 import org.chromium.ui.base.DeviceFormFactor; | 33 import org.chromium.ui.base.DeviceFormFactor; |
| 36 | 34 |
| 37 /** | 35 /** |
| 38 * A class holding static util functions for bookmark. | 36 * A class holding static util functions for bookmark. |
| 39 */ | 37 */ |
| 40 public class BookmarkUtils { | 38 public class BookmarkUtils { |
| 41 private static final String PREF_LAST_USED_URL = "enhanced_bookmark_last_use
d_url"; | 39 private static final String PREF_LAST_USED_URL = "enhanced_bookmark_last_use
d_url"; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 // If the bookmark manager is shown in a tab on a phone (rather than
in a separate | 261 // If the bookmark manager is shown in a tab on a phone (rather than
in a separate |
| 264 // activity) the component name may be null. Send the intent through | 262 // activity) the component name may be null. Send the intent through |
| 265 // ChromeLauncherActivity instead to avoid crashing. See crbug.com/6
15012. | 263 // ChromeLauncherActivity instead to avoid crashing. See crbug.com/6
15012. |
| 266 intent.setClass(activity, ChromeLauncherActivity.class); | 264 intent.setClass(activity, ChromeLauncherActivity.class); |
| 267 } | 265 } |
| 268 | 266 |
| 269 IntentHandler.startActivityForTrustedIntent(intent, activity); | 267 IntentHandler.startActivityForTrustedIntent(intent, activity); |
| 270 } | 268 } |
| 271 | 269 |
| 272 /** | 270 /** |
| 273 * Updates the title of chrome shown in recent tasks. It only takes effect i
n document mode. | |
| 274 */ | |
| 275 public static void setTaskDescriptionInDocumentMode(Activity activity, Strin
g description) { | |
| 276 if (FeatureUtilities.isDocumentMode(activity)) { | |
| 277 // Setting icon to be null and color to be 0 will means "take no eff
ect". | |
| 278 ApiCompatibilityUtils.setTaskDescription(activity, description, null
, 0); | |
| 279 } | |
| 280 } | |
| 281 | |
| 282 /** | |
| 283 * Closes the {@link BookmarkActivity} on Phone. Does nothing on tablet. | 271 * Closes the {@link BookmarkActivity} on Phone. Does nothing on tablet. |
| 284 */ | 272 */ |
| 285 public static void finishActivityOnPhone(Context context) { | 273 public static void finishActivityOnPhone(Context context) { |
| 286 if (context instanceof BookmarkActivity) { | 274 if (context instanceof BookmarkActivity) { |
| 287 ((Activity) context).finish(); | 275 ((Activity) context).finish(); |
| 288 } | 276 } |
| 289 } | 277 } |
| 290 | 278 |
| 291 /** | 279 /** |
| 292 * @return Whether "all bookmarks" section is enabled. | 280 * @return Whether "all bookmarks" section is enabled. |
| 293 */ | 281 */ |
| 294 static boolean isAllBookmarksViewEnabled() { | 282 static boolean isAllBookmarksViewEnabled() { |
| 295 return ChromeFeatureList.isEnabled("AllBookmarks"); | 283 return ChromeFeatureList.isEnabled("AllBookmarks"); |
| 296 } | 284 } |
| 297 } | 285 } |
| OLD | NEW |