Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1465)

Unified Diff: chrome/browser/history/android/android_provider_backend.cc

Issue 15275004: bookmarks: Get rid of the dependency on history_notifications.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more android fixes Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,
- &notifications))
+ &notifications, &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, &notifications, true);
+ AndroidURLID id = InsertHistoryAndBookmark(
+ values, &notifications, &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,
- &notifications))
+ &notifications, &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();

Powered by Google App Engine
This is Rietveld 408576698