Upstream oodles of Chrome for Android code into Chromium.
[chromium-blink-merge.git] / chrome / browser / android / bookmark / edit_bookmark_helper.cc
blobc3f1341ed4413fa591ebd0e02a3bd23880395c22
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/bookmark/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 jclass clazz,
19 jobject jprofile,
20 jlong bookmark_id,
21 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);