| Index: chrome/browser/history/android/favicon_sql_handler.cc
|
| diff --git a/chrome/browser/history/android/favicon_sql_handler.cc b/chrome/browser/history/android/favicon_sql_handler.cc
|
| index e42068bb1c5ddc44494a6271ed8073812c33e72f..af815b25436a4e3b5f3ddb388384b300bfc193fc 100644
|
| --- a/chrome/browser/history/android/favicon_sql_handler.cc
|
| +++ b/chrome/browser/history/android/favicon_sql_handler.cc
|
| @@ -51,22 +51,22 @@ bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row,
|
| std::vector<FaviconID> favicon_ids;
|
| for (TableIDRows::const_iterator i = ids_set.begin();
|
| i != ids_set.end(); ++i) {
|
| - IconMapping icon_mapping;
|
| - if (thumbnail_db_->GetIconMappingForPageURL(i->url, FAVICON,
|
| - &icon_mapping)) {
|
| - if (favicon_id) {
|
| - if (!thumbnail_db_->UpdateIconMapping(icon_mapping.mapping_id,
|
| - favicon_id))
|
| - return false;
|
| - } else {
|
| - // Require to delete the icon mapping.
|
| - if (!thumbnail_db_->DeleteIconMappings(i->url))
|
| - return false;
|
| + // Remove existing icon mappings.
|
| + std::vector<IconMapping> icon_mappings;
|
| + if (thumbnail_db_->GetIconMappingsForPageURL(i->url, FAVICON,
|
| + &icon_mappings)) {
|
| + for (std::vector<IconMapping>::const_iterator m = icon_mappings.begin();
|
| + m != icon_mappings.end(); ++m) {
|
| + if (m->icon_id != favicon_id) {
|
| + // Keep the old icon for deleting it later if possible.
|
| + favicon_ids.push_back(m->icon_id);
|
| + }
|
| }
|
| - // Keep the old icon for deleting it later if possible.
|
| - favicon_ids.push_back(icon_mapping.icon_id);
|
| - } else if (favicon_id) {
|
| - // The URL doesn't have icon before, add the icon mapping.
|
| + if (!thumbnail_db_->DeleteIconMappings(i->url))
|
| + return false;
|
| + }
|
| + if (favicon_id) {
|
| + // Add the icon mapping.
|
| if (!thumbnail_db_->AddIconMapping(i->url, favicon_id))
|
| return false;
|
| }
|
| @@ -82,17 +82,14 @@ bool FaviconSQLHandler::Delete(const TableIDRows& ids_set) {
|
| std::vector<FaviconID> favicon_ids;
|
| for (TableIDRows::const_iterator i = ids_set.begin();
|
| i != ids_set.end(); ++i) {
|
| - // Since the URL was delete, we delete all type of icon mapping.
|
| - IconMapping icon_mapping;
|
| - if (thumbnail_db_->GetIconMappingForPageURL(i->url, FAVICON,
|
| - &icon_mapping))
|
| - favicon_ids.push_back(icon_mapping.icon_id);
|
| - if (thumbnail_db_->GetIconMappingForPageURL(i->url, TOUCH_ICON,
|
| - &icon_mapping))
|
| - favicon_ids.push_back(icon_mapping.icon_id);
|
| - if (thumbnail_db_->GetIconMappingForPageURL(i->url,
|
| - TOUCH_PRECOMPOSED_ICON, &icon_mapping))
|
| - favicon_ids.push_back(icon_mapping.icon_id);
|
| + // Since the URL was deleted, we delete all types of icon mappings.
|
| + std::vector<IconMapping> icon_mappings;
|
| + if (thumbnail_db_->GetIconMappingsForPageURL(i->url, &icon_mappings)) {
|
| + for (std::vector<IconMapping>::const_iterator m = icon_mappings.begin();
|
| + m != icon_mappings.end(); ++m) {
|
| + favicon_ids.push_back(m->icon_id);
|
| + }
|
| + }
|
| if (!thumbnail_db_->DeleteIconMappings(i->url))
|
| return false;
|
| }
|
|
|