| Index: chrome/browser/history/android/android_provider_backend.cc
|
| diff --git a/chrome/browser/history/android/android_provider_backend.cc b/chrome/browser/history/android/android_provider_backend.cc
|
| index 36ad43b00b8cad14f9a62e0f9a6e5019d2fd5634..1efbc0a8aa4ff7db596e7882131fb90fb19d6da7 100644
|
| --- a/chrome/browser/history/android/android_provider_backend.cc
|
| +++ b/chrome/browser/history/android/android_provider_backend.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/i18n/case_conversion.h"
|
| #include "chrome/browser/bookmarks/bookmark_service.h"
|
| +#include "chrome/browser/favicon/favicon_changed_details.h"
|
| #include "chrome/browser/history/android/android_time.h"
|
| #include "chrome/browser/history/android/android_urls_sql_handler.h"
|
| #include "chrome/browser/history/android/bookmark_model_sql_handler.h"
|
| @@ -158,14 +159,16 @@ bool AndroidProviderBackend::UpdateHistoryAndBookmarks(
|
| const std::vector<string16>& selection_args,
|
| int* updated_count) {
|
| HistoryNotifications notifications;
|
| + FaviconNotifications favicon_notifications;
|
|
|
| ScopedTransaction transaction(history_db_, thumbnail_db_);
|
|
|
| if (!UpdateHistoryAndBookmarks(row, selection, selection_args, updated_count,
|
| - ¬ifications))
|
| + ¬ifications, &favicon_notifications))
|
| return false;
|
|
|
| transaction.Commit();
|
| + SendFaviconChangedNotifications(favicon_notifications);
|
| BroadcastNotifications(notifications);
|
| return true;
|
| }
|
| @@ -173,13 +176,16 @@ bool AndroidProviderBackend::UpdateHistoryAndBookmarks(
|
| AndroidURLID AndroidProviderBackend::InsertHistoryAndBookmark(
|
| const HistoryAndBookmarkRow& values) {
|
| HistoryNotifications notifications;
|
| + FaviconNotifications favicon_notifications;
|
|
|
| ScopedTransaction transaction(history_db_, thumbnail_db_);
|
|
|
| - AndroidURLID id = InsertHistoryAndBookmark(values, ¬ifications, true);
|
| + AndroidURLID id = InsertHistoryAndBookmark(
|
| + values, ¬ifications, &favicon_notifications, true);
|
| if (id) {
|
| transaction.Commit();
|
| BroadcastNotifications(notifications);
|
| + SendFaviconChangedNotifications(favicon_notifications);
|
| return id;
|
| }
|
| return 0;
|
| @@ -207,15 +213,17 @@ bool AndroidProviderBackend::DeleteHistory(
|
| const std::vector<string16>& selection_args,
|
| int* deleted_count) {
|
| HistoryNotifications notifications;
|
| + FaviconNotifications favicon_notifications;
|
|
|
| ScopedTransaction transaction(history_db_, thumbnail_db_);
|
|
|
| if (!DeleteHistory(selection, selection_args, deleted_count,
|
| - ¬ifications))
|
| + ¬ifications, &favicon_notifications))
|
| return false;
|
|
|
| transaction.Commit();
|
| BroadcastNotifications(notifications);
|
| + SendFaviconChangedNotifications(favicon_notifications);
|
| return true;
|
| }
|
|
|
| @@ -291,7 +299,8 @@ bool AndroidProviderBackend::UpdateHistoryAndBookmarks(
|
| const std::string& selection,
|
| const std::vector<string16>& selection_args,
|
| int* updated_count,
|
| - HistoryNotifications* notifications) {
|
| + HistoryNotifications* notifications,
|
| + FaviconNotifications* favicon_notifications) {
|
| if (!IsHistoryAndBookmarkRowValid(row))
|
| return false;
|
|
|
| @@ -334,7 +343,8 @@ bool AndroidProviderBackend::UpdateHistoryAndBookmarks(
|
| *updated_count = ids_set.size();
|
|
|
| scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
|
| - scoped_ptr<FaviconChangeDetails> favicon(new FaviconChangeDetails);
|
| + scoped_ptr<chrome::FaviconChangedDetails> favicon(
|
| + new chrome::FaviconChangedDetails);
|
|
|
| for (TableIDRows::const_iterator i = ids_set.begin(); i != ids_set.end();
|
| ++i) {
|
| @@ -356,8 +366,7 @@ bool AndroidProviderBackend::UpdateHistoryAndBookmarks(
|
| chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release()));
|
|
|
| if (!favicon->urls.empty())
|
| - notifications->push_back(HistoryNotification(
|
| - chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release()));
|
| + favicon_notifications->push_back(favicon.release());
|
|
|
| return true;
|
| }
|
| @@ -365,6 +374,7 @@ bool AndroidProviderBackend::UpdateHistoryAndBookmarks(
|
| AndroidURLID AndroidProviderBackend::InsertHistoryAndBookmark(
|
| const HistoryAndBookmarkRow& values,
|
| HistoryNotifications* notifications,
|
| + FaviconNotifications* favicon_notifications,
|
| bool ensure_initialized_and_updated) {
|
| if (!IsHistoryAndBookmarkRowValid(values))
|
| return false;
|
| @@ -390,11 +400,11 @@ AndroidURLID AndroidProviderBackend::InsertHistoryAndBookmark(
|
| return false;
|
| modified->changed_urls.push_back(url_row);
|
|
|
| - scoped_ptr<FaviconChangeDetails> favicon;
|
| + scoped_ptr<chrome::FaviconChangedDetails> favicon;
|
| // No favicon should be changed if the thumbnail_db_ is not available.
|
| if (row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) &&
|
| row.favicon_valid() && thumbnail_db_) {
|
| - favicon.reset(new FaviconChangeDetails);
|
| + favicon.reset(new chrome::FaviconChangedDetails);
|
| if (!favicon.get())
|
| return false;
|
| favicon->urls.insert(url_row.url());
|
| @@ -403,8 +413,7 @@ AndroidURLID AndroidProviderBackend::InsertHistoryAndBookmark(
|
| notifications->push_back(HistoryNotification(
|
| chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release()));
|
| if (favicon.get())
|
| - notifications->push_back(HistoryNotification(
|
| - chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release()));
|
| + favicon_notifications->push_back(favicon.release());
|
|
|
| return row.id();
|
| }
|
| @@ -438,7 +447,8 @@ bool AndroidProviderBackend::DeleteHistory(
|
| const std::string& selection,
|
| const std::vector<string16>& selection_args,
|
| int* deleted_count,
|
| - HistoryNotifications* notifications) {
|
| + HistoryNotifications* notifications,
|
| + FaviconNotifications* favicon_notifications) {
|
| if (!EnsureInitializedAndUpdated())
|
| return false;
|
|
|
| @@ -484,7 +494,8 @@ bool AndroidProviderBackend::DeleteHistory(
|
| // database during UpdateBookmark(), then the insertion will fail.
|
| // We can't rely on UpdateBookmark() to insert the bookmarks into history
|
| // database as the raw_url will be lost.
|
| - if (!InsertHistoryAndBookmark(*i, notifications, false))
|
| + if (!InsertHistoryAndBookmark(
|
| + *i, notifications, favicon_notifications, false))
|
| return false;
|
| }
|
| return true;
|
| @@ -975,7 +986,8 @@ bool AndroidProviderBackend::SimulateUpdateURL(
|
| new_row.set_title(statement->statement()->ColumnString16(3));
|
|
|
| scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails);
|
| - scoped_ptr<FaviconChangeDetails> favicon_details(new FaviconChangeDetails);
|
| + scoped_ptr<chrome::FaviconChangedDetails> favicon_details(
|
| + new chrome::FaviconChangedDetails);
|
| scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
|
| URLRow old_url_row;
|
| if (!history_db_->GetURLRow(ids[0].url_id, &old_url_row))
|
| @@ -1057,8 +1069,7 @@ bool AndroidProviderBackend::SimulateUpdateURL(
|
| chrome::NOTIFICATION_HISTORY_URLS_DELETED,
|
| deleted_details.release()));
|
| if (favicon_details.get() && !favicon_details->urls.empty())
|
| - notifications->push_back(HistoryNotification(
|
| - chrome::NOTIFICATION_FAVICON_CHANGED, favicon_details.release()));
|
| + favicon_notifications->push_back(favicon_details.release());
|
| notifications->push_back(HistoryNotification(
|
| chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release()));
|
|
|
| @@ -1104,7 +1115,8 @@ bool AndroidProviderBackend::DeleteHistoryInternal(
|
| bool delete_bookmarks,
|
| HistoryNotifications* notifications) {
|
| scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails);
|
| - scoped_ptr<FaviconChangeDetails> favicon(new FaviconChangeDetails);
|
| + scoped_ptr<chrome::FaviconChangedDetails> favicon(
|
| + new chrome::FaviconChangedDetails);
|
| for (TableIDRows::const_iterator i = urls.begin(); i != urls.end(); ++i) {
|
| URLRow url_row;
|
| if (!history_db_->GetURLRow(i->url_id, &url_row))
|
| @@ -1128,11 +1140,16 @@ bool AndroidProviderBackend::DeleteHistoryInternal(
|
| chrome::NOTIFICATION_HISTORY_URLS_DELETED,
|
| deleted_details.release()));
|
| if (favicon.get() && !favicon->urls.empty())
|
| - notifications->push_back(HistoryNotification(
|
| - chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release()));
|
| + favicon_notifications->push_back(favicon.release());
|
| return true;
|
| }
|
|
|
| +void AndroidProviderBackend::SendFaviconChangedNotifications(
|
| + const FaviconNotifications& favicon_notifications) {
|
| + for (size_t i = 0; i < favicon_notifications.size(); ++i)
|
| + delegate_->SendFaviconChangedNotification(favicon_notifications[i]);
|
| +}
|
| +
|
| void AndroidProviderBackend::BroadcastNotifications(
|
| const HistoryNotifications& notifications) {
|
| for (HistoryNotifications::const_iterator i = notifications.begin();
|
|
|