OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/bookmarks/bookmarks_bridge.h" | 5 #include "chrome/browser/android/bookmarks/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/containers/stack_container.h" | 9 #include "base/containers/stack_container.h" |
10 #include "base/i18n/string_compare.h" | 10 #include "base/i18n/string_compare.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 | 136 |
137 static jlong Init(JNIEnv* env, jobject obj, jobject j_profile) { | 137 static jlong Init(JNIEnv* env, jobject obj, jobject j_profile) { |
138 BookmarksBridge* delegate = new BookmarksBridge(env, obj, j_profile); | 138 BookmarksBridge* delegate = new BookmarksBridge(env, obj, j_profile); |
139 return reinterpret_cast<intptr_t>(delegate); | 139 return reinterpret_cast<intptr_t>(delegate); |
140 } | 140 } |
141 | 141 |
142 static jboolean IsEnhancedBookmarksFeatureEnabled(JNIEnv* env, | 142 static jboolean IsEnhancedBookmarksFeatureEnabled(JNIEnv* env, |
143 jclass clazz, | 143 jclass clazz, |
144 jobject j_profile) { | 144 jobject j_profile) { |
145 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); | 145 return IsEnhancedBookmarksEnabled(); |
146 return IsEnhancedBookmarksEnabled(profile->GetPrefs()); | |
147 } | 146 } |
148 | 147 |
149 static bool IsEditBookmarksEnabled(Profile* profile) { | 148 static bool IsEditBookmarksEnabled(Profile* profile) { |
150 return profile->GetPrefs()->GetBoolean( | 149 return profile->GetPrefs()->GetBoolean( |
151 bookmarks::prefs::kEditBookmarksEnabled); | 150 bookmarks::prefs::kEditBookmarksEnabled); |
152 } | 151 } |
153 | 152 |
154 static jboolean IsEditBookmarksEnabled(JNIEnv* env, | 153 static jboolean IsEditBookmarksEnabled(JNIEnv* env, |
155 jclass clazz, | 154 jclass clazz, |
156 jobject j_profile) { | 155 jobject j_profile) { |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 DCHECK(IsLoaded()); | 731 DCHECK(IsLoaded()); |
733 DCHECK(grouped_bookmark_actions_.get()); // should only call after start | 732 DCHECK(grouped_bookmark_actions_.get()); // should only call after start |
734 grouped_bookmark_actions_.reset(); | 733 grouped_bookmark_actions_.reset(); |
735 } | 734 } |
736 | 735 |
737 base::string16 BookmarksBridge::GetTitle(const BookmarkNode* node) const { | 736 base::string16 BookmarksBridge::GetTitle(const BookmarkNode* node) const { |
738 if (partner_bookmarks_shim_->IsPartnerBookmark(node)) | 737 if (partner_bookmarks_shim_->IsPartnerBookmark(node)) |
739 return partner_bookmarks_shim_->GetTitle(node); | 738 return partner_bookmarks_shim_->GetTitle(node); |
740 | 739 |
741 if (node == bookmark_model_->bookmark_bar_node() | 740 if (node == bookmark_model_->bookmark_bar_node() |
742 && IsEnhancedBookmarksEnabled(profile_->GetPrefs())) { | 741 && IsEnhancedBookmarksEnabled()) { |
743 return l10n_util::GetStringUTF16(IDS_ENHANCED_BOOKMARK_BAR_FOLDER_NAME); | 742 return l10n_util::GetStringUTF16(IDS_ENHANCED_BOOKMARK_BAR_FOLDER_NAME); |
744 } | 743 } |
745 | 744 |
746 return node->GetTitle(); | 745 return node->GetTitle(); |
747 } | 746 } |
748 | 747 |
749 ScopedJavaLocalRef<jobject> BookmarksBridge::CreateJavaBookmark( | 748 ScopedJavaLocalRef<jobject> BookmarksBridge::CreateJavaBookmark( |
750 const BookmarkNode* node) { | 749 const BookmarkNode* node) { |
751 JNIEnv* env = AttachCurrentThread(); | 750 JNIEnv* env = AttachCurrentThread(); |
752 | 751 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 BookmarkModelChanged(); | 1034 BookmarkModelChanged(); |
1036 } | 1035 } |
1037 | 1036 |
1038 void BookmarksBridge::PartnerShimLoaded(PartnerBookmarksShim* shim) { | 1037 void BookmarksBridge::PartnerShimLoaded(PartnerBookmarksShim* shim) { |
1039 NotifyIfDoneLoading(); | 1038 NotifyIfDoneLoading(); |
1040 } | 1039 } |
1041 | 1040 |
1042 void BookmarksBridge::ShimBeingDeleted(PartnerBookmarksShim* shim) { | 1041 void BookmarksBridge::ShimBeingDeleted(PartnerBookmarksShim* shim) { |
1043 partner_bookmarks_shim_ = NULL; | 1042 partner_bookmarks_shim_ = NULL; |
1044 } | 1043 } |
OLD | NEW |