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 <cmath> | 7 #include <cmath> |
8 #include <list> | 8 #include <list> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 model(), title, url, is_folder, parent_id, &result)); | 209 model(), title, url, is_folder, parent_id, &result)); |
210 return result; | 210 return result; |
211 } | 211 } |
212 | 212 |
213 static void RunOnUIThread(BookmarkModel* model, | 213 static void RunOnUIThread(BookmarkModel* model, |
214 const base::string16& title, | 214 const base::string16& title, |
215 const base::string16& url, | 215 const base::string16& url, |
216 const bool is_folder, | 216 const bool is_folder, |
217 const int64 parent_id, | 217 const int64 parent_id, |
218 int64* result) { | 218 int64* result) { |
219 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 219 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
220 DCHECK(result); | 220 DCHECK(result); |
221 GURL gurl = ParseAndMaybeAppendScheme(url, kDefaultUrlScheme); | 221 GURL gurl = ParseAndMaybeAppendScheme(url, kDefaultUrlScheme); |
222 | 222 |
223 // Check if the bookmark already exists. | 223 // Check if the bookmark already exists. |
224 const BookmarkNode* node = model->GetMostRecentlyAddedUserNodeForURL(gurl); | 224 const BookmarkNode* node = model->GetMostRecentlyAddedUserNodeForURL(gurl); |
225 if (!node) { | 225 if (!node) { |
226 const BookmarkNode* parent_node = NULL; | 226 const BookmarkNode* parent_node = NULL; |
227 if (parent_id >= 0) | 227 if (parent_id >= 0) |
228 parent_node = bookmarks::GetBookmarkNodeByID(model, parent_id); | 228 parent_node = bookmarks::GetBookmarkNodeByID(model, parent_id); |
229 if (!parent_node) | 229 if (!parent_node) |
(...skipping 22 matching lines...) Expand all Loading... |
252 ~RemoveBookmarkTask() override {} | 252 ~RemoveBookmarkTask() override {} |
253 | 253 |
254 int Run(const int64 id) { | 254 int Run(const int64 id) { |
255 id_to_delete_ = id; | 255 id_to_delete_ = id; |
256 RunOnUIThreadBlocking::Run( | 256 RunOnUIThreadBlocking::Run( |
257 base::Bind(&RemoveBookmarkTask::RunOnUIThread, model(), id)); | 257 base::Bind(&RemoveBookmarkTask::RunOnUIThread, model(), id)); |
258 return deleted_; | 258 return deleted_; |
259 } | 259 } |
260 | 260 |
261 static void RunOnUIThread(BookmarkModel* model, const int64 id) { | 261 static void RunOnUIThread(BookmarkModel* model, const int64 id) { |
262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 262 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
263 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID(model, id); | 263 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID(model, id); |
264 if (node && node->parent()) { | 264 if (node && node->parent()) { |
265 const BookmarkNode* parent_node = node->parent(); | 265 const BookmarkNode* parent_node = node->parent(); |
266 model->Remove(parent_node, parent_node->GetIndexOf(node)); | 266 model->Remove(parent_node, parent_node->GetIndexOf(node)); |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 // Verify that the bookmark was actually removed. Called synchronously. | 270 // Verify that the bookmark was actually removed. Called synchronously. |
271 void BookmarkNodeRemoved(BookmarkModel* bookmark_model, | 271 void BookmarkNodeRemoved(BookmarkModel* bookmark_model, |
272 const BookmarkNode* parent, | 272 const BookmarkNode* parent, |
(...skipping 18 matching lines...) Expand all Loading... |
291 : BookmarkModelObserverTask(model) {} | 291 : BookmarkModelObserverTask(model) {} |
292 | 292 |
293 ~RemoveAllUserBookmarksTask() override {} | 293 ~RemoveAllUserBookmarksTask() override {} |
294 | 294 |
295 void Run() { | 295 void Run() { |
296 RunOnUIThreadBlocking::Run( | 296 RunOnUIThreadBlocking::Run( |
297 base::Bind(&RemoveAllUserBookmarksTask::RunOnUIThread, model())); | 297 base::Bind(&RemoveAllUserBookmarksTask::RunOnUIThread, model())); |
298 } | 298 } |
299 | 299 |
300 static void RunOnUIThread(BookmarkModel* model) { | 300 static void RunOnUIThread(BookmarkModel* model) { |
301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 301 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
302 LOG(ERROR) << "begin model->RemoveAllUserBookmarks"; | 302 LOG(ERROR) << "begin model->RemoveAllUserBookmarks"; |
303 model->RemoveAllUserBookmarks(); | 303 model->RemoveAllUserBookmarks(); |
304 LOG(ERROR) << "after model->RemoveAllUserBookmarks"; | 304 LOG(ERROR) << "after model->RemoveAllUserBookmarks"; |
305 } | 305 } |
306 | 306 |
307 private: | 307 private: |
308 DISALLOW_COPY_AND_ASSIGN(RemoveAllUserBookmarksTask); | 308 DISALLOW_COPY_AND_ASSIGN(RemoveAllUserBookmarksTask); |
309 }; | 309 }; |
310 | 310 |
311 // Utility method to update a bookmark. | 311 // Utility method to update a bookmark. |
(...skipping 14 matching lines...) Expand all Loading... |
326 base::Bind(&UpdateBookmarkTask::RunOnUIThread, | 326 base::Bind(&UpdateBookmarkTask::RunOnUIThread, |
327 model(), id, title, url, parent_id)); | 327 model(), id, title, url, parent_id)); |
328 return updated_; | 328 return updated_; |
329 } | 329 } |
330 | 330 |
331 static void RunOnUIThread(BookmarkModel* model, | 331 static void RunOnUIThread(BookmarkModel* model, |
332 const int64 id, | 332 const int64 id, |
333 const base::string16& title, | 333 const base::string16& title, |
334 const base::string16& url, | 334 const base::string16& url, |
335 const int64 parent_id) { | 335 const int64 parent_id) { |
336 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 336 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
337 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID(model, id); | 337 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID(model, id); |
338 if (node) { | 338 if (node) { |
339 if (node->GetTitle() != title) | 339 if (node->GetTitle() != title) |
340 model->SetTitle(node, title); | 340 model->SetTitle(node, title); |
341 | 341 |
342 if (node->type() == BookmarkNode::URL) { | 342 if (node->type() == BookmarkNode::URL) { |
343 GURL bookmark_url = ParseAndMaybeAppendScheme(url, kDefaultUrlScheme); | 343 GURL bookmark_url = ParseAndMaybeAppendScheme(url, kDefaultUrlScheme); |
344 if (bookmark_url != node->url()) | 344 if (bookmark_url != node->url()) |
345 model->SetURL(node, bookmark_url); | 345 model->SetURL(node, bookmark_url); |
346 } | 346 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 bool result = false; | 381 bool result = false; |
382 RunOnUIThreadBlocking::Run( | 382 RunOnUIThreadBlocking::Run( |
383 base::Bind(&BookmarkNodeExistsTask::RunOnUIThread, | 383 base::Bind(&BookmarkNodeExistsTask::RunOnUIThread, |
384 model(), id, &result)); | 384 model(), id, &result)); |
385 return result; | 385 return result; |
386 } | 386 } |
387 | 387 |
388 static void RunOnUIThread(BookmarkModel* model, | 388 static void RunOnUIThread(BookmarkModel* model, |
389 const int64 id, | 389 const int64 id, |
390 bool* result) { | 390 bool* result) { |
391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 391 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
392 DCHECK(result); | 392 DCHECK(result); |
393 *result = bookmarks::GetBookmarkNodeByID(model, id) != NULL; | 393 *result = bookmarks::GetBookmarkNodeByID(model, id) != NULL; |
394 } | 394 } |
395 | 395 |
396 private: | 396 private: |
397 DISALLOW_COPY_AND_ASSIGN(BookmarkNodeExistsTask); | 397 DISALLOW_COPY_AND_ASSIGN(BookmarkNodeExistsTask); |
398 }; | 398 }; |
399 | 399 |
400 // Checks if a node belongs to the Mobile Bookmarks hierarchy branch. | 400 // Checks if a node belongs to the Mobile Bookmarks hierarchy branch. |
401 class IsInMobileBookmarksBranchTask : public BookmarkModelTask { | 401 class IsInMobileBookmarksBranchTask : public BookmarkModelTask { |
402 public: | 402 public: |
403 explicit IsInMobileBookmarksBranchTask(BookmarkModel* model) | 403 explicit IsInMobileBookmarksBranchTask(BookmarkModel* model) |
404 : BookmarkModelTask(model) {} | 404 : BookmarkModelTask(model) {} |
405 | 405 |
406 bool Run(const int64 id) { | 406 bool Run(const int64 id) { |
407 bool result = false; | 407 bool result = false; |
408 RunOnUIThreadBlocking::Run( | 408 RunOnUIThreadBlocking::Run( |
409 base::Bind(&IsInMobileBookmarksBranchTask::RunOnUIThread, | 409 base::Bind(&IsInMobileBookmarksBranchTask::RunOnUIThread, |
410 model(), id, &result)); | 410 model(), id, &result)); |
411 return result; | 411 return result; |
412 } | 412 } |
413 | 413 |
414 static void RunOnUIThread(BookmarkModel* model, | 414 static void RunOnUIThread(BookmarkModel* model, |
415 const int64 id, | 415 const int64 id, |
416 bool *result) { | 416 bool *result) { |
417 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 417 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
418 DCHECK(result); | 418 DCHECK(result); |
419 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID(model, id); | 419 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID(model, id); |
420 const BookmarkNode* mobile_node = model->mobile_node(); | 420 const BookmarkNode* mobile_node = model->mobile_node(); |
421 while (node && node != mobile_node) | 421 while (node && node != mobile_node) |
422 node = node->parent(); | 422 node = node->parent(); |
423 | 423 |
424 *result = node == mobile_node; | 424 *result = node == mobile_node; |
425 } | 425 } |
426 | 426 |
427 private: | 427 private: |
(...skipping 13 matching lines...) Expand all Loading... |
441 RunOnUIThreadBlocking::Run( | 441 RunOnUIThreadBlocking::Run( |
442 base::Bind(&CreateBookmarksFolderOnceTask::RunOnUIThread, | 442 base::Bind(&CreateBookmarksFolderOnceTask::RunOnUIThread, |
443 model(), title, parent_id, &result)); | 443 model(), title, parent_id, &result)); |
444 return result; | 444 return result; |
445 } | 445 } |
446 | 446 |
447 static void RunOnUIThread(BookmarkModel* model, | 447 static void RunOnUIThread(BookmarkModel* model, |
448 const base::string16& title, | 448 const base::string16& title, |
449 const int64 parent_id, | 449 const int64 parent_id, |
450 int64* result) { | 450 int64* result) { |
451 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 451 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
452 DCHECK(result); | 452 DCHECK(result); |
453 | 453 |
454 // Invalid ids are assumed to refer to the Mobile Bookmarks folder. | 454 // Invalid ids are assumed to refer to the Mobile Bookmarks folder. |
455 const BookmarkNode* parent = | 455 const BookmarkNode* parent = |
456 parent_id >= 0 ? bookmarks::GetBookmarkNodeByID(model, parent_id) | 456 parent_id >= 0 ? bookmarks::GetBookmarkNodeByID(model, parent_id) |
457 : model->mobile_node(); | 457 : model->mobile_node(); |
458 DCHECK(parent); | 458 DCHECK(parent); |
459 | 459 |
460 bool in_mobile_bookmarks; | 460 bool in_mobile_bookmarks; |
461 IsInMobileBookmarksBranchTask::RunOnUIThread(model, parent->id(), | 461 IsInMobileBookmarksBranchTask::RunOnUIThread(model, parent->id(), |
(...skipping 27 matching lines...) Expand all Loading... |
489 | 489 |
490 void Run(ScopedJavaGlobalRef<jobject>* jroot) { | 490 void Run(ScopedJavaGlobalRef<jobject>* jroot) { |
491 RunOnUIThreadBlocking::Run( | 491 RunOnUIThreadBlocking::Run( |
492 base::Bind(&GetEditableBookmarkFoldersTask::RunOnUIThread, | 492 base::Bind(&GetEditableBookmarkFoldersTask::RunOnUIThread, |
493 client_, model(), jroot)); | 493 client_, model(), jroot)); |
494 } | 494 } |
495 | 495 |
496 static void RunOnUIThread(ChromeBookmarkClient* client, | 496 static void RunOnUIThread(ChromeBookmarkClient* client, |
497 BookmarkModel* model, | 497 BookmarkModel* model, |
498 ScopedJavaGlobalRef<jobject>* jroot) { | 498 ScopedJavaGlobalRef<jobject>* jroot) { |
499 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 499 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
500 const BookmarkNode* root = model->root_node(); | 500 const BookmarkNode* root = model->root_node(); |
501 if (!root || !root->is_folder()) | 501 if (!root || !root->is_folder()) |
502 return; | 502 return; |
503 | 503 |
504 // The iterative approach is not possible because ScopedGlobalJavaRefs | 504 // The iterative approach is not possible because ScopedGlobalJavaRefs |
505 // cannot be copy-constructed, and therefore not used in STL containers. | 505 // cannot be copy-constructed, and therefore not used in STL containers. |
506 ConvertFolderSubtree(client, AttachCurrentThread(), root, | 506 ConvertFolderSubtree(client, AttachCurrentThread(), root, |
507 ScopedJavaLocalRef<jobject>(), jroot); | 507 ScopedJavaLocalRef<jobject>(), jroot); |
508 } | 508 } |
509 | 509 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 return RunOnUIThreadBlocking::Run( | 555 return RunOnUIThreadBlocking::Run( |
556 base::Bind(&GetBookmarkNodeTask::RunOnUIThread, | 556 base::Bind(&GetBookmarkNodeTask::RunOnUIThread, |
557 model(), id, get_parent, get_children, jnode)); | 557 model(), id, get_parent, get_children, jnode)); |
558 } | 558 } |
559 | 559 |
560 static void RunOnUIThread(BookmarkModel* model, | 560 static void RunOnUIThread(BookmarkModel* model, |
561 const int64 id, | 561 const int64 id, |
562 bool get_parent, | 562 bool get_parent, |
563 bool get_children, | 563 bool get_children, |
564 ScopedJavaGlobalRef<jobject>* jnode) { | 564 ScopedJavaGlobalRef<jobject>* jnode) { |
565 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 565 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
566 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID(model, id); | 566 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID(model, id); |
567 if (!node || !jnode) | 567 if (!node || !jnode) |
568 return; | 568 return; |
569 | 569 |
570 ScopedJavaGlobalRef<jobject> jparent; | 570 ScopedJavaGlobalRef<jobject> jparent; |
571 if (get_parent) { | 571 if (get_parent) { |
572 ConvertBookmarkNode(node->parent(), ScopedJavaLocalRef<jobject>(), | 572 ConvertBookmarkNode(node->parent(), ScopedJavaLocalRef<jobject>(), |
573 &jparent); | 573 &jparent); |
574 } | 574 } |
575 | 575 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 610 |
611 const BookmarkNode* Run() { | 611 const BookmarkNode* Run() { |
612 const BookmarkNode* result = NULL; | 612 const BookmarkNode* result = NULL; |
613 RunOnUIThreadBlocking::Run( | 613 RunOnUIThreadBlocking::Run( |
614 base::Bind(&GetMobileBookmarksNodeTask::RunOnUIThread, | 614 base::Bind(&GetMobileBookmarksNodeTask::RunOnUIThread, |
615 model(), &result)); | 615 model(), &result)); |
616 return result; | 616 return result; |
617 } | 617 } |
618 | 618 |
619 static void RunOnUIThread(BookmarkModel* model, const BookmarkNode** result) { | 619 static void RunOnUIThread(BookmarkModel* model, const BookmarkNode** result) { |
620 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 620 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
621 DCHECK(result); | 621 DCHECK(result); |
622 *result = model->mobile_node(); | 622 *result = model->mobile_node(); |
623 } | 623 } |
624 | 624 |
625 private: | 625 private: |
626 DISALLOW_COPY_AND_ASSIGN(GetMobileBookmarksNodeTask); | 626 DISALLOW_COPY_AND_ASSIGN(GetMobileBookmarksNodeTask); |
627 }; | 627 }; |
628 | 628 |
629 // ------------- Aynchronous requests classes ------------- // | 629 // ------------- Aynchronous requests classes ------------- // |
630 | 630 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 class SearchTermTask : public HistoryProviderTask { | 889 class SearchTermTask : public HistoryProviderTask { |
890 protected: | 890 protected: |
891 SearchTermTask(AndroidHistoryProviderService* service, | 891 SearchTermTask(AndroidHistoryProviderService* service, |
892 base::CancelableTaskTracker* cancelable_tracker, | 892 base::CancelableTaskTracker* cancelable_tracker, |
893 Profile* profile) | 893 Profile* profile) |
894 : HistoryProviderTask(service, cancelable_tracker), profile_(profile) {} | 894 : HistoryProviderTask(service, cancelable_tracker), profile_(profile) {} |
895 | 895 |
896 // Fill SearchRow's keyword_id and url fields according the given | 896 // Fill SearchRow's keyword_id and url fields according the given |
897 // search_term. Return true if succeeded. | 897 // search_term. Return true if succeeded. |
898 void BuildSearchRow(history::SearchRow* row) { | 898 void BuildSearchRow(history::SearchRow* row) { |
899 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 899 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
900 | 900 |
901 TemplateURLService* template_service = | 901 TemplateURLService* template_service = |
902 TemplateURLServiceFactory::GetForProfile(profile_); | 902 TemplateURLServiceFactory::GetForProfile(profile_); |
903 template_service->Load(); | 903 template_service->Load(); |
904 | 904 |
905 const TemplateURL* search_engine = | 905 const TemplateURL* search_engine = |
906 template_service->GetDefaultSearchProvider(); | 906 template_service->GetDefaultSearchProvider(); |
907 if (search_engine) { | 907 if (search_engine) { |
908 const TemplateURLRef* search_url = &search_engine->url_ref(); | 908 const TemplateURLRef* search_url = &search_engine->url_ref(); |
909 TemplateURLRef::SearchTermsArgs search_terms_args(row->search_term()); | 909 TemplateURLRef::SearchTermsArgs search_terms_args(row->search_term()); |
(...skipping 23 matching lines...) Expand all Loading... |
933 | 933 |
934 history::URLID Run(const history::SearchRow& row) { | 934 history::URLID Run(const history::SearchRow& row) { |
935 RunAsyncRequestOnUIThreadBlocking( | 935 RunAsyncRequestOnUIThreadBlocking( |
936 base::Bind(&AddSearchTermFromAPITask::MakeRequestOnUIThread, | 936 base::Bind(&AddSearchTermFromAPITask::MakeRequestOnUIThread, |
937 base::Unretained(this), row)); | 937 base::Unretained(this), row)); |
938 return result_; | 938 return result_; |
939 } | 939 } |
940 | 940 |
941 private: | 941 private: |
942 void MakeRequestOnUIThread(const history::SearchRow& row) { | 942 void MakeRequestOnUIThread(const history::SearchRow& row) { |
943 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 943 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
944 history::SearchRow internal_row = row; | 944 history::SearchRow internal_row = row; |
945 BuildSearchRow(&internal_row); | 945 BuildSearchRow(&internal_row); |
946 service()->InsertSearchTerm( | 946 service()->InsertSearchTerm( |
947 internal_row, | 947 internal_row, |
948 base::Bind(&AddSearchTermFromAPITask::OnSearchTermInserted, | 948 base::Bind(&AddSearchTermFromAPITask::OnSearchTermInserted, |
949 base::Unretained(this)), | 949 base::Unretained(this)), |
950 cancelable_tracker()); | 950 cancelable_tracker()); |
951 } | 951 } |
952 | 952 |
953 void OnSearchTermInserted(history::URLID id) { | 953 void OnSearchTermInserted(history::URLID id) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 base::Bind(&UpdateSearchTermsFromAPITask::MakeRequestOnUIThread, | 1015 base::Bind(&UpdateSearchTermsFromAPITask::MakeRequestOnUIThread, |
1016 base::Unretained(this), row, selection, selection_args)); | 1016 base::Unretained(this), row, selection, selection_args)); |
1017 return result_; | 1017 return result_; |
1018 } | 1018 } |
1019 | 1019 |
1020 private: | 1020 private: |
1021 void MakeRequestOnUIThread( | 1021 void MakeRequestOnUIThread( |
1022 const history::SearchRow& row, | 1022 const history::SearchRow& row, |
1023 const std::string& selection, | 1023 const std::string& selection, |
1024 const std::vector<base::string16>& selection_args) { | 1024 const std::vector<base::string16>& selection_args) { |
1025 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1025 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1026 history::SearchRow internal_row = row; | 1026 history::SearchRow internal_row = row; |
1027 BuildSearchRow(&internal_row); | 1027 BuildSearchRow(&internal_row); |
1028 service()->UpdateSearchTerms( | 1028 service()->UpdateSearchTerms( |
1029 internal_row, | 1029 internal_row, |
1030 selection, | 1030 selection, |
1031 selection_args, | 1031 selection_args, |
1032 base::Bind(&UpdateSearchTermsFromAPITask::OnSearchTermsUpdated, | 1032 base::Bind(&UpdateSearchTermsFromAPITask::OnSearchTermsUpdated, |
1033 base::Unretained(this)), | 1033 base::Unretained(this)), |
1034 cancelable_tracker()); | 1034 cancelable_tracker()); |
1035 } | 1035 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 } | 1158 } |
1159 | 1159 |
1160 bool ChromeBrowserProvider::RegisterChromeBrowserProvider(JNIEnv* env) { | 1160 bool ChromeBrowserProvider::RegisterChromeBrowserProvider(JNIEnv* env) { |
1161 return RegisterNativesImpl(env); | 1161 return RegisterNativesImpl(env); |
1162 } | 1162 } |
1163 | 1163 |
1164 ChromeBrowserProvider::ChromeBrowserProvider(JNIEnv* env, jobject obj) | 1164 ChromeBrowserProvider::ChromeBrowserProvider(JNIEnv* env, jobject obj) |
1165 : weak_java_provider_(env, obj), | 1165 : weak_java_provider_(env, obj), |
1166 history_service_observer_(this), | 1166 history_service_observer_(this), |
1167 handling_extensive_changes_(false) { | 1167 handling_extensive_changes_(false) { |
1168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1168 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1169 profile_ = g_browser_process->profile_manager()->GetLastUsedProfile(); | 1169 profile_ = g_browser_process->profile_manager()->GetLastUsedProfile(); |
1170 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile_); | 1170 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile_); |
1171 top_sites_ = TopSitesFactory::GetForProfile(profile_); | 1171 top_sites_ = TopSitesFactory::GetForProfile(profile_); |
1172 favicon_service_ = FaviconServiceFactory::GetForProfile( | 1172 favicon_service_ = FaviconServiceFactory::GetForProfile( |
1173 profile_, ServiceAccessType::EXPLICIT_ACCESS), | 1173 profile_, ServiceAccessType::EXPLICIT_ACCESS), |
1174 service_.reset(new AndroidHistoryProviderService(profile_)); | 1174 service_.reset(new AndroidHistoryProviderService(profile_)); |
1175 | 1175 |
1176 // Register as observer for service we are interested. | 1176 // Register as observer for service we are interested. |
1177 bookmark_model_->AddObserver(this); | 1177 bookmark_model_->AddObserver(this); |
1178 history_service_observer_.Add(HistoryServiceFactory::GetForProfile( | 1178 history_service_observer_.Add(HistoryServiceFactory::GetForProfile( |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); | 1646 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); |
1647 if (obj.is_null()) | 1647 if (obj.is_null()) |
1648 return; | 1648 return; |
1649 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); | 1649 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); |
1650 } | 1650 } |
1651 | 1651 |
1652 void ChromeBrowserProvider::OnKeywordSearchTermDeleted( | 1652 void ChromeBrowserProvider::OnKeywordSearchTermDeleted( |
1653 history::HistoryService* history_service, | 1653 history::HistoryService* history_service, |
1654 history::URLID url_id) { | 1654 history::URLID url_id) { |
1655 } | 1655 } |
OLD | NEW |