| 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 15 matching lines...) Expand all Loading... |
| 26 import org.chromium.chrome.browser.document.ChromeLauncherActivity; | 26 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
| 27 import org.chromium.chrome.browser.ntp.NewTabPageUma; | 27 import org.chromium.chrome.browser.ntp.NewTabPageUma; |
| 28 import org.chromium.chrome.browser.snackbar.Snackbar; | 28 import org.chromium.chrome.browser.snackbar.Snackbar; |
| 29 import org.chromium.chrome.browser.snackbar.SnackbarManager; | 29 import org.chromium.chrome.browser.snackbar.SnackbarManager; |
| 30 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; | 30 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; |
| 31 import org.chromium.chrome.browser.tab.Tab; | 31 import org.chromium.chrome.browser.tab.Tab; |
| 32 import org.chromium.chrome.browser.util.FeatureUtilities; | 32 import org.chromium.chrome.browser.util.FeatureUtilities; |
| 33 import org.chromium.chrome.browser.util.IntentUtils; | 33 import org.chromium.chrome.browser.util.IntentUtils; |
| 34 import org.chromium.components.bookmarks.BookmarkId; | 34 import org.chromium.components.bookmarks.BookmarkId; |
| 35 import org.chromium.components.bookmarks.BookmarkType; | 35 import org.chromium.components.bookmarks.BookmarkType; |
| 36 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; | |
| 37 import org.chromium.ui.base.DeviceFormFactor; | 36 import org.chromium.ui.base.DeviceFormFactor; |
| 38 | 37 |
| 39 /** | 38 /** |
| 40 * A class holding static util functions for bookmark. | 39 * A class holding static util functions for bookmark. |
| 41 */ | 40 */ |
| 42 public class BookmarkUtils { | 41 public class BookmarkUtils { |
| 43 private static final String PREF_LAST_USED_URL = "enhanced_bookmark_last_use
d_url"; | 42 private static final String PREF_LAST_USED_URL = "enhanced_bookmark_last_use
d_url"; |
| 44 private static final String PREF_LAST_USED_PARENT = "enhanced_bookmark_last_
used_parent_folder"; | 43 private static final String PREF_LAST_USED_PARENT = "enhanced_bookmark_last_
used_parent_folder"; |
| 45 | 44 |
| 46 /** | 45 /** |
| (...skipping 17 matching lines...) Expand all Loading... |
| 64 startEditActivity(activity, bookmarkId); | 63 startEditActivity(activity, bookmarkId); |
| 65 bookmarkModel.destroy(); | 64 bookmarkModel.destroy(); |
| 66 return bookmarkId; | 65 return bookmarkId; |
| 67 } | 66 } |
| 68 | 67 |
| 69 BookmarkId parent = getLastUsedParent(activity); | 68 BookmarkId parent = getLastUsedParent(activity); |
| 70 if (parent == null || !bookmarkModel.doesBookmarkExist(parent)) { | 69 if (parent == null || !bookmarkModel.doesBookmarkExist(parent)) { |
| 71 parent = bookmarkModel.getDefaultFolder(); | 70 parent = bookmarkModel.getDefaultFolder(); |
| 72 } | 71 } |
| 73 | 72 |
| 74 String url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(tab.get
Url()); | 73 String url = tab.getOriginalUrl(); |
| 75 BookmarkId bookmarkId = bookmarkModel.addBookmark(parent, | 74 BookmarkId bookmarkId = bookmarkModel.addBookmark(parent, |
| 76 bookmarkModel.getChildCount(parent), tab.getTitle(), url); | 75 bookmarkModel.getChildCount(parent), tab.getTitle(), url); |
| 77 | 76 |
| 78 Snackbar snackbar = null; | 77 Snackbar snackbar = null; |
| 79 if (bookmarkId == null) { | 78 if (bookmarkId == null) { |
| 80 snackbar = Snackbar.make(activity.getString(R.string.bookmark_page_f
ailed), | 79 snackbar = Snackbar.make(activity.getString(R.string.bookmark_page_f
ailed), |
| 81 new SnackbarController() { | 80 new SnackbarController() { |
| 82 @Override | 81 @Override |
| 83 public void onDismissNoAction(Object actionData) { } | 82 public void onDismissNoAction(Object actionData) { } |
| 84 | 83 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 291 |
| 293 /** | 292 /** |
| 294 * @return Whether "all bookmarks" section is enabled. | 293 * @return Whether "all bookmarks" section is enabled. |
| 295 */ | 294 */ |
| 296 static boolean isAllBookmarksViewEnabled() { | 295 static boolean isAllBookmarksViewEnabled() { |
| 297 String flag = CommandLine.getInstance() | 296 String flag = CommandLine.getInstance() |
| 298 .getSwitchValue(ChromeSwitches.ENABLE_ALL_BOOKMARKS_VIEW, "false
"); | 297 .getSwitchValue(ChromeSwitches.ENABLE_ALL_BOOKMARKS_VIEW, "false
"); |
| 299 return flag.equals("true"); | 298 return flag.equals("true"); |
| 300 } | 299 } |
| 301 } | 300 } |
| OLD | NEW |