Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / android / bookmarks / edit_bookmark_helper.cc
blob6b94576bae3f7472e81d1e4d9d68a5702fef1982
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
3 // found in the LICENSE file.
5 #include "chrome/browser/android/bookmarks/edit_bookmark_helper.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h"
10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_android.h"
13 #include "jni/EditBookmarkHelper_jni.h"
15 using bookmarks::BookmarkNode;
17 void SetPartnerBookmarkTitle(JNIEnv* env,
18 const JavaParamRef<jclass>& clazz,
19 const JavaParamRef<jobject>& jprofile,
20 jlong bookmark_id,
21 const JavaParamRef<jstring>& new_title) {
22 PartnerBookmarksShim* partner_bookmarks_shim =
23 PartnerBookmarksShim::BuildForBrowserContext(
24 chrome::GetBrowserContextRedirectedInIncognito(
25 ProfileAndroid::FromProfileAndroid(jprofile)));
26 if (!partner_bookmarks_shim)
27 return;
29 const BookmarkNode* node = partner_bookmarks_shim->GetNodeByID(bookmark_id);
30 if (!node)
31 return;
33 partner_bookmarks_shim->RenameBookmark(
34 node,
35 base::android::ConvertJavaStringToUTF16(env, new_title));
38 // static
39 bool RegisterEditBookmarkHelper(JNIEnv* env) {
40 return RegisterNativesImpl(env);