#include "base/i18n/case_conversion.h"
#include "chrome/browser/chrome_notification_types.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"
#include "chrome/browser/history/thumbnail_database.h"
#include "components/history/core/browser/history_client.h"
#include "components/history/core/browser/keyword_search_term.h"
-#include "content/public/common/page_transition_types.h"
#include "sql/connection.h"
return true;
}
-} // namespace
-
-
-// AndroidProviderBackend::HistoryNotifications -------------------------------
-
-AndroidProviderBackend::HistoryNotifications::HistoryNotifications() {
-}
-
-AndroidProviderBackend::HistoryNotifications::~HistoryNotifications() {
-}
-
-void AndroidProviderBackend::HistoryNotifications::PushBack(
- int type,
- scoped_ptr<HistoryDetails> detail) {
- DCHECK_EQ(types_.size(), details_.size());
- types_.push_back(type);
- details_.push_back(detail.release());
-}
-
-int AndroidProviderBackend::HistoryNotifications::PopBackType() {
- DCHECK(!empty());
- int type = types_.back();
- types_.pop_back();
- return type;
-}
-
-scoped_ptr<HistoryDetails>
- AndroidProviderBackend::HistoryNotifications::PopBackDetails() {
- DCHECK(!details_.empty());
- scoped_ptr<HistoryDetails> detail(details_.back());
- details_.weak_erase(details_.end() - 1);
- return detail.Pass();
+void RunNotifyFaviconChanged(HistoryBackend::Delegate* delegate,
+ scoped_ptr<std::set<GURL> > changed_favicons) {
+ delegate->NotifyFaviconChanged(*changed_favicons);
}
+} // namespace
// AndroidProviderBackend::ScopedTransaction ----------------------------------
*updated_count = ids_set.size();
scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
- scoped_ptr<FaviconChangedDetails> favicon(new FaviconChangedDetails);
+ scoped_ptr<std::set<GURL> > favicon(new std::set<GURL>);
for (TableIDRows::const_iterator i = ids_set.begin(); i != ids_set.end();
++i) {
}
if (thumbnail_db_ &&
row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON))
- favicon->urls.insert(i->url);
+ favicon->insert(i->url);
}
if (!modified->changed_urls.empty()) {
- notifications->PushBack(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED,
- modified.PassAs<HistoryDetails>());
+ scoped_ptr<HistoryDetails> details = modified.PassAs<HistoryDetails>();
+ notifications->push_back(
+ base::Bind(&HistoryBackend::Delegate::BroadcastNotifications,
+ base::Unretained(delegate_),
+ chrome::NOTIFICATION_HISTORY_URLS_MODIFIED,
+ base::Passed(&details)));
}
- if (!favicon->urls.empty()) {
- notifications->PushBack(chrome::NOTIFICATION_FAVICON_CHANGED,
- favicon.PassAs<HistoryDetails>());
+ if (!favicon->empty()) {
+ notifications->push_back(base::Bind(&RunNotifyFaviconChanged,
+ base::Unretained(delegate_),
+ base::Passed(&favicon)));
}
return true;
return false;
scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
- if (!modified.get())
- return false;
modified->changed_urls.push_back(url_row);
- scoped_ptr<FaviconChangedDetails> favicon;
+ scoped_ptr<std::set<GURL> > 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 FaviconChangedDetails);
- if (!favicon.get())
- return false;
- favicon->urls.insert(url_row.url());
+ favicon.reset(new std::set<GURL>);
+ favicon->insert(url_row.url());
}
- notifications->PushBack(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED,
- modified.PassAs<HistoryDetails>());
+ scoped_ptr<HistoryDetails> details = modified.PassAs<HistoryDetails>();
+ notifications->push_back(
+ base::Bind(&HistoryBackend::Delegate::BroadcastNotifications,
+ base::Unretained(delegate_),
+ chrome::NOTIFICATION_HISTORY_URLS_MODIFIED,
+ base::Passed(&details)));
+
if (favicon) {
- notifications->PushBack(chrome::NOTIFICATION_FAVICON_CHANGED,
- favicon.PassAs<HistoryDetails>());
+ DCHECK(!favicon->empty());
+ notifications->push_back(base::Bind(&RunNotifyFaviconChanged,
+ base::Unretained(delegate_),
+ base::Passed(&favicon)));
}
return row.id();
new_row.set_title(statement->statement()->ColumnString16(3));
scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails);
- scoped_ptr<FaviconChangedDetails> favicon_details(new FaviconChangedDetails);
+ scoped_ptr<std::set<GURL> > favicons(new std::set<GURL>);
scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
URLRow old_url_row;
if (!history_db_->GetURLRow(ids[0].url_id, &old_url_row))
favicon_bitmaps[0].bitmap_data;
if (bitmap_data.get() && bitmap_data->size())
new_row.set_favicon(bitmap_data);
- favicon_details->urls.insert(old_url_row.url());
- favicon_details->urls.insert(row.url());
+ favicons->insert(old_url_row.url());
+ favicons->insert(row.url());
}
new_row.set_is_bookmark(statement->statement()->ColumnBool(5));
new_row.set_title(row.title());
if (row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON)) {
new_row.set_favicon(row.favicon());
- favicon_details->urls.insert(new_row.url());
+ favicons->insert(new_row.url());
}
if (row.is_value_set_explicitly(HistoryAndBookmarkRow::BOOKMARK))
new_row.set_is_bookmark(row.is_bookmark());
modified->changed_urls.push_back(new_url_row);
- notifications->PushBack(chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- deleted_details.PassAs<HistoryDetails>());
- if (favicon_details && !favicon_details->urls.empty()) {
- notifications->PushBack(chrome::NOTIFICATION_FAVICON_CHANGED,
- favicon_details.PassAs<HistoryDetails>());
+ scoped_ptr<HistoryDetails> details = deleted_details.PassAs<HistoryDetails>();
+ notifications->push_back(
+ base::Bind(&HistoryBackend::Delegate::BroadcastNotifications,
+ base::Unretained(delegate_),
+ chrome::NOTIFICATION_HISTORY_URLS_DELETED,
+ base::Passed(&details)));
+ if (favicons && !favicons->empty()) {
+ notifications->push_back(base::Bind(&RunNotifyFaviconChanged,
+ base::Unretained(delegate_),
+ base::Passed(&favicons)));
}
- notifications->PushBack(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED,
- modified.PassAs<HistoryDetails>());
+ scoped_ptr<HistoryDetails> other_details = modified.PassAs<HistoryDetails>();
+ notifications->push_back(
+ base::Bind(&HistoryBackend::Delegate::BroadcastNotifications,
+ base::Unretained(delegate_),
+ chrome::NOTIFICATION_HISTORY_URLS_MODIFIED,
+ base::Passed(&other_details)));
return true;
}
bool delete_bookmarks,
HistoryNotifications* notifications) {
scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails);
- scoped_ptr<FaviconChangedDetails> favicon(new FaviconChangedDetails);
+ scoped_ptr<std::set<GURL> > favicon(new std::set<GURL>);
for (TableIDRows::const_iterator i = urls.begin(); i != urls.end(); ++i) {
URLRow url_row;
if (!history_db_->GetURLRow(i->url_id, &url_row))
deleted_details->rows.push_back(url_row);
if (thumbnail_db_ &&
thumbnail_db_->GetIconMappingsForPageURL(url_row.url(), NULL))
- favicon->urls.insert(url_row.url());
+ favicon->insert(url_row.url());
}
// Only invoke Delete on the BookmarkModelHandler if we need
return false;
}
- notifications->PushBack(chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- deleted_details.PassAs<HistoryDetails>());
- if (favicon && !favicon->urls.empty()) {
- notifications->PushBack(chrome::NOTIFICATION_FAVICON_CHANGED,
- favicon.PassAs<HistoryDetails>());
+ scoped_ptr<HistoryDetails> details = deleted_details.PassAs<HistoryDetails>();
+ notifications->push_back(
+ base::Bind(&HistoryBackend::Delegate::BroadcastNotifications,
+ base::Unretained(delegate_),
+ chrome::NOTIFICATION_HISTORY_URLS_DELETED,
+ base::Passed(&details)));
+ if (favicon && !favicon->empty()) {
+ notifications->push_back(base::Bind(&RunNotifyFaviconChanged,
+ base::Unretained(delegate_),
+ base::Passed(&favicon)));
}
return true;
}
void AndroidProviderBackend::BroadcastNotifications(
HistoryNotifications* notifications) {
while (!notifications->empty()) {
- delegate_->BroadcastNotifications(notifications->PopBackType(),
- notifications->PopBackDetails());
+ notifications->back().Run();
+ notifications->pop_back();
}
}