From 8d4dd86fc31b1694dbc26c9ec60dee602395edcc Mon Sep 17 00:00:00 2001 From: ianwen Date: Wed, 4 Mar 2015 11:16:20 -0800 Subject: [PATCH] Add EnhancedBookmark Command Line flag in Java Enhanced Bookmark feature may need to be turned on by some java instrumental tests. Therefore the flag should be added to the java command line class. BUG=458632 Review URL: https://codereview.chromium.org/973283002 Cr-Commit-Position: refs/heads/master@{#319096} --- .../java/src/org/chromium/chrome/ChromeSwitches.java | 6 ++++++ .../src/org/chromium/chrome/browser/BookmarksBridge.java | 9 +++++++-- chrome/browser/android/bookmarks/bookmarks_bridge.cc | 13 +++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/chrome/android/java/src/org/chromium/chrome/ChromeSwitches.java b/chrome/android/java/src/org/chromium/chrome/ChromeSwitches.java index e1639c1559fa..85c1213a55c4 100644 --- a/chrome/android/java/src/org/chromium/chrome/ChromeSwitches.java +++ b/chrome/android/java/src/org/chromium/chrome/ChromeSwitches.java @@ -109,6 +109,12 @@ public abstract class ChromeSwitches { /** Enable begin frame scheduling. */ public static final String ENABLE_BEGIN_FRAME_SCHEDULING = "enable-begin-frame-scheduling"; + /** + * Enable enhanced bookmarks feature. + * Native switch - switches::kEnhancedBookmarksExperiment + */ + public static final String ENABLE_ENHANCED_BOOKMARKS = "enhanced-bookmarks-experiment"; + /** Enable the DOM Distiller. */ public static final String ENABLE_DOM_DISTILLER = "enable-dom-distiller"; diff --git a/chrome/android/java/src/org/chromium/chrome/browser/BookmarksBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/BookmarksBridge.java index 93140596c518..07ebf13b9140 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/BookmarksBridge.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/BookmarksBridge.java @@ -544,8 +544,13 @@ public class BookmarksBridge { nativeEndGroupingUndos(mNativeBookmarksBridge); } + public static boolean isEditBookmarksEnabled(Profile profile) { + return nativeIsEditBookmarksEnabled(profile); + } + + // TODO(ianwen): Remove this method after rolling. public static boolean isEditBookmarksEnabled() { - return nativeIsEditBookmarksEnabled(); + return true; } public static boolean isEnhancedBookmarksEnabled(Profile profile) { @@ -737,7 +742,7 @@ public class BookmarksBridge { private native long nativeInit(Profile profile); private native boolean nativeIsDoingExtensiveChanges(long nativeBookmarksBridge); private native void nativeDestroy(long nativeBookmarksBridge); - private static native boolean nativeIsEditBookmarksEnabled(); + private static native boolean nativeIsEditBookmarksEnabled(Profile profile); /** * Simple object representing the bookmark item. diff --git a/chrome/browser/android/bookmarks/bookmarks_bridge.cc b/chrome/browser/android/bookmarks/bookmarks_bridge.cc index 1ea35d0c2d37..8a9a1f3b346f 100644 --- a/chrome/browser/android/bookmarks/bookmarks_bridge.cc +++ b/chrome/browser/android/bookmarks/bookmarks_bridge.cc @@ -15,7 +15,6 @@ #include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" -#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/undo/bookmark_undo_service.h" #include "chrome/browser/undo/bookmark_undo_service_factory.h" @@ -147,13 +146,15 @@ static jboolean IsEnhancedBookmarksFeatureEnabled(JNIEnv* env, return IsEnhancedBookmarksEnabled(profile->GetPrefs()); } -static bool IsEditBookmarksEnabled() { - return ProfileManager::GetLastUsedProfile()->GetPrefs()->GetBoolean( +static bool IsEditBookmarksEnabled(Profile* profile) { + return profile->GetPrefs()->GetBoolean( bookmarks::prefs::kEditBookmarksEnabled); } -static jboolean IsEditBookmarksEnabled(JNIEnv* env, jclass clazz) { - return IsEditBookmarksEnabled(); +static jboolean IsEditBookmarksEnabled(JNIEnv* env, + jclass clazz, + jobject j_profile) { + return IsEditBookmarksEnabled(ProfileAndroid::FromProfileAndroid(j_profile)); } void BookmarksBridge::LoadEmptyPartnerBookmarkShimForTesting(JNIEnv* env, @@ -808,7 +809,7 @@ bool BookmarksBridge::IsEditable(const BookmarkNode* node) const { node->type() != BookmarkNode::URL)) { return false; } - if (!IsEditBookmarksEnabled()) + if (!IsEditBookmarksEnabled(profile_)) return false; if (partner_bookmarks_shim_->IsPartnerBookmark(node)) return partner_bookmarks_shim_->IsEditable(node); -- 2.11.4.GIT