OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/android/enhanced_bookmarks/enhanced_bookmarks_bridge.h" | 5 #include "chrome/browser/android/enhanced_bookmarks/enhanced_bookmarks_bridge.h" |
6 | 6 |
7 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 DCHECK(enhanced_bookmark_model_->loaded()); | 83 DCHECK(enhanced_bookmark_model_->loaded()); |
84 DCHECK_EQ(type, BookmarkType::BOOKMARK_TYPE_NORMAL); | 84 DCHECK_EQ(type, BookmarkType::BOOKMARK_TYPE_NORMAL); |
85 | 85 |
86 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID( | 86 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID( |
87 enhanced_bookmark_model_->bookmark_model(), static_cast<int64>(id)); | 87 enhanced_bookmark_model_->bookmark_model(), static_cast<int64>(id)); |
88 | 88 |
89 enhanced_bookmark_model_->SetDescription( | 89 enhanced_bookmark_model_->SetDescription( |
90 node, base::android::ConvertJavaStringToUTF8(env, description)); | 90 node, base::android::ConvertJavaStringToUTF8(env, description)); |
91 } | 91 } |
92 | 92 |
93 ScopedJavaLocalRef<jobjectArray> EnhancedBookmarksBridge::GetFiltersForBookmark( | |
94 JNIEnv* env, | |
95 jobject obj, | |
96 jlong id, | |
97 jint type) { | |
Ted C
2014/10/31 23:18:21
type isn't used, but it probably should be.
If it
Ian Wen
2014/10/31 23:46:23
Done.
| |
98 DCHECK(enhanced_bookmark_model_->loaded()); | |
99 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID( | |
100 enhanced_bookmark_model_->bookmark_model(), static_cast<int64>(id)); | |
101 std::vector<std::string> filters = | |
102 cluster_service_->ClustersForBookmark(node); | |
103 return base::android::ToJavaArrayOfStrings(env, filters); | |
104 } | |
105 | |
93 void EnhancedBookmarksBridge::GetBookmarksForFilter(JNIEnv* env, | 106 void EnhancedBookmarksBridge::GetBookmarksForFilter(JNIEnv* env, |
94 jobject obj, | 107 jobject obj, |
95 jstring j_filter, | 108 jstring j_filter, |
96 jobject j_result_obj) { | 109 jobject j_result_obj) { |
97 DCHECK(enhanced_bookmark_model_->loaded()); | 110 DCHECK(enhanced_bookmark_model_->loaded()); |
98 const std::string title = | 111 const std::string title = |
99 base::android::ConvertJavaStringToUTF8(env, j_filter); | 112 base::android::ConvertJavaStringToUTF8(env, j_filter); |
100 const std::vector<const BookmarkNode*> bookmarks = | 113 const std::vector<const BookmarkNode*> bookmarks = |
101 cluster_service_->BookmarksForClusterNamed(title); | 114 cluster_service_->BookmarksForClusterNamed(title); |
102 for (const BookmarkNode* node : bookmarks) { | 115 for (const BookmarkNode* node : bookmarks) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 return reinterpret_cast<jlong>(new EnhancedBookmarksBridge( | 255 return reinterpret_cast<jlong>(new EnhancedBookmarksBridge( |
243 env, obj, ProfileAndroid::FromProfileAndroid(j_profile))); | 256 env, obj, ProfileAndroid::FromProfileAndroid(j_profile))); |
244 } | 257 } |
245 | 258 |
246 bool RegisterEnhancedBookmarksBridge(JNIEnv* env) { | 259 bool RegisterEnhancedBookmarksBridge(JNIEnv* env) { |
247 return RegisterNativesImpl(env); | 260 return RegisterNativesImpl(env); |
248 } | 261 } |
249 | 262 |
250 } // namespace android | 263 } // namespace android |
251 } // namespace enhanced_bookmarks | 264 } // namespace enhanced_bookmarks |
OLD | NEW |