| 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.BuildInfo; | 16 import org.chromium.base.BuildInfo; |
| 17 import org.chromium.base.ContextUtils; | 17 import org.chromium.base.ContextUtils; |
| 18 import org.chromium.base.VisibleForTesting; | 18 import org.chromium.base.VisibleForTesting; |
| 19 import org.chromium.base.metrics.RecordHistogram; | 19 import org.chromium.base.metrics.RecordHistogram; |
| 20 import org.chromium.base.metrics.RecordUserAction; | 20 import org.chromium.base.metrics.RecordUserAction; |
| 21 import org.chromium.chrome.R; | 21 import org.chromium.chrome.R; |
| 22 import org.chromium.chrome.browser.IntentHandler; | 22 import org.chromium.chrome.browser.IntentHandler; |
| 23 import org.chromium.chrome.browser.UrlConstants; | 23 import org.chromium.chrome.browser.UrlConstants; |
| 24 import org.chromium.chrome.browser.document.ChromeLauncherActivity; | 24 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
| 25 import org.chromium.chrome.browser.ntp.NewTabPageUma; | |
| 26 import org.chromium.chrome.browser.snackbar.Snackbar; | 25 import org.chromium.chrome.browser.snackbar.Snackbar; |
| 27 import org.chromium.chrome.browser.snackbar.SnackbarManager; | 26 import org.chromium.chrome.browser.snackbar.SnackbarManager; |
| 28 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; | 27 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; |
| 29 import org.chromium.chrome.browser.tab.Tab; | 28 import org.chromium.chrome.browser.tab.Tab; |
| 30 import org.chromium.chrome.browser.util.IntentUtils; | 29 import org.chromium.chrome.browser.util.IntentUtils; |
| 31 import org.chromium.components.bookmarks.BookmarkId; | 30 import org.chromium.components.bookmarks.BookmarkId; |
| 32 import org.chromium.components.bookmarks.BookmarkType; | 31 import org.chromium.components.bookmarks.BookmarkType; |
| 33 import org.chromium.ui.base.DeviceFormFactor; | 32 import org.chromium.ui.base.DeviceFormFactor; |
| 34 import org.chromium.ui.base.PageTransition; | 33 import org.chromium.ui.base.PageTransition; |
| 35 | 34 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 * @param bookmarkId ID of the bookmark to be opened. | 232 * @param bookmarkId ID of the bookmark to be opened. |
| 234 * @param launchLocation Location from which the bookmark is being opened. | 233 * @param launchLocation Location from which the bookmark is being opened. |
| 235 * @return Whether the bookmark was successfully opened. | 234 * @return Whether the bookmark was successfully opened. |
| 236 */ | 235 */ |
| 237 public static boolean openBookmark(BookmarkModel model, Activity activity, | 236 public static boolean openBookmark(BookmarkModel model, Activity activity, |
| 238 BookmarkId bookmarkId, int launchLocation) { | 237 BookmarkId bookmarkId, int launchLocation) { |
| 239 if (model.getBookmarkById(bookmarkId) == null) return false; | 238 if (model.getBookmarkById(bookmarkId) == null) return false; |
| 240 | 239 |
| 241 String url = model.getBookmarkById(bookmarkId).getUrl(); | 240 String url = model.getBookmarkById(bookmarkId).getUrl(); |
| 242 | 241 |
| 243 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_BOOKMARK); | 242 RecordUserAction.record("MobileBookmarkManagerEntryOpened"); |
| 244 RecordHistogram.recordEnumeratedHistogram( | 243 RecordHistogram.recordEnumeratedHistogram( |
| 245 "Stars.LaunchLocation", launchLocation, BookmarkLaunchLocation.C
OUNT); | 244 "Stars.LaunchLocation", launchLocation, BookmarkLaunchLocation.C
OUNT); |
| 246 | 245 |
| 247 if (DeviceFormFactor.isTablet(activity)) { | 246 if (DeviceFormFactor.isTablet(activity)) { |
| 248 // For tablets, the bookmark manager is open in a tab in the ChromeA
ctivity. Use | 247 // For tablets, the bookmark manager is open in a tab in the ChromeA
ctivity. Use |
| 249 // the ComponentName of the ChromeActivity passed into this method. | 248 // the ComponentName of the ChromeActivity passed into this method. |
| 250 openUrl(activity, url, activity.getComponentName()); | 249 openUrl(activity, url, activity.getComponentName()); |
| 251 } else { | 250 } else { |
| 252 // For phones, the bookmark manager is a separate activity. When the
activity is | 251 // For phones, the bookmark manager is a separate activity. When the
activity is |
| 253 // launched, an intent extra is set specifying the parent component. | 252 // launched, an intent extra is set specifying the parent component. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 280 | 279 |
| 281 /** | 280 /** |
| 282 * Closes the {@link BookmarkActivity} on Phone. Does nothing on tablet. | 281 * Closes the {@link BookmarkActivity} on Phone. Does nothing on tablet. |
| 283 */ | 282 */ |
| 284 public static void finishActivityOnPhone(Context context) { | 283 public static void finishActivityOnPhone(Context context) { |
| 285 if (context instanceof BookmarkActivity) { | 284 if (context instanceof BookmarkActivity) { |
| 286 ((Activity) context).finish(); | 285 ((Activity) context).finish(); |
| 287 } | 286 } |
| 288 } | 287 } |
| 289 } | 288 } |
| OLD | NEW |