| 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; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 /** | 155 /** |
| 156 * Shows bookmark main UI. | 156 * Shows bookmark main UI. |
| 157 */ | 157 */ |
| 158 public static void showBookmarkManager(ChromeActivity activity) { | 158 public static void showBookmarkManager(ChromeActivity activity) { |
| 159 String url = getFirstUrlToLoad(activity); | 159 String url = getFirstUrlToLoad(activity); |
| 160 | 160 |
| 161 if (activity.getBottomSheet() != null) { | 161 if (activity.getBottomSheet() != null) { |
| 162 activity.getBottomSheetContentController().showContentAndOpenSheet( | 162 activity.getBottomSheetContentController().showContentAndOpenSheet( |
| 163 R.id.action_bookmarks); | 163 R.id.action_bookmarks); |
| 164 } else if (DeviceFormFactor.isTablet(activity)) { | 164 } else if (DeviceFormFactor.isTablet()) { |
| 165 openUrl(activity, url, activity.getComponentName()); | 165 openUrl(activity, url, activity.getComponentName()); |
| 166 } else { | 166 } else { |
| 167 Intent intent = new Intent(activity, BookmarkActivity.class); | 167 Intent intent = new Intent(activity, BookmarkActivity.class); |
| 168 intent.setData(Uri.parse(url)); | 168 intent.setData(Uri.parse(url)); |
| 169 intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getCo
mponentName()); | 169 intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getCo
mponentName()); |
| 170 activity.startActivity(intent); | 170 activity.startActivity(intent); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 /** | 174 /** |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 public static boolean openBookmark(BookmarkModel model, Activity activity, | 240 public static boolean openBookmark(BookmarkModel model, Activity activity, |
| 241 BookmarkId bookmarkId, int launchLocation) { | 241 BookmarkId bookmarkId, int launchLocation) { |
| 242 if (model.getBookmarkById(bookmarkId) == null) return false; | 242 if (model.getBookmarkById(bookmarkId) == null) return false; |
| 243 | 243 |
| 244 String url = model.getBookmarkById(bookmarkId).getUrl(); | 244 String url = model.getBookmarkById(bookmarkId).getUrl(); |
| 245 | 245 |
| 246 RecordUserAction.record("MobileBookmarkManagerEntryOpened"); | 246 RecordUserAction.record("MobileBookmarkManagerEntryOpened"); |
| 247 RecordHistogram.recordEnumeratedHistogram( | 247 RecordHistogram.recordEnumeratedHistogram( |
| 248 "Stars.LaunchLocation", launchLocation, BookmarkLaunchLocation.C
OUNT); | 248 "Stars.LaunchLocation", launchLocation, BookmarkLaunchLocation.C
OUNT); |
| 249 | 249 |
| 250 if (DeviceFormFactor.isTablet(activity)) { | 250 if (DeviceFormFactor.isTablet()) { |
| 251 // For tablets, the bookmark manager is open in a tab in the ChromeA
ctivity. Use | 251 // For tablets, the bookmark manager is open in a tab in the ChromeA
ctivity. Use |
| 252 // the ComponentName of the ChromeActivity passed into this method. | 252 // the ComponentName of the ChromeActivity passed into this method. |
| 253 openUrl(activity, url, activity.getComponentName()); | 253 openUrl(activity, url, activity.getComponentName()); |
| 254 } else { | 254 } else { |
| 255 // For phones, the bookmark manager is a separate activity. When the
activity is | 255 // For phones, the bookmark manager is a separate activity. When the
activity is |
| 256 // launched, an intent extra is set specifying the parent component. | 256 // launched, an intent extra is set specifying the parent component. |
| 257 ComponentName parentComponent = IntentUtils.safeGetParcelableExtra( | 257 ComponentName parentComponent = IntentUtils.safeGetParcelableExtra( |
| 258 activity.getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT); | 258 activity.getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT); |
| 259 openUrl(activity, url, parentComponent); | 259 openUrl(activity, url, parentComponent); |
| 260 } | 260 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 283 | 283 |
| 284 /** | 284 /** |
| 285 * Closes the {@link BookmarkActivity} on Phone. Does nothing on tablet. | 285 * Closes the {@link BookmarkActivity} on Phone. Does nothing on tablet. |
| 286 */ | 286 */ |
| 287 public static void finishActivityOnPhone(Context context) { | 287 public static void finishActivityOnPhone(Context context) { |
| 288 if (context instanceof BookmarkActivity) { | 288 if (context instanceof BookmarkActivity) { |
| 289 ((Activity) context).finish(); | 289 ((Activity) context).finish(); |
| 290 } | 290 } |
| 291 } | 291 } |
| 292 } | 292 } |
| OLD | NEW |