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/bookmarks/bookmark_service.h" | 8 #include "chrome/browser/bookmarks/bookmark_service.h" |
9 #include "chrome/common/chrome_notification_types.h" | 9 #include "chrome/common/chrome_notification_types.h" |
10 #include "chrome/browser/history/android/android_time.h" | 10 #include "chrome/browser/history/android/android_time.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 if (!history_db_->GetURLRow(i->url_id, &url_row)) | 309 if (!history_db_->GetURLRow(i->url_id, &url_row)) |
310 return false; | 310 return false; |
311 modified->changed_urls.push_back(url_row); | 311 modified->changed_urls.push_back(url_row); |
312 } | 312 } |
313 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON)) | 313 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON)) |
314 favicon->urls.insert(i->url); | 314 favicon->urls.insert(i->url); |
315 } | 315 } |
316 | 316 |
317 if (!modified->changed_urls.empty()) | 317 if (!modified->changed_urls.empty()) |
318 notifications->push_back(HistoryNotification( | 318 notifications->push_back(HistoryNotification( |
319 chrome::NOTIFICATION_HISTORY_TYPED_URLS_MODIFIED, modified.release())); | 319 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release())); |
320 | 320 |
321 if (!favicon->urls.empty()) | 321 if (!favicon->urls.empty()) |
322 notifications->push_back(HistoryNotification( | 322 notifications->push_back(HistoryNotification( |
323 chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release())); | 323 chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release())); |
324 | 324 |
325 return true; | 325 return true; |
326 } | 326 } |
327 | 327 |
328 AndroidURLID AndroidProviderBackend::InsertHistoryAndBookmark( | 328 AndroidURLID AndroidProviderBackend::InsertHistoryAndBookmark( |
329 const HistoryAndBookmarkRow& values, | 329 const HistoryAndBookmarkRow& values, |
(...skipping 25 matching lines...) Expand all Loading... |
355 scoped_ptr<FaviconChangeDetails> favicon; | 355 scoped_ptr<FaviconChangeDetails> favicon; |
356 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) && | 356 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) && |
357 !row.favicon().empty()) { | 357 !row.favicon().empty()) { |
358 favicon.reset(new FaviconChangeDetails); | 358 favicon.reset(new FaviconChangeDetails); |
359 if (!favicon.get()) | 359 if (!favicon.get()) |
360 return false; | 360 return false; |
361 favicon->urls.insert(url_row.url()); | 361 favicon->urls.insert(url_row.url()); |
362 } | 362 } |
363 | 363 |
364 notifications->push_back(HistoryNotification( | 364 notifications->push_back(HistoryNotification( |
365 chrome::NOTIFICATION_HISTORY_TYPED_URLS_MODIFIED, modified.release())); | 365 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release())); |
366 if (favicon.get()) | 366 if (favicon.get()) |
367 notifications->push_back(HistoryNotification( | 367 notifications->push_back(HistoryNotification( |
368 chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release())); | 368 chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release())); |
369 | 369 |
370 return row.id(); | 370 return row.id(); |
371 } | 371 } |
372 | 372 |
373 bool AndroidProviderBackend::DeleteHistoryAndBookmarks( | 373 bool AndroidProviderBackend::DeleteHistoryAndBookmarks( |
374 const std::string& selection, | 374 const std::string& selection, |
375 const std::vector<string16>& selection_args, | 375 const std::vector<string16>& selection_args, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 i != bookmark_rows.end(); ++i) { | 430 i != bookmark_rows.end(); ++i) { |
431 URLRow row(i->url); | 431 URLRow row(i->url); |
432 // Set visit time as UnixEpoch because the Android's system time start from | 432 // Set visit time as UnixEpoch because the Android's system time start from |
433 // the unix epoch. | 433 // the unix epoch. |
434 row.set_last_visit(Time::UnixEpoch()); | 434 row.set_last_visit(Time::UnixEpoch()); |
435 if (!history_db_->AddURL(row)) | 435 if (!history_db_->AddURL(row)) |
436 return false; | 436 return false; |
437 modified->changed_urls.push_back(row); | 437 modified->changed_urls.push_back(row); |
438 } | 438 } |
439 notifications->push_back(HistoryNotification( | 439 notifications->push_back(HistoryNotification( |
440 chrome::NOTIFICATION_HISTORY_TYPED_URLS_MODIFIED, modified.release())); | 440 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release())); |
441 | 441 |
442 return true; | 442 return true; |
443 } | 443 } |
444 | 444 |
445 AndroidStatement* AndroidProviderBackend::QuerySearchTerms( | 445 AndroidStatement* AndroidProviderBackend::QuerySearchTerms( |
446 const std::vector<SearchRow::ColumnID>& projections, | 446 const std::vector<SearchRow::ColumnID>& projections, |
447 const std::string& selection, | 447 const std::string& selection, |
448 const std::vector<string16>& selection_args, | 448 const std::vector<string16>& selection_args, |
449 const std::string& sort_order) { | 449 const std::string& sort_order) { |
450 if (projections.empty()) | 450 if (projections.empty()) |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 | 970 |
971 modified->changed_urls.push_back(new_url_row); | 971 modified->changed_urls.push_back(new_url_row); |
972 | 972 |
973 notifications->push_back(HistoryNotification( | 973 notifications->push_back(HistoryNotification( |
974 chrome::NOTIFICATION_HISTORY_URLS_DELETED, | 974 chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
975 deleted_details.release())); | 975 deleted_details.release())); |
976 if (favicon_details.get() && !favicon_details->urls.empty()) | 976 if (favicon_details.get() && !favicon_details->urls.empty()) |
977 notifications->push_back(HistoryNotification( | 977 notifications->push_back(HistoryNotification( |
978 chrome::NOTIFICATION_FAVICON_CHANGED, favicon_details.release())); | 978 chrome::NOTIFICATION_FAVICON_CHANGED, favicon_details.release())); |
979 notifications->push_back(HistoryNotification( | 979 notifications->push_back(HistoryNotification( |
980 chrome::NOTIFICATION_HISTORY_TYPED_URLS_MODIFIED, modified.release())); | 980 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release())); |
981 | 981 |
982 return true; | 982 return true; |
983 } | 983 } |
984 | 984 |
985 AndroidStatement* AndroidProviderBackend::QueryHistoryAndBookmarksInternal( | 985 AndroidStatement* AndroidProviderBackend::QueryHistoryAndBookmarksInternal( |
986 const std::vector<HistoryAndBookmarkRow::ColumnID>& projections, | 986 const std::vector<HistoryAndBookmarkRow::ColumnID>& projections, |
987 const std::string& selection, | 987 const std::string& selection, |
988 const std::vector<string16>& selection_args, | 988 const std::vector<string16>& selection_args, |
989 const std::string& sort_order) { | 989 const std::string& sort_order) { |
990 std::string sql; | 990 std::string sql; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 return false; | 1099 return false; |
1100 | 1100 |
1101 if (!history_db_->SetKeywordSearchTermsForURL(bookmark_row.url_id(), | 1101 if (!history_db_->SetKeywordSearchTermsForURL(bookmark_row.url_id(), |
1102 values.template_url_id(), values.search_term())) | 1102 values.template_url_id(), values.search_term())) |
1103 return false; | 1103 return false; |
1104 } | 1104 } |
1105 return true; | 1105 return true; |
1106 } | 1106 } |
1107 | 1107 |
1108 } // namespace history | 1108 } // namespace history |
OLD | NEW |