| 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/history/android/android_provider_backend.h" | 5 #include "chrome/browser/history/android/android_provider_backend.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/favicon/favicon_changed_details.h" | 9 #include "chrome/browser/favicon/favicon_changed_details.h" |
| 10 #include "chrome/browser/history/android/android_time.h" | 10 #include "chrome/browser/history/android/android_time.h" |
| 11 #include "chrome/browser/history/android/android_urls_sql_handler.h" | 11 #include "chrome/browser/history/android/android_urls_sql_handler.h" |
| 12 #include "chrome/browser/history/android/bookmark_model_sql_handler.h" | 12 #include "chrome/browser/history/android/bookmark_model_sql_handler.h" |
| 13 #include "chrome/browser/history/android/favicon_sql_handler.h" | 13 #include "chrome/browser/history/android/favicon_sql_handler.h" |
| 14 #include "chrome/browser/history/android/urls_sql_handler.h" | 14 #include "chrome/browser/history/android/urls_sql_handler.h" |
| 15 #include "chrome/browser/history/android/visit_sql_handler.h" | 15 #include "chrome/browser/history/android/visit_sql_handler.h" |
| 16 #include "chrome/browser/history/history_backend.h" | 16 #include "chrome/browser/history/history_backend.h" |
| 17 #include "chrome/browser/history/history_database.h" | 17 #include "chrome/browser/history/history_database.h" |
| 18 #include "chrome/browser/history/thumbnail_database.h" | 18 #include "chrome/browser/history/thumbnail_database.h" |
| 19 #include "components/bookmarks/browser/bookmark_service.h" | 19 #include "components/history/core/browser/history_client.h" |
| 20 #include "content/public/common/page_transition_types.h" | 20 #include "content/public/common/page_transition_types.h" |
| 21 #include "sql/connection.h" | 21 #include "sql/connection.h" |
| 22 | 22 |
| 23 | 23 |
| 24 namespace history { | 24 namespace history { |
| 25 | 25 |
| 26 | 26 |
| 27 // Helpers -------------------------------------------------------------------- | 27 // Helpers -------------------------------------------------------------------- |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 committed_ = true; | 208 committed_ = true; |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 // AndroidProviderBackend ----------------------------------------------------- | 212 // AndroidProviderBackend ----------------------------------------------------- |
| 213 | 213 |
| 214 AndroidProviderBackend::AndroidProviderBackend( | 214 AndroidProviderBackend::AndroidProviderBackend( |
| 215 const base::FilePath& db_name, | 215 const base::FilePath& db_name, |
| 216 HistoryDatabase* history_db, | 216 HistoryDatabase* history_db, |
| 217 ThumbnailDatabase* thumbnail_db, | 217 ThumbnailDatabase* thumbnail_db, |
| 218 BookmarkService* bookmark_service, | 218 HistoryClient* history_client, |
| 219 HistoryBackend::Delegate* delegate) | 219 HistoryBackend::Delegate* delegate) |
| 220 : android_cache_db_filename_(db_name), | 220 : android_cache_db_filename_(db_name), |
| 221 db_(&history_db->GetDB()), | 221 db_(&history_db->GetDB()), |
| 222 history_db_(history_db), | 222 history_db_(history_db), |
| 223 thumbnail_db_(thumbnail_db), | 223 thumbnail_db_(thumbnail_db), |
| 224 bookmark_service_(bookmark_service), | 224 history_client_(history_client), |
| 225 initialized_(false), | 225 initialized_(false), |
| 226 delegate_(delegate) { | 226 delegate_(delegate) { |
| 227 DCHECK(delegate_); | 227 DCHECK(delegate_); |
| 228 } | 228 } |
| 229 | 229 |
| 230 AndroidProviderBackend::~AndroidProviderBackend() { | 230 AndroidProviderBackend::~AndroidProviderBackend() { |
| 231 } | 231 } |
| 232 | 232 |
| 233 AndroidStatement* AndroidProviderBackend::QueryHistoryAndBookmarks( | 233 AndroidStatement* AndroidProviderBackend::QueryHistoryAndBookmarks( |
| 234 const std::vector<HistoryAndBookmarkRow::ColumnID>& projections, | 234 const std::vector<HistoryAndBookmarkRow::ColumnID>& projections, |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 return false; | 786 return false; |
| 787 } | 787 } |
| 788 return true; | 788 return true; |
| 789 } | 789 } |
| 790 | 790 |
| 791 bool AndroidProviderBackend::UpdateRemovedURLs() { | 791 bool AndroidProviderBackend::UpdateRemovedURLs() { |
| 792 return history_db_->DeleteUnusedAndroidURLs(); | 792 return history_db_->DeleteUnusedAndroidURLs(); |
| 793 } | 793 } |
| 794 | 794 |
| 795 bool AndroidProviderBackend::UpdateBookmarks() { | 795 bool AndroidProviderBackend::UpdateBookmarks() { |
| 796 if (bookmark_service_ == NULL) { | 796 if (history_client_ == NULL) { |
| 797 LOG(ERROR) << "Bookmark service is not available"; | 797 LOG(ERROR) << "HistoryClient is not available"; |
| 798 return false; | 798 return false; |
| 799 } | 799 } |
| 800 | 800 |
| 801 bookmark_service_->BlockTillLoaded(); | 801 std::vector<URLAndTitle> bookmarks; |
| 802 std::vector<BookmarkService::URLAndTitle> bookmarks; | 802 history_client_->GetBookmarks(&bookmarks); |
| 803 bookmark_service_->GetBookmarks(&bookmarks); | |
| 804 | 803 |
| 805 if (bookmarks.empty()) | 804 if (bookmarks.empty()) |
| 806 return true; | 805 return true; |
| 807 | 806 |
| 808 std::vector<URLID> url_ids; | 807 std::vector<URLID> url_ids; |
| 809 for (std::vector<BookmarkService::URLAndTitle>::const_iterator i = | 808 for (std::vector<URLAndTitle>::const_iterator i = |
| 810 bookmarks.begin(); i != bookmarks.end(); ++i) { | 809 bookmarks.begin(); i != bookmarks.end(); ++i) { |
| 811 URLID url_id = history_db_->GetRowForURL(i->url, NULL); | 810 URLID url_id = history_db_->GetRowForURL(i->url, NULL); |
| 812 if (url_id == 0) { | 811 if (url_id == 0) { |
| 813 URLRow url_row(i->url); | 812 URLRow url_row(i->url); |
| 814 url_row.set_title(i->title); | 813 url_row.set_title(i->title); |
| 815 // Set the visit time to the UnixEpoch since that's when the Android | 814 // Set the visit time to the UnixEpoch since that's when the Android |
| 816 // system time starts. The Android have a CTS testcase for this. | 815 // system time starts. The Android have a CTS testcase for this. |
| 817 url_row.set_last_visit(base::Time::UnixEpoch()); | 816 url_row.set_last_visit(base::Time::UnixEpoch()); |
| 818 url_row.set_hidden(true); | 817 url_row.set_hidden(true); |
| 819 url_id = history_db_->AddURL(url_row); | 818 url_id = history_db_->AddURL(url_row); |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 return false; | 1220 return false; |
| 1222 | 1221 |
| 1223 if (!history_db_->SetKeywordSearchTermsForURL(bookmark_row.url_id(), | 1222 if (!history_db_->SetKeywordSearchTermsForURL(bookmark_row.url_id(), |
| 1224 values.template_url_id(), values.search_term())) | 1223 values.template_url_id(), values.search_term())) |
| 1225 return false; | 1224 return false; |
| 1226 } | 1225 } |
| 1227 return true; | 1226 return true; |
| 1228 } | 1227 } |
| 1229 | 1228 |
| 1230 } // namespace history | 1229 } // namespace history |
| OLD | NEW |