| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/provider/chrome_browser_provider.h" | 5 #include "chrome/browser/android/provider/chrome_browser_provider.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 140 } |
| 141 | 141 |
| 142 jint ConvertJIntegerToJint(JNIEnv* env, jobject integer_obj) { | 142 jint ConvertJIntegerToJint(JNIEnv* env, jobject integer_obj) { |
| 143 ScopedJavaLocalRef<jclass> jinteger_clazz = | 143 ScopedJavaLocalRef<jclass> jinteger_clazz = |
| 144 GetClass(env, "java/lang/Integer"); | 144 GetClass(env, "java/lang/Integer"); |
| 145 jmethodID int_value = MethodID::Get<MethodID::TYPE_INSTANCE>( | 145 jmethodID int_value = MethodID::Get<MethodID::TYPE_INSTANCE>( |
| 146 env, jinteger_clazz.obj(), "intValue", "()I"); | 146 env, jinteger_clazz.obj(), "intValue", "()I"); |
| 147 return env->CallIntMethod(integer_obj, int_value, NULL); | 147 return env->CallIntMethod(integer_obj, int_value, NULL); |
| 148 } | 148 } |
| 149 | 149 |
| 150 std::vector<string16> ConvertJStringArrayToString16Array(JNIEnv* env, | 150 std::vector<base::string16> ConvertJStringArrayToString16Array( |
| 151 jobjectArray array) { | 151 JNIEnv* env, |
| 152 std::vector<string16> results; | 152 jobjectArray array) { |
| 153 std::vector<base::string16> results; |
| 153 if (array) { | 154 if (array) { |
| 154 jsize len = env->GetArrayLength(array); | 155 jsize len = env->GetArrayLength(array); |
| 155 for (int i = 0; i < len; i++) { | 156 for (int i = 0; i < len; i++) { |
| 156 results.push_back(ConvertJavaStringToUTF16(env, | 157 results.push_back(ConvertJavaStringToUTF16(env, |
| 157 static_cast<jstring>(env->GetObjectArrayElement(array, i)))); | 158 static_cast<jstring>(env->GetObjectArrayElement(array, i)))); |
| 158 } | 159 } |
| 159 } | 160 } |
| 160 return results; | 161 return results; |
| 161 } | 162 } |
| 162 | 163 |
| 163 // ------------- Utility methods used by tasks ------------- // | 164 // ------------- Utility methods used by tasks ------------- // |
| 164 | 165 |
| 165 // Parse the given url and return a GURL, appending the default scheme | 166 // Parse the given url and return a GURL, appending the default scheme |
| 166 // if one is not present. | 167 // if one is not present. |
| 167 GURL ParseAndMaybeAppendScheme(const string16& url, | 168 GURL ParseAndMaybeAppendScheme(const base::string16& url, |
| 168 const char* default_scheme) { | 169 const char* default_scheme) { |
| 169 GURL gurl(url); | 170 GURL gurl(url); |
| 170 if (!gurl.is_valid() && !gurl.has_scheme()) { | 171 if (!gurl.is_valid() && !gurl.has_scheme()) { |
| 171 string16 refined_url(ASCIIToUTF16(default_scheme)); | 172 base::string16 refined_url(ASCIIToUTF16(default_scheme)); |
| 172 refined_url.append(url); | 173 refined_url.append(url); |
| 173 gurl = GURL(refined_url); | 174 gurl = GURL(refined_url); |
| 174 } | 175 } |
| 175 return gurl; | 176 return gurl; |
| 176 } | 177 } |
| 177 | 178 |
| 178 const BookmarkNode* GetChildFolderByTitle(const BookmarkNode* parent, | 179 const BookmarkNode* GetChildFolderByTitle(const BookmarkNode* parent, |
| 179 const string16& title) { | 180 const base::string16& title) { |
| 180 for (int i = 0; i < parent->child_count(); ++i) { | 181 for (int i = 0; i < parent->child_count(); ++i) { |
| 181 if (parent->GetChild(i)->is_folder() && | 182 if (parent->GetChild(i)->is_folder() && |
| 182 parent->GetChild(i)->GetTitle() == title) { | 183 parent->GetChild(i)->GetTitle() == title) { |
| 183 return parent->GetChild(i); | 184 return parent->GetChild(i); |
| 184 } | 185 } |
| 185 } | 186 } |
| 186 return NULL; | 187 return NULL; |
| 187 } | 188 } |
| 188 | 189 |
| 189 // ------------- Synchronous task classes ------------- // | 190 // ------------- Synchronous task classes ------------- // |
| 190 | 191 |
| 191 // Utility task to add a bookmark. | 192 // Utility task to add a bookmark. |
| 192 class AddBookmarkTask : public BookmarkModelTask { | 193 class AddBookmarkTask : public BookmarkModelTask { |
| 193 public: | 194 public: |
| 194 explicit AddBookmarkTask(BookmarkModel* model) : BookmarkModelTask(model) {} | 195 explicit AddBookmarkTask(BookmarkModel* model) : BookmarkModelTask(model) {} |
| 195 | 196 |
| 196 int64 Run(const string16& title, | 197 int64 Run(const base::string16& title, |
| 197 const string16& url, | 198 const base::string16& url, |
| 198 const bool is_folder, | 199 const bool is_folder, |
| 199 const int64 parent_id) { | 200 const int64 parent_id) { |
| 200 int64 result = kInvalidBookmarkId; | 201 int64 result = kInvalidBookmarkId; |
| 201 RunOnUIThreadBlocking::Run( | 202 RunOnUIThreadBlocking::Run( |
| 202 base::Bind(&AddBookmarkTask::RunOnUIThread, | 203 base::Bind(&AddBookmarkTask::RunOnUIThread, |
| 203 model(), title, url, is_folder, parent_id, &result)); | 204 model(), title, url, is_folder, parent_id, &result)); |
| 204 return result; | 205 return result; |
| 205 } | 206 } |
| 206 | 207 |
| 207 static void RunOnUIThread(BookmarkModel* model, | 208 static void RunOnUIThread(BookmarkModel* model, |
| 208 const string16& title, | 209 const base::string16& title, |
| 209 const string16& url, | 210 const base::string16& url, |
| 210 const bool is_folder, | 211 const bool is_folder, |
| 211 const int64 parent_id, | 212 const int64 parent_id, |
| 212 int64* result) { | 213 int64* result) { |
| 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 214 DCHECK(result); | 215 DCHECK(result); |
| 215 GURL gurl = ParseAndMaybeAppendScheme(url, kDefaultUrlScheme); | 216 GURL gurl = ParseAndMaybeAppendScheme(url, kDefaultUrlScheme); |
| 216 | 217 |
| 217 // Check if the bookmark already exists. | 218 // Check if the bookmark already exists. |
| 218 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(gurl); | 219 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(gurl); |
| 219 if (!node) { | 220 if (!node) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 // Utility method to update a bookmark. | 303 // Utility method to update a bookmark. |
| 303 class UpdateBookmarkTask : public BookmarkModelObserverTask { | 304 class UpdateBookmarkTask : public BookmarkModelObserverTask { |
| 304 public: | 305 public: |
| 305 explicit UpdateBookmarkTask(BookmarkModel* model) | 306 explicit UpdateBookmarkTask(BookmarkModel* model) |
| 306 : BookmarkModelObserverTask(model), | 307 : BookmarkModelObserverTask(model), |
| 307 updated_(0), | 308 updated_(0), |
| 308 id_to_update_(kInvalidBookmarkId){} | 309 id_to_update_(kInvalidBookmarkId){} |
| 309 virtual ~UpdateBookmarkTask() {} | 310 virtual ~UpdateBookmarkTask() {} |
| 310 | 311 |
| 311 int Run(const int64 id, | 312 int Run(const int64 id, |
| 312 const string16& title, | 313 const base::string16& title, |
| 313 const string16& url, | 314 const base::string16& url, |
| 314 const int64 parent_id) { | 315 const int64 parent_id) { |
| 315 id_to_update_ = id; | 316 id_to_update_ = id; |
| 316 RunOnUIThreadBlocking::Run( | 317 RunOnUIThreadBlocking::Run( |
| 317 base::Bind(&UpdateBookmarkTask::RunOnUIThread, | 318 base::Bind(&UpdateBookmarkTask::RunOnUIThread, |
| 318 model(), id, title, url, parent_id)); | 319 model(), id, title, url, parent_id)); |
| 319 return updated_; | 320 return updated_; |
| 320 } | 321 } |
| 321 | 322 |
| 322 static void RunOnUIThread(BookmarkModel* model, | 323 static void RunOnUIThread(BookmarkModel* model, |
| 323 const int64 id, | 324 const int64 id, |
| 324 const string16& title, | 325 const base::string16& title, |
| 325 const string16& url, | 326 const base::string16& url, |
| 326 const int64 parent_id) { | 327 const int64 parent_id) { |
| 327 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 328 const BookmarkNode* node = model->GetNodeByID(id); | 329 const BookmarkNode* node = model->GetNodeByID(id); |
| 329 if (node) { | 330 if (node) { |
| 330 if (node->GetTitle() != title) | 331 if (node->GetTitle() != title) |
| 331 model->SetTitle(node, title); | 332 model->SetTitle(node, title); |
| 332 | 333 |
| 333 if (node->type() == BookmarkNode::URL) { | 334 if (node->type() == BookmarkNode::URL) { |
| 334 GURL bookmark_url = ParseAndMaybeAppendScheme(url, kDefaultUrlScheme); | 335 GURL bookmark_url = ParseAndMaybeAppendScheme(url, kDefaultUrlScheme); |
| 335 if (bookmark_url != node->url()) | 336 if (bookmark_url != node->url()) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 }; | 420 }; |
| 420 | 421 |
| 421 // Creates folder or retrieves its id if already exists. | 422 // Creates folder or retrieves its id if already exists. |
| 422 // An invalid parent id is assumed to represent the Mobile Bookmarks folder. | 423 // An invalid parent id is assumed to represent the Mobile Bookmarks folder. |
| 423 // Can only be used to create folders inside the Mobile Bookmarks branch. | 424 // Can only be used to create folders inside the Mobile Bookmarks branch. |
| 424 class CreateBookmarksFolderOnceTask : public BookmarkModelTask { | 425 class CreateBookmarksFolderOnceTask : public BookmarkModelTask { |
| 425 public: | 426 public: |
| 426 explicit CreateBookmarksFolderOnceTask(BookmarkModel* model) | 427 explicit CreateBookmarksFolderOnceTask(BookmarkModel* model) |
| 427 : BookmarkModelTask(model) {} | 428 : BookmarkModelTask(model) {} |
| 428 | 429 |
| 429 int64 Run(const string16& title, const int64 parent_id) { | 430 int64 Run(const base::string16& title, const int64 parent_id) { |
| 430 int64 result = kInvalidBookmarkId; | 431 int64 result = kInvalidBookmarkId; |
| 431 RunOnUIThreadBlocking::Run( | 432 RunOnUIThreadBlocking::Run( |
| 432 base::Bind(&CreateBookmarksFolderOnceTask::RunOnUIThread, | 433 base::Bind(&CreateBookmarksFolderOnceTask::RunOnUIThread, |
| 433 model(), title, parent_id, &result)); | 434 model(), title, parent_id, &result)); |
| 434 return result; | 435 return result; |
| 435 } | 436 } |
| 436 | 437 |
| 437 static void RunOnUIThread(BookmarkModel* model, | 438 static void RunOnUIThread(BookmarkModel* model, |
| 438 const string16& title, | 439 const base::string16& title, |
| 439 const int64 parent_id, | 440 const int64 parent_id, |
| 440 int64* result) { | 441 int64* result) { |
| 441 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 442 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 442 DCHECK(result); | 443 DCHECK(result); |
| 443 | 444 |
| 444 // Invalid ids are assumed to refer to the Mobile Bookmarks folder. | 445 // Invalid ids are assumed to refer to the Mobile Bookmarks folder. |
| 445 const BookmarkNode* parent = parent_id >= 0 ? | 446 const BookmarkNode* parent = parent_id >= 0 ? |
| 446 model->GetNodeByID(parent_id) : model->mobile_node(); | 447 model->GetNodeByID(parent_id) : model->mobile_node(); |
| 447 DCHECK(parent); | 448 DCHECK(parent); |
| 448 | 449 |
| 449 bool in_mobile_bookmarks; | 450 bool in_mobile_bookmarks; |
| 450 IsInMobileBookmarksBranchTask::RunOnUIThread(model, parent->id(), | 451 IsInMobileBookmarksBranchTask::RunOnUIThread(model, parent->id(), |
| 451 &in_mobile_bookmarks); | 452 &in_mobile_bookmarks); |
| 452 if (!in_mobile_bookmarks) { | 453 if (!in_mobile_bookmarks) { |
| 453 // The parent folder must be inside the Mobile Bookmarks folder. | 454 // The parent folder must be inside the Mobile Bookmarks folder. |
| 454 *result = kInvalidBookmarkId; | 455 *result = kInvalidBookmarkId; |
| 455 return; | 456 return; |
| 456 } | 457 } |
| 457 | 458 |
| 458 const BookmarkNode* node = GetChildFolderByTitle(parent, title); | 459 const BookmarkNode* node = GetChildFolderByTitle(parent, title); |
| 459 if (node) { | 460 if (node) { |
| 460 *result = node->id(); | 461 *result = node->id(); |
| 461 return; | 462 return; |
| 462 } | 463 } |
| 463 | 464 |
| 464 AddBookmarkTask::RunOnUIThread(model, title, string16(), true, | 465 AddBookmarkTask::RunOnUIThread(model, title, base::string16(), true, |
| 465 parent->id(), result); | 466 parent->id(), result); |
| 466 } | 467 } |
| 467 | 468 |
| 468 private: | 469 private: |
| 469 DISALLOW_COPY_AND_ASSIGN(CreateBookmarksFolderOnceTask); | 470 DISALLOW_COPY_AND_ASSIGN(CreateBookmarksFolderOnceTask); |
| 470 }; | 471 }; |
| 471 | 472 |
| 472 // Creates a Java BookmarkNode object for a node given its id. | 473 // Creates a Java BookmarkNode object for a node given its id. |
| 473 class GetAllBookmarkFoldersTask : public BookmarkModelTask { | 474 class GetAllBookmarkFoldersTask : public BookmarkModelTask { |
| 474 public: | 475 public: |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 class QueryBookmarksFromAPITask : public HistoryProviderTask { | 745 class QueryBookmarksFromAPITask : public HistoryProviderTask { |
| 745 public: | 746 public: |
| 746 QueryBookmarksFromAPITask(AndroidHistoryProviderService* service, | 747 QueryBookmarksFromAPITask(AndroidHistoryProviderService* service, |
| 747 CancelableRequestConsumer* cancelable_consumer) | 748 CancelableRequestConsumer* cancelable_consumer) |
| 748 : HistoryProviderTask(service, cancelable_consumer), | 749 : HistoryProviderTask(service, cancelable_consumer), |
| 749 result_(NULL) {} | 750 result_(NULL) {} |
| 750 | 751 |
| 751 history::AndroidStatement* Run( | 752 history::AndroidStatement* Run( |
| 752 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, | 753 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, |
| 753 const std::string& selection, | 754 const std::string& selection, |
| 754 const std::vector<string16>& selection_args, | 755 const std::vector<base::string16>& selection_args, |
| 755 const std::string& sort_order) { | 756 const std::string& sort_order) { |
| 756 RunAsyncRequestOnUIThreadBlocking( | 757 RunAsyncRequestOnUIThreadBlocking( |
| 757 base::Bind(&AndroidHistoryProviderService::QueryHistoryAndBookmarks, | 758 base::Bind(&AndroidHistoryProviderService::QueryHistoryAndBookmarks, |
| 758 base::Unretained(service()), projections, selection, | 759 base::Unretained(service()), projections, selection, |
| 759 selection_args, sort_order, cancelable_consumer(), | 760 selection_args, sort_order, cancelable_consumer(), |
| 760 base::Bind(&QueryBookmarksFromAPITask::OnBookmarksQueried, | 761 base::Bind(&QueryBookmarksFromAPITask::OnBookmarksQueried, |
| 761 base::Unretained(this)))); | 762 base::Unretained(this)))); |
| 762 return result_; | 763 return result_; |
| 763 } | 764 } |
| 764 | 765 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 778 // Updates bookmarks from the API. | 779 // Updates bookmarks from the API. |
| 779 class UpdateBookmarksFromAPITask : public HistoryProviderTask { | 780 class UpdateBookmarksFromAPITask : public HistoryProviderTask { |
| 780 public: | 781 public: |
| 781 UpdateBookmarksFromAPITask(AndroidHistoryProviderService* service, | 782 UpdateBookmarksFromAPITask(AndroidHistoryProviderService* service, |
| 782 CancelableRequestConsumer* cancelable_consumer) | 783 CancelableRequestConsumer* cancelable_consumer) |
| 783 : HistoryProviderTask(service, cancelable_consumer), | 784 : HistoryProviderTask(service, cancelable_consumer), |
| 784 result_(0) {} | 785 result_(0) {} |
| 785 | 786 |
| 786 int Run(const history::HistoryAndBookmarkRow& row, | 787 int Run(const history::HistoryAndBookmarkRow& row, |
| 787 const std::string& selection, | 788 const std::string& selection, |
| 788 const std::vector<string16>& selection_args) { | 789 const std::vector<base::string16>& selection_args) { |
| 789 RunAsyncRequestOnUIThreadBlocking( | 790 RunAsyncRequestOnUIThreadBlocking( |
| 790 base::Bind(&AndroidHistoryProviderService::UpdateHistoryAndBookmarks, | 791 base::Bind(&AndroidHistoryProviderService::UpdateHistoryAndBookmarks, |
| 791 base::Unretained(service()), row, selection, | 792 base::Unretained(service()), row, selection, |
| 792 selection_args, cancelable_consumer(), | 793 selection_args, cancelable_consumer(), |
| 793 base::Bind(&UpdateBookmarksFromAPITask::OnBookmarksUpdated, | 794 base::Bind(&UpdateBookmarksFromAPITask::OnBookmarksUpdated, |
| 794 base::Unretained(this)))); | 795 base::Unretained(this)))); |
| 795 return result_; | 796 return result_; |
| 796 } | 797 } |
| 797 | 798 |
| 798 private: | 799 private: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 810 | 811 |
| 811 // Removes bookmarks from the API. | 812 // Removes bookmarks from the API. |
| 812 class RemoveBookmarksFromAPITask : public HistoryProviderTask { | 813 class RemoveBookmarksFromAPITask : public HistoryProviderTask { |
| 813 public: | 814 public: |
| 814 RemoveBookmarksFromAPITask(AndroidHistoryProviderService* service, | 815 RemoveBookmarksFromAPITask(AndroidHistoryProviderService* service, |
| 815 CancelableRequestConsumer* cancelable_consumer) | 816 CancelableRequestConsumer* cancelable_consumer) |
| 816 : HistoryProviderTask(service, cancelable_consumer), | 817 : HistoryProviderTask(service, cancelable_consumer), |
| 817 result_(0) {} | 818 result_(0) {} |
| 818 | 819 |
| 819 int Run(const std::string& selection, | 820 int Run(const std::string& selection, |
| 820 const std::vector<string16>& selection_args) { | 821 const std::vector<base::string16>& selection_args) { |
| 821 RunAsyncRequestOnUIThreadBlocking( | 822 RunAsyncRequestOnUIThreadBlocking( |
| 822 base::Bind(&AndroidHistoryProviderService::DeleteHistoryAndBookmarks, | 823 base::Bind(&AndroidHistoryProviderService::DeleteHistoryAndBookmarks, |
| 823 base::Unretained(service()), selection, selection_args, | 824 base::Unretained(service()), selection, selection_args, |
| 824 cancelable_consumer(), | 825 cancelable_consumer(), |
| 825 base::Bind(&RemoveBookmarksFromAPITask::OnBookmarksRemoved, | 826 base::Bind(&RemoveBookmarksFromAPITask::OnBookmarksRemoved, |
| 826 base::Unretained(this)))); | 827 base::Unretained(this)))); |
| 827 return result_; | 828 return result_; |
| 828 } | 829 } |
| 829 | 830 |
| 830 private: | 831 private: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 842 | 843 |
| 843 // Removes history from the API. | 844 // Removes history from the API. |
| 844 class RemoveHistoryFromAPITask : public HistoryProviderTask { | 845 class RemoveHistoryFromAPITask : public HistoryProviderTask { |
| 845 public: | 846 public: |
| 846 RemoveHistoryFromAPITask(AndroidHistoryProviderService* service, | 847 RemoveHistoryFromAPITask(AndroidHistoryProviderService* service, |
| 847 CancelableRequestConsumer* cancelable_consumer) | 848 CancelableRequestConsumer* cancelable_consumer) |
| 848 : HistoryProviderTask(service, cancelable_consumer), | 849 : HistoryProviderTask(service, cancelable_consumer), |
| 849 result_(0) {} | 850 result_(0) {} |
| 850 | 851 |
| 851 int Run(const std::string& selection, | 852 int Run(const std::string& selection, |
| 852 const std::vector<string16>& selection_args) { | 853 const std::vector<base::string16>& selection_args) { |
| 853 RunAsyncRequestOnUIThreadBlocking( | 854 RunAsyncRequestOnUIThreadBlocking( |
| 854 base::Bind(&AndroidHistoryProviderService::DeleteHistory, | 855 base::Bind(&AndroidHistoryProviderService::DeleteHistory, |
| 855 base::Unretained(service()), selection, | 856 base::Unretained(service()), selection, |
| 856 selection_args, cancelable_consumer(), | 857 selection_args, cancelable_consumer(), |
| 857 base::Bind(&RemoveHistoryFromAPITask::OnHistoryRemoved, | 858 base::Bind(&RemoveHistoryFromAPITask::OnHistoryRemoved, |
| 858 base::Unretained(this)))); | 859 base::Unretained(this)))); |
| 859 return result_; | 860 return result_; |
| 860 } | 861 } |
| 861 | 862 |
| 862 private: | 863 private: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 public: | 955 public: |
| 955 QuerySearchTermsFromAPITask(AndroidHistoryProviderService* service, | 956 QuerySearchTermsFromAPITask(AndroidHistoryProviderService* service, |
| 956 CancelableRequestConsumer* cancelable_consumer, | 957 CancelableRequestConsumer* cancelable_consumer, |
| 957 Profile* profile) | 958 Profile* profile) |
| 958 : SearchTermTask(service, cancelable_consumer, profile), | 959 : SearchTermTask(service, cancelable_consumer, profile), |
| 959 result_(NULL) {} | 960 result_(NULL) {} |
| 960 | 961 |
| 961 history::AndroidStatement* Run( | 962 history::AndroidStatement* Run( |
| 962 const std::vector<history::SearchRow::ColumnID>& projections, | 963 const std::vector<history::SearchRow::ColumnID>& projections, |
| 963 const std::string& selection, | 964 const std::string& selection, |
| 964 const std::vector<string16>& selection_args, | 965 const std::vector<base::string16>& selection_args, |
| 965 const std::string& sort_order) { | 966 const std::string& sort_order) { |
| 966 RunAsyncRequestOnUIThreadBlocking( | 967 RunAsyncRequestOnUIThreadBlocking( |
| 967 base::Bind(&AndroidHistoryProviderService::QuerySearchTerms, | 968 base::Bind(&AndroidHistoryProviderService::QuerySearchTerms, |
| 968 base::Unretained(service()), projections, selection, | 969 base::Unretained(service()), projections, selection, |
| 969 selection_args, sort_order, cancelable_consumer(), | 970 selection_args, sort_order, cancelable_consumer(), |
| 970 base::Bind( | 971 base::Bind( |
| 971 &QuerySearchTermsFromAPITask::OnSearchTermsQueried, | 972 &QuerySearchTermsFromAPITask::OnSearchTermsQueried, |
| 972 base::Unretained(this)))); | 973 base::Unretained(this)))); |
| 973 return result_; | 974 return result_; |
| 974 } | 975 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 991 class UpdateSearchTermsFromAPITask : public SearchTermTask { | 992 class UpdateSearchTermsFromAPITask : public SearchTermTask { |
| 992 public: | 993 public: |
| 993 UpdateSearchTermsFromAPITask(AndroidHistoryProviderService* service, | 994 UpdateSearchTermsFromAPITask(AndroidHistoryProviderService* service, |
| 994 CancelableRequestConsumer* cancelable_consumer, | 995 CancelableRequestConsumer* cancelable_consumer, |
| 995 Profile* profile) | 996 Profile* profile) |
| 996 : SearchTermTask(service, cancelable_consumer, profile), | 997 : SearchTermTask(service, cancelable_consumer, profile), |
| 997 result_(0) {} | 998 result_(0) {} |
| 998 | 999 |
| 999 int Run(const history::SearchRow& row, | 1000 int Run(const history::SearchRow& row, |
| 1000 const std::string& selection, | 1001 const std::string& selection, |
| 1001 const std::vector<string16>& selection_args) { | 1002 const std::vector<base::string16>& selection_args) { |
| 1002 RunAsyncRequestOnUIThreadBlocking( | 1003 RunAsyncRequestOnUIThreadBlocking( |
| 1003 base::Bind(&UpdateSearchTermsFromAPITask::MakeRequestOnUIThread, | 1004 base::Bind(&UpdateSearchTermsFromAPITask::MakeRequestOnUIThread, |
| 1004 base::Unretained(this), row, selection, selection_args)); | 1005 base::Unretained(this), row, selection, selection_args)); |
| 1005 return result_; | 1006 return result_; |
| 1006 } | 1007 } |
| 1007 | 1008 |
| 1008 private: | 1009 private: |
| 1009 void MakeRequestOnUIThread(const history::SearchRow& row, | 1010 void MakeRequestOnUIThread( |
| 1010 const std::string& selection, | 1011 const history::SearchRow& row, |
| 1011 const std::vector<string16>& selection_args) { | 1012 const std::string& selection, |
| 1013 const std::vector<base::string16>& selection_args) { |
| 1012 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1014 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1013 history::SearchRow internal_row = row; | 1015 history::SearchRow internal_row = row; |
| 1014 BuildSearchRow(&internal_row); | 1016 BuildSearchRow(&internal_row); |
| 1015 service()->UpdateSearchTerms( | 1017 service()->UpdateSearchTerms( |
| 1016 internal_row, | 1018 internal_row, |
| 1017 selection, | 1019 selection, |
| 1018 selection_args, | 1020 selection_args, |
| 1019 cancelable_consumer(), | 1021 cancelable_consumer(), |
| 1020 base::Bind(&UpdateSearchTermsFromAPITask::OnSearchTermsUpdated, | 1022 base::Bind(&UpdateSearchTermsFromAPITask::OnSearchTermsUpdated, |
| 1021 base::Unretained(this))); | 1023 base::Unretained(this))); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1036 | 1038 |
| 1037 // Removes search terms from the API. | 1039 // Removes search terms from the API. |
| 1038 class RemoveSearchTermsFromAPITask : public SearchTermTask { | 1040 class RemoveSearchTermsFromAPITask : public SearchTermTask { |
| 1039 public: | 1041 public: |
| 1040 RemoveSearchTermsFromAPITask(AndroidHistoryProviderService* service, | 1042 RemoveSearchTermsFromAPITask(AndroidHistoryProviderService* service, |
| 1041 CancelableRequestConsumer* cancelable_consumer, | 1043 CancelableRequestConsumer* cancelable_consumer, |
| 1042 Profile* profile) | 1044 Profile* profile) |
| 1043 : SearchTermTask(service, cancelable_consumer, profile), result_() {} | 1045 : SearchTermTask(service, cancelable_consumer, profile), result_() {} |
| 1044 | 1046 |
| 1045 int Run(const std::string& selection, | 1047 int Run(const std::string& selection, |
| 1046 const std::vector<string16>& selection_args) { | 1048 const std::vector<base::string16>& selection_args) { |
| 1047 RunAsyncRequestOnUIThreadBlocking( | 1049 RunAsyncRequestOnUIThreadBlocking( |
| 1048 base::Bind(&AndroidHistoryProviderService::DeleteSearchTerms, | 1050 base::Bind(&AndroidHistoryProviderService::DeleteSearchTerms, |
| 1049 base::Unretained(service()), selection, selection_args, | 1051 base::Unretained(service()), selection, selection_args, |
| 1050 cancelable_consumer(), | 1052 cancelable_consumer(), |
| 1051 base::Bind( | 1053 base::Bind( |
| 1052 &RemoveSearchTermsFromAPITask::OnSearchTermsDeleted, | 1054 &RemoveSearchTermsFromAPITask::OnSearchTermsDeleted, |
| 1053 base::Unretained(this)))); | 1055 base::Unretained(this)))); |
| 1054 return result_; | 1056 return result_; |
| 1055 } | 1057 } |
| 1056 | 1058 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1079 jbyteArray favicon, | 1081 jbyteArray favicon, |
| 1080 jstring title, | 1082 jstring title, |
| 1081 jobject visits, | 1083 jobject visits, |
| 1082 jlong parent_id, | 1084 jlong parent_id, |
| 1083 history::HistoryAndBookmarkRow* row, | 1085 history::HistoryAndBookmarkRow* row, |
| 1084 BookmarkModel* model) { | 1086 BookmarkModel* model) { |
| 1085 // Needed because of the internal bookmark model task invocation. | 1087 // Needed because of the internal bookmark model task invocation. |
| 1086 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1088 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1087 | 1089 |
| 1088 if (url) { | 1090 if (url) { |
| 1089 string16 raw_url = ConvertJavaStringToUTF16(env, url); | 1091 base::string16 raw_url = ConvertJavaStringToUTF16(env, url); |
| 1090 // GURL doesn't accept the URL without protocol, but the Android CTS | 1092 // GURL doesn't accept the URL without protocol, but the Android CTS |
| 1091 // allows it. We are trying to prefix with 'http://' to see whether | 1093 // allows it. We are trying to prefix with 'http://' to see whether |
| 1092 // GURL thinks it is a valid URL. The original url will be stored in | 1094 // GURL thinks it is a valid URL. The original url will be stored in |
| 1093 // history::BookmarkRow.raw_url_. | 1095 // history::BookmarkRow.raw_url_. |
| 1094 GURL gurl = ParseAndMaybeAppendScheme(raw_url, kDefaultUrlScheme); | 1096 GURL gurl = ParseAndMaybeAppendScheme(raw_url, kDefaultUrlScheme); |
| 1095 row->set_url(gurl); | 1097 row->set_url(gurl); |
| 1096 row->set_raw_url(UTF16ToUTF8(raw_url)); | 1098 row->set_raw_url(UTF16ToUTF8(raw_url)); |
| 1097 } | 1099 } |
| 1098 | 1100 |
| 1099 if (created) | 1101 if (created) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 } | 1189 } |
| 1188 | 1190 |
| 1189 // ------------- Provider public APIs ------------- // | 1191 // ------------- Provider public APIs ------------- // |
| 1190 | 1192 |
| 1191 jlong ChromeBrowserProvider::AddBookmark(JNIEnv* env, | 1193 jlong ChromeBrowserProvider::AddBookmark(JNIEnv* env, |
| 1192 jobject, | 1194 jobject, |
| 1193 jstring jurl, | 1195 jstring jurl, |
| 1194 jstring jtitle, | 1196 jstring jtitle, |
| 1195 jboolean is_folder, | 1197 jboolean is_folder, |
| 1196 jlong parent_id) { | 1198 jlong parent_id) { |
| 1197 string16 url; | 1199 base::string16 url; |
| 1198 if (jurl) | 1200 if (jurl) |
| 1199 url = ConvertJavaStringToUTF16(env, jurl); | 1201 url = ConvertJavaStringToUTF16(env, jurl); |
| 1200 string16 title = ConvertJavaStringToUTF16(env, jtitle); | 1202 base::string16 title = ConvertJavaStringToUTF16(env, jtitle); |
| 1201 | 1203 |
| 1202 AddBookmarkTask task(bookmark_model_); | 1204 AddBookmarkTask task(bookmark_model_); |
| 1203 return task.Run(title, url, is_folder, parent_id); | 1205 return task.Run(title, url, is_folder, parent_id); |
| 1204 } | 1206 } |
| 1205 | 1207 |
| 1206 jint ChromeBrowserProvider::RemoveBookmark(JNIEnv*, jobject, jlong id) { | 1208 jint ChromeBrowserProvider::RemoveBookmark(JNIEnv*, jobject, jlong id) { |
| 1207 RemoveBookmarkTask task(bookmark_model_); | 1209 RemoveBookmarkTask task(bookmark_model_); |
| 1208 return task.Run(id); | 1210 return task.Run(id); |
| 1209 } | 1211 } |
| 1210 | 1212 |
| 1211 jint ChromeBrowserProvider::UpdateBookmark(JNIEnv* env, | 1213 jint ChromeBrowserProvider::UpdateBookmark(JNIEnv* env, |
| 1212 jobject, | 1214 jobject, |
| 1213 jlong id, | 1215 jlong id, |
| 1214 jstring jurl, | 1216 jstring jurl, |
| 1215 jstring jtitle, | 1217 jstring jtitle, |
| 1216 jlong parent_id) { | 1218 jlong parent_id) { |
| 1217 string16 url; | 1219 base::string16 url; |
| 1218 if (jurl) | 1220 if (jurl) |
| 1219 url = ConvertJavaStringToUTF16(env, jurl); | 1221 url = ConvertJavaStringToUTF16(env, jurl); |
| 1220 string16 title = ConvertJavaStringToUTF16(env, jtitle); | 1222 base::string16 title = ConvertJavaStringToUTF16(env, jtitle); |
| 1221 | 1223 |
| 1222 UpdateBookmarkTask task(bookmark_model_); | 1224 UpdateBookmarkTask task(bookmark_model_); |
| 1223 return task.Run(id, title, url, parent_id); | 1225 return task.Run(id, title, url, parent_id); |
| 1224 } | 1226 } |
| 1225 | 1227 |
| 1226 // Add the bookmark with the given column values. | 1228 // Add the bookmark with the given column values. |
| 1227 jlong ChromeBrowserProvider::AddBookmarkFromAPI(JNIEnv* env, | 1229 jlong ChromeBrowserProvider::AddBookmarkFromAPI(JNIEnv* env, |
| 1228 jobject obj, | 1230 jobject obj, |
| 1229 jstring url, | 1231 jstring url, |
| 1230 jobject created, | 1232 jobject created, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 if (id == history::HistoryAndBookmarkRow::COLUMN_END) { | 1274 if (id == history::HistoryAndBookmarkRow::COLUMN_END) { |
| 1273 // Ignore the unknown column; As Android platform will send us | 1275 // Ignore the unknown column; As Android platform will send us |
| 1274 // the non public column. | 1276 // the non public column. |
| 1275 continue; | 1277 continue; |
| 1276 } | 1278 } |
| 1277 query_columns.push_back(id); | 1279 query_columns.push_back(id); |
| 1278 columns_name.push_back(name); | 1280 columns_name.push_back(name); |
| 1279 } | 1281 } |
| 1280 } | 1282 } |
| 1281 | 1283 |
| 1282 std::vector<string16> where_args = | 1284 std::vector<base::string16> where_args = |
| 1283 ConvertJStringArrayToString16Array(env, selection_args); | 1285 ConvertJStringArrayToString16Array(env, selection_args); |
| 1284 | 1286 |
| 1285 std::string where_clause; | 1287 std::string where_clause; |
| 1286 if (selections) { | 1288 if (selections) { |
| 1287 where_clause = ConvertJavaStringToUTF8(env, selections); | 1289 where_clause = ConvertJavaStringToUTF8(env, selections); |
| 1288 } | 1290 } |
| 1289 | 1291 |
| 1290 std::string sort_clause; | 1292 std::string sort_clause; |
| 1291 if (sort_order) { | 1293 if (sort_order) { |
| 1292 sort_clause = ConvertJavaStringToUTF8(env, sort_order); | 1294 sort_clause = ConvertJavaStringToUTF8(env, sort_order); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1315 jbyteArray favicon, | 1317 jbyteArray favicon, |
| 1316 jstring title, | 1318 jstring title, |
| 1317 jobject visits, | 1319 jobject visits, |
| 1318 jlong parent_id, | 1320 jlong parent_id, |
| 1319 jstring selections, | 1321 jstring selections, |
| 1320 jobjectArray selection_args) { | 1322 jobjectArray selection_args) { |
| 1321 history::HistoryAndBookmarkRow row; | 1323 history::HistoryAndBookmarkRow row; |
| 1322 FillBookmarkRow(env, obj, url, created, isBookmark, date, favicon, title, | 1324 FillBookmarkRow(env, obj, url, created, isBookmark, date, favicon, title, |
| 1323 visits, parent_id, &row, bookmark_model_); | 1325 visits, parent_id, &row, bookmark_model_); |
| 1324 | 1326 |
| 1325 std::vector<string16> where_args = | 1327 std::vector<base::string16> where_args = |
| 1326 ConvertJStringArrayToString16Array(env, selection_args); | 1328 ConvertJStringArrayToString16Array(env, selection_args); |
| 1327 | 1329 |
| 1328 std::string where_clause; | 1330 std::string where_clause; |
| 1329 if (selections) | 1331 if (selections) |
| 1330 where_clause = ConvertJavaStringToUTF8(env, selections); | 1332 where_clause = ConvertJavaStringToUTF8(env, selections); |
| 1331 | 1333 |
| 1332 UpdateBookmarksFromAPITask task(service_.get(), &android_history_consumer_); | 1334 UpdateBookmarksFromAPITask task(service_.get(), &android_history_consumer_); |
| 1333 return task.Run(row, where_clause, where_args); | 1335 return task.Run(row, where_clause, where_args); |
| 1334 } | 1336 } |
| 1335 | 1337 |
| 1336 jint ChromeBrowserProvider::RemoveBookmarkFromAPI(JNIEnv* env, | 1338 jint ChromeBrowserProvider::RemoveBookmarkFromAPI(JNIEnv* env, |
| 1337 jobject obj, | 1339 jobject obj, |
| 1338 jstring selections, | 1340 jstring selections, |
| 1339 jobjectArray selection_args) { | 1341 jobjectArray selection_args) { |
| 1340 std::vector<string16> where_args = | 1342 std::vector<base::string16> where_args = |
| 1341 ConvertJStringArrayToString16Array(env, selection_args); | 1343 ConvertJStringArrayToString16Array(env, selection_args); |
| 1342 | 1344 |
| 1343 std::string where_clause; | 1345 std::string where_clause; |
| 1344 if (selections) | 1346 if (selections) |
| 1345 where_clause = ConvertJavaStringToUTF8(env, selections); | 1347 where_clause = ConvertJavaStringToUTF8(env, selections); |
| 1346 | 1348 |
| 1347 RemoveBookmarksFromAPITask task(service_.get(), &android_history_consumer_); | 1349 RemoveBookmarksFromAPITask task(service_.get(), &android_history_consumer_); |
| 1348 return task.Run(where_clause, where_args); | 1350 return task.Run(where_clause, where_args); |
| 1349 } | 1351 } |
| 1350 | 1352 |
| 1351 jint ChromeBrowserProvider::RemoveHistoryFromAPI(JNIEnv* env, | 1353 jint ChromeBrowserProvider::RemoveHistoryFromAPI(JNIEnv* env, |
| 1352 jobject obj, | 1354 jobject obj, |
| 1353 jstring selections, | 1355 jstring selections, |
| 1354 jobjectArray selection_args) { | 1356 jobjectArray selection_args) { |
| 1355 std::vector<string16> where_args = | 1357 std::vector<base::string16> where_args = |
| 1356 ConvertJStringArrayToString16Array(env, selection_args); | 1358 ConvertJStringArrayToString16Array(env, selection_args); |
| 1357 | 1359 |
| 1358 std::string where_clause; | 1360 std::string where_clause; |
| 1359 if (selections) | 1361 if (selections) |
| 1360 where_clause = ConvertJavaStringToUTF8(env, selections); | 1362 where_clause = ConvertJavaStringToUTF8(env, selections); |
| 1361 | 1363 |
| 1362 RemoveHistoryFromAPITask task(service_.get(), &android_history_consumer_); | 1364 RemoveHistoryFromAPITask task(service_.get(), &android_history_consumer_); |
| 1363 return task.Run(where_clause, where_args); | 1365 return task.Run(where_clause, where_args); |
| 1364 } | 1366 } |
| 1365 | 1367 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 history::SearchRow::GetColumnID(name); | 1408 history::SearchRow::GetColumnID(name); |
| 1407 if (id == history::SearchRow::COLUMN_END) { | 1409 if (id == history::SearchRow::COLUMN_END) { |
| 1408 LOG(ERROR) << "Can not find " << name; | 1410 LOG(ERROR) << "Can not find " << name; |
| 1409 return ScopedJavaLocalRef<jobject>(); | 1411 return ScopedJavaLocalRef<jobject>(); |
| 1410 } | 1412 } |
| 1411 query_columns.push_back(id); | 1413 query_columns.push_back(id); |
| 1412 columns_name.push_back(name); | 1414 columns_name.push_back(name); |
| 1413 } | 1415 } |
| 1414 } | 1416 } |
| 1415 | 1417 |
| 1416 std::vector<string16> where_args = | 1418 std::vector<base::string16> where_args = |
| 1417 ConvertJStringArrayToString16Array(env, selection_args); | 1419 ConvertJStringArrayToString16Array(env, selection_args); |
| 1418 | 1420 |
| 1419 std::string where_clause; | 1421 std::string where_clause; |
| 1420 if (selections) { | 1422 if (selections) { |
| 1421 where_clause = ConvertJavaStringToUTF8(env, selections); | 1423 where_clause = ConvertJavaStringToUTF8(env, selections); |
| 1422 } | 1424 } |
| 1423 | 1425 |
| 1424 std::string sort_clause; | 1426 std::string sort_clause; |
| 1425 if (sort_order) { | 1427 if (sort_order) { |
| 1426 sort_clause = ConvertJavaStringToUTF8(env, sort_order); | 1428 sort_clause = ConvertJavaStringToUTF8(env, sort_order); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1439 } | 1441 } |
| 1440 | 1442 |
| 1441 // Updates the search terms with the given column values. The value is not | 1443 // Updates the search terms with the given column values. The value is not |
| 1442 // given if it is NULL. | 1444 // given if it is NULL. |
| 1443 jint ChromeBrowserProvider::UpdateSearchTermFromAPI( | 1445 jint ChromeBrowserProvider::UpdateSearchTermFromAPI( |
| 1444 JNIEnv* env, jobject obj, jstring search_term, jobject date, | 1446 JNIEnv* env, jobject obj, jstring search_term, jobject date, |
| 1445 jstring selections, jobjectArray selection_args) { | 1447 jstring selections, jobjectArray selection_args) { |
| 1446 history::SearchRow row; | 1448 history::SearchRow row; |
| 1447 FillSearchRow(env, obj, search_term, date, &row); | 1449 FillSearchRow(env, obj, search_term, date, &row); |
| 1448 | 1450 |
| 1449 std::vector<string16> where_args = ConvertJStringArrayToString16Array( | 1451 std::vector<base::string16> where_args = ConvertJStringArrayToString16Array( |
| 1450 env, selection_args); | 1452 env, selection_args); |
| 1451 | 1453 |
| 1452 std::string where_clause; | 1454 std::string where_clause; |
| 1453 if (selections) | 1455 if (selections) |
| 1454 where_clause = ConvertJavaStringToUTF8(env, selections); | 1456 where_clause = ConvertJavaStringToUTF8(env, selections); |
| 1455 | 1457 |
| 1456 UpdateSearchTermsFromAPITask task(service_.get(), &android_history_consumer_, | 1458 UpdateSearchTermsFromAPITask task(service_.get(), &android_history_consumer_, |
| 1457 profile_); | 1459 profile_); |
| 1458 return task.Run(row, where_clause, where_args); | 1460 return task.Run(row, where_clause, where_args); |
| 1459 } | 1461 } |
| 1460 | 1462 |
| 1461 jint ChromeBrowserProvider::RemoveSearchTermFromAPI( | 1463 jint ChromeBrowserProvider::RemoveSearchTermFromAPI( |
| 1462 JNIEnv* env, jobject obj, jstring selections, jobjectArray selection_args) { | 1464 JNIEnv* env, jobject obj, jstring selections, jobjectArray selection_args) { |
| 1463 std::vector<string16> where_args = | 1465 std::vector<base::string16> where_args = |
| 1464 ConvertJStringArrayToString16Array(env, selection_args); | 1466 ConvertJStringArrayToString16Array(env, selection_args); |
| 1465 | 1467 |
| 1466 std::string where_clause; | 1468 std::string where_clause; |
| 1467 if (selections) | 1469 if (selections) |
| 1468 where_clause = ConvertJavaStringToUTF8(env, selections); | 1470 where_clause = ConvertJavaStringToUTF8(env, selections); |
| 1469 | 1471 |
| 1470 RemoveSearchTermsFromAPITask task(service_.get(), &android_history_consumer_, | 1472 RemoveSearchTermsFromAPITask task(service_.get(), &android_history_consumer_, |
| 1471 profile_); | 1473 profile_); |
| 1472 return task.Run(where_clause, where_args); | 1474 return task.Run(where_clause, where_args); |
| 1473 } | 1475 } |
| 1474 | 1476 |
| 1475 // ------------- Provider custom APIs ------------- // | 1477 // ------------- Provider custom APIs ------------- // |
| 1476 | 1478 |
| 1477 jboolean ChromeBrowserProvider::BookmarkNodeExists( | 1479 jboolean ChromeBrowserProvider::BookmarkNodeExists( |
| 1478 JNIEnv* env, | 1480 JNIEnv* env, |
| 1479 jobject obj, | 1481 jobject obj, |
| 1480 jlong id) { | 1482 jlong id) { |
| 1481 BookmarkNodeExistsTask task(bookmark_model_); | 1483 BookmarkNodeExistsTask task(bookmark_model_); |
| 1482 return task.Run(id); | 1484 return task.Run(id); |
| 1483 } | 1485 } |
| 1484 | 1486 |
| 1485 jlong ChromeBrowserProvider::CreateBookmarksFolderOnce( | 1487 jlong ChromeBrowserProvider::CreateBookmarksFolderOnce( |
| 1486 JNIEnv* env, | 1488 JNIEnv* env, |
| 1487 jobject obj, | 1489 jobject obj, |
| 1488 jstring jtitle, | 1490 jstring jtitle, |
| 1489 jlong parent_id) { | 1491 jlong parent_id) { |
| 1490 string16 title = ConvertJavaStringToUTF16(env, jtitle); | 1492 base::string16 title = ConvertJavaStringToUTF16(env, jtitle); |
| 1491 if (title.empty()) | 1493 if (title.empty()) |
| 1492 return kInvalidBookmarkId; | 1494 return kInvalidBookmarkId; |
| 1493 | 1495 |
| 1494 CreateBookmarksFolderOnceTask task(bookmark_model_); | 1496 CreateBookmarksFolderOnceTask task(bookmark_model_); |
| 1495 return task.Run(title, parent_id); | 1497 return task.Run(title, parent_id); |
| 1496 } | 1498 } |
| 1497 | 1499 |
| 1498 ScopedJavaLocalRef<jobject> ChromeBrowserProvider::GetAllBookmarkFolders( | 1500 ScopedJavaLocalRef<jobject> ChromeBrowserProvider::GetAllBookmarkFolders( |
| 1499 JNIEnv* env, | 1501 JNIEnv* env, |
| 1500 jobject obj) { | 1502 jobject obj) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 Java_ChromeBrowserProvider_onBookmarkChanged(env, obj.obj()); | 1613 Java_ChromeBrowserProvider_onBookmarkChanged(env, obj.obj()); |
| 1612 } else if (type == | 1614 } else if (type == |
| 1613 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { | 1615 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { |
| 1614 JNIEnv* env = AttachCurrentThread(); | 1616 JNIEnv* env = AttachCurrentThread(); |
| 1615 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); | 1617 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); |
| 1616 if (obj.is_null()) | 1618 if (obj.is_null()) |
| 1617 return; | 1619 return; |
| 1618 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); | 1620 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); |
| 1619 } | 1621 } |
| 1620 } | 1622 } |
| OLD | NEW |