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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/favicon/favicon_changed_details.h"
9 #include "chrome/browser/history/android/android_time.h" 10 #include "chrome/browser/history/android/android_time.h"
10 #include "chrome/browser/history/android/android_urls_sql_handler.h" 11 #include "chrome/browser/history/android/android_urls_sql_handler.h"
11 #include "chrome/browser/history/android/bookmark_model_sql_handler.h" 12 #include "chrome/browser/history/android/bookmark_model_sql_handler.h"
12 #include "chrome/browser/history/android/favicon_sql_handler.h" 13 #include "chrome/browser/history/android/favicon_sql_handler.h"
13 #include "chrome/browser/history/android/urls_sql_handler.h" 14 #include "chrome/browser/history/android/urls_sql_handler.h"
14 #include "chrome/browser/history/android/visit_sql_handler.h" 15 #include "chrome/browser/history/android/visit_sql_handler.h"
15 #include "chrome/browser/history/history_backend.h" 16 #include "chrome/browser/history/history_backend.h"
16 #include "chrome/browser/history/history_database.h" 17 #include "chrome/browser/history/history_database.h"
17 #include "chrome/browser/history/thumbnail_database.h" 18 #include "chrome/browser/history/thumbnail_database.h"
18 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return QueryHistoryAndBookmarksInternal(projections, selection, 152 return QueryHistoryAndBookmarksInternal(projections, selection,
152 selection_args, sort_order); 153 selection_args, sort_order);
153 } 154 }
154 155
155 bool AndroidProviderBackend::UpdateHistoryAndBookmarks( 156 bool AndroidProviderBackend::UpdateHistoryAndBookmarks(
156 const HistoryAndBookmarkRow& row, 157 const HistoryAndBookmarkRow& row,
157 const std::string& selection, 158 const std::string& selection,
158 const std::vector<string16>& selection_args, 159 const std::vector<string16>& selection_args,
159 int* updated_count) { 160 int* updated_count) {
160 HistoryNotifications notifications; 161 HistoryNotifications notifications;
162 FaviconNotifications favicon_notifications;
161 163
162 ScopedTransaction transaction(history_db_, thumbnail_db_); 164 ScopedTransaction transaction(history_db_, thumbnail_db_);
163 165
164 if (!UpdateHistoryAndBookmarks(row, selection, selection_args, updated_count, 166 if (!UpdateHistoryAndBookmarks(row, selection, selection_args, updated_count,
165 &notifications)) 167 &notifications, &favicon_notifications))
166 return false; 168 return false;
167 169
168 transaction.Commit(); 170 transaction.Commit();
171 SendFaviconChangedNotifications(favicon_notifications);
169 BroadcastNotifications(notifications); 172 BroadcastNotifications(notifications);
170 return true; 173 return true;
171 } 174 }
172 175
173 AndroidURLID AndroidProviderBackend::InsertHistoryAndBookmark( 176 AndroidURLID AndroidProviderBackend::InsertHistoryAndBookmark(
174 const HistoryAndBookmarkRow& values) { 177 const HistoryAndBookmarkRow& values) {
175 HistoryNotifications notifications; 178 HistoryNotifications notifications;
179 FaviconNotifications favicon_notifications;
176 180
177 ScopedTransaction transaction(history_db_, thumbnail_db_); 181 ScopedTransaction transaction(history_db_, thumbnail_db_);
178 182
179 AndroidURLID id = InsertHistoryAndBookmark(values, &notifications, true); 183 AndroidURLID id = InsertHistoryAndBookmark(
184 values, &notifications, &favicon_notifications, true);
180 if (id) { 185 if (id) {
181 transaction.Commit(); 186 transaction.Commit();
182 BroadcastNotifications(notifications); 187 BroadcastNotifications(notifications);
188 SendFaviconChangedNotifications(favicon_notifications);
183 return id; 189 return id;
184 } 190 }
185 return 0; 191 return 0;
186 } 192 }
187 193
188 bool AndroidProviderBackend::DeleteHistoryAndBookmarks( 194 bool AndroidProviderBackend::DeleteHistoryAndBookmarks(
189 const std::string& selection, 195 const std::string& selection,
190 const std::vector<string16>& selection_args, 196 const std::vector<string16>& selection_args,
191 int* deleted_count) { 197 int* deleted_count) {
192 HistoryNotifications notifications; 198 HistoryNotifications notifications;
193 199
194 ScopedTransaction transaction(history_db_, thumbnail_db_); 200 ScopedTransaction transaction(history_db_, thumbnail_db_);
195 201
196 if (!DeleteHistoryAndBookmarks(selection, selection_args, deleted_count, 202 if (!DeleteHistoryAndBookmarks(selection, selection_args, deleted_count,
197 &notifications)) 203 &notifications))
198 return false; 204 return false;
199 205
200 transaction.Commit(); 206 transaction.Commit();
201 BroadcastNotifications(notifications); 207 BroadcastNotifications(notifications);
202 return true; 208 return true;
203 } 209 }
204 210
205 bool AndroidProviderBackend::DeleteHistory( 211 bool AndroidProviderBackend::DeleteHistory(
206 const std::string& selection, 212 const std::string& selection,
207 const std::vector<string16>& selection_args, 213 const std::vector<string16>& selection_args,
208 int* deleted_count) { 214 int* deleted_count) {
209 HistoryNotifications notifications; 215 HistoryNotifications notifications;
216 FaviconNotifications favicon_notifications;
210 217
211 ScopedTransaction transaction(history_db_, thumbnail_db_); 218 ScopedTransaction transaction(history_db_, thumbnail_db_);
212 219
213 if (!DeleteHistory(selection, selection_args, deleted_count, 220 if (!DeleteHistory(selection, selection_args, deleted_count,
214 &notifications)) 221 &notifications, &favicon_notifications))
215 return false; 222 return false;
216 223
217 transaction.Commit(); 224 transaction.Commit();
218 BroadcastNotifications(notifications); 225 BroadcastNotifications(notifications);
226 SendFaviconChangedNotifications(favicon_notifications);
219 return true; 227 return true;
220 } 228 }
221 229
222 AndroidProviderBackend::HistoryNotification::HistoryNotification( 230 AndroidProviderBackend::HistoryNotification::HistoryNotification(
223 int type, 231 int type,
224 HistoryDetails* detail) 232 HistoryDetails* detail)
225 : type(type), 233 : type(type),
226 detail(detail) { 234 detail(detail) {
227 } 235 }
228 236
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 if (thumbnail_db_) 292 if (thumbnail_db_)
285 thumbnail_db_->CommitTransaction(); 293 thumbnail_db_->CommitTransaction();
286 committed_ = true; 294 committed_ = true;
287 } 295 }
288 296
289 bool AndroidProviderBackend::UpdateHistoryAndBookmarks( 297 bool AndroidProviderBackend::UpdateHistoryAndBookmarks(
290 const HistoryAndBookmarkRow& row, 298 const HistoryAndBookmarkRow& row,
291 const std::string& selection, 299 const std::string& selection,
292 const std::vector<string16>& selection_args, 300 const std::vector<string16>& selection_args,
293 int* updated_count, 301 int* updated_count,
294 HistoryNotifications* notifications) { 302 HistoryNotifications* notifications,
303 FaviconNotifications* favicon_notifications) {
295 if (!IsHistoryAndBookmarkRowValid(row)) 304 if (!IsHistoryAndBookmarkRowValid(row))
296 return false; 305 return false;
297 306
298 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::ID)) 307 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::ID))
299 return false; 308 return false;
300 309
301 if (!EnsureInitializedAndUpdated()) 310 if (!EnsureInitializedAndUpdated())
302 return false; 311 return false;
303 312
304 TableIDRows ids_set; 313 TableIDRows ids_set;
(...skipping 22 matching lines...) Expand all
327 for (std::vector<SQLHandler*>::iterator i = 336 for (std::vector<SQLHandler*>::iterator i =
328 sql_handlers_.begin(); i != sql_handlers_.end(); ++i) { 337 sql_handlers_.begin(); i != sql_handlers_.end(); ++i) {
329 if ((*i)->HasColumnIn(row)) { 338 if ((*i)->HasColumnIn(row)) {
330 if (!(*i)->Update(row, ids_set)) 339 if (!(*i)->Update(row, ids_set))
331 return false; 340 return false;
332 } 341 }
333 } 342 }
334 *updated_count = ids_set.size(); 343 *updated_count = ids_set.size();
335 344
336 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails); 345 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
337 scoped_ptr<FaviconChangeDetails> favicon(new FaviconChangeDetails); 346 scoped_ptr<chrome::FaviconChangedDetails> favicon(
347 new chrome::FaviconChangedDetails);
338 348
339 for (TableIDRows::const_iterator i = ids_set.begin(); i != ids_set.end(); 349 for (TableIDRows::const_iterator i = ids_set.begin(); i != ids_set.end();
340 ++i) { 350 ++i) {
341 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::TITLE) || 351 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::TITLE) ||
342 row.is_value_set_explicitly(HistoryAndBookmarkRow::VISIT_COUNT) || 352 row.is_value_set_explicitly(HistoryAndBookmarkRow::VISIT_COUNT) ||
343 row.is_value_set_explicitly(HistoryAndBookmarkRow::LAST_VISIT_TIME)) { 353 row.is_value_set_explicitly(HistoryAndBookmarkRow::LAST_VISIT_TIME)) {
344 URLRow url_row; 354 URLRow url_row;
345 if (!history_db_->GetURLRow(i->url_id, &url_row)) 355 if (!history_db_->GetURLRow(i->url_id, &url_row))
346 return false; 356 return false;
347 modified->changed_urls.push_back(url_row); 357 modified->changed_urls.push_back(url_row);
348 } 358 }
349 if (thumbnail_db_ && 359 if (thumbnail_db_ &&
350 row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON)) 360 row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON))
351 favicon->urls.insert(i->url); 361 favicon->urls.insert(i->url);
352 } 362 }
353 363
354 if (!modified->changed_urls.empty()) 364 if (!modified->changed_urls.empty())
355 notifications->push_back(HistoryNotification( 365 notifications->push_back(HistoryNotification(
356 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release())); 366 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release()));
357 367
358 if (!favicon->urls.empty()) 368 if (!favicon->urls.empty())
359 notifications->push_back(HistoryNotification( 369 favicon_notifications->push_back(favicon.release());
360 chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release()));
361 370
362 return true; 371 return true;
363 } 372 }
364 373
365 AndroidURLID AndroidProviderBackend::InsertHistoryAndBookmark( 374 AndroidURLID AndroidProviderBackend::InsertHistoryAndBookmark(
366 const HistoryAndBookmarkRow& values, 375 const HistoryAndBookmarkRow& values,
367 HistoryNotifications* notifications, 376 HistoryNotifications* notifications,
377 FaviconNotifications* favicon_notifications,
368 bool ensure_initialized_and_updated) { 378 bool ensure_initialized_and_updated) {
369 if (!IsHistoryAndBookmarkRowValid(values)) 379 if (!IsHistoryAndBookmarkRowValid(values))
370 return false; 380 return false;
371 381
372 if (ensure_initialized_and_updated && !EnsureInitializedAndUpdated()) 382 if (ensure_initialized_and_updated && !EnsureInitializedAndUpdated())
373 return 0; 383 return 0;
374 384
375 DCHECK(values.is_value_set_explicitly(HistoryAndBookmarkRow::URL)); 385 DCHECK(values.is_value_set_explicitly(HistoryAndBookmarkRow::URL));
376 // Make a copy of values as we need change it during insert. 386 // Make a copy of values as we need change it during insert.
377 HistoryAndBookmarkRow row = values; 387 HistoryAndBookmarkRow row = values;
378 for (std::vector<SQLHandler*>::iterator i = 388 for (std::vector<SQLHandler*>::iterator i =
379 sql_handlers_.begin(); i != sql_handlers_.end(); ++i) { 389 sql_handlers_.begin(); i != sql_handlers_.end(); ++i) {
380 if (!(*i)->Insert(&row)) 390 if (!(*i)->Insert(&row))
381 return 0; 391 return 0;
382 } 392 }
383 393
384 URLRow url_row; 394 URLRow url_row;
385 if (!history_db_->GetURLRow(row.url_id(), &url_row)) 395 if (!history_db_->GetURLRow(row.url_id(), &url_row))
386 return false; 396 return false;
387 397
388 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails); 398 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
389 if (!modified.get()) 399 if (!modified.get())
390 return false; 400 return false;
391 modified->changed_urls.push_back(url_row); 401 modified->changed_urls.push_back(url_row);
392 402
393 scoped_ptr<FaviconChangeDetails> favicon; 403 scoped_ptr<chrome::FaviconChangedDetails> favicon;
394 // No favicon should be changed if the thumbnail_db_ is not available. 404 // No favicon should be changed if the thumbnail_db_ is not available.
395 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) && 405 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) &&
396 row.favicon_valid() && thumbnail_db_) { 406 row.favicon_valid() && thumbnail_db_) {
397 favicon.reset(new FaviconChangeDetails); 407 favicon.reset(new chrome::FaviconChangedDetails);
398 if (!favicon.get()) 408 if (!favicon.get())
399 return false; 409 return false;
400 favicon->urls.insert(url_row.url()); 410 favicon->urls.insert(url_row.url());
401 } 411 }
402 412
403 notifications->push_back(HistoryNotification( 413 notifications->push_back(HistoryNotification(
404 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release())); 414 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release()));
405 if (favicon.get()) 415 if (favicon.get())
406 notifications->push_back(HistoryNotification( 416 favicon_notifications->push_back(favicon.release());
407 chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release()));
408 417
409 return row.id(); 418 return row.id();
410 } 419 }
411 420
412 bool AndroidProviderBackend::DeleteHistoryAndBookmarks( 421 bool AndroidProviderBackend::DeleteHistoryAndBookmarks(
413 const std::string& selection, 422 const std::string& selection,
414 const std::vector<string16>& selection_args, 423 const std::vector<string16>& selection_args,
415 int * deleted_count, 424 int * deleted_count,
416 HistoryNotifications* notifications) { 425 HistoryNotifications* notifications) {
417 if (!EnsureInitializedAndUpdated()) 426 if (!EnsureInitializedAndUpdated())
(...skipping 13 matching lines...) Expand all
431 440
432 *deleted_count = ids_set.size(); 441 *deleted_count = ids_set.size();
433 442
434 return true; 443 return true;
435 } 444 }
436 445
437 bool AndroidProviderBackend::DeleteHistory( 446 bool AndroidProviderBackend::DeleteHistory(
438 const std::string& selection, 447 const std::string& selection,
439 const std::vector<string16>& selection_args, 448 const std::vector<string16>& selection_args,
440 int* deleted_count, 449 int* deleted_count,
441 HistoryNotifications* notifications) { 450 HistoryNotifications* notifications,
451 FaviconNotifications* favicon_notifications) {
442 if (!EnsureInitializedAndUpdated()) 452 if (!EnsureInitializedAndUpdated())
443 return false; 453 return false;
444 454
445 TableIDRows ids_set; 455 TableIDRows ids_set;
446 if (!GetSelectedURLs(selection, selection_args, &ids_set)) 456 if (!GetSelectedURLs(selection, selection_args, &ids_set))
447 return false; 457 return false;
448 458
449 if (ids_set.empty()) { 459 if (ids_set.empty()) {
450 *deleted_count = 0; 460 *deleted_count = 0;
451 return true; 461 return true;
(...skipping 25 matching lines...) Expand all
477 // Don't delete the bookmark from bookmark model when deleting the history. 487 // Don't delete the bookmark from bookmark model when deleting the history.
478 if (!DeleteHistoryInternal(ids_set, false, notifications)) 488 if (!DeleteHistoryInternal(ids_set, false, notifications))
479 return false; 489 return false;
480 490
481 for (std::vector<HistoryAndBookmarkRow>::const_iterator i = bookmarks.begin(); 491 for (std::vector<HistoryAndBookmarkRow>::const_iterator i = bookmarks.begin();
482 i != bookmarks.end(); ++i) { 492 i != bookmarks.end(); ++i) {
483 // Don't update the tables, otherwise, the bookmarks will be added to 493 // Don't update the tables, otherwise, the bookmarks will be added to
484 // database during UpdateBookmark(), then the insertion will fail. 494 // database during UpdateBookmark(), then the insertion will fail.
485 // We can't rely on UpdateBookmark() to insert the bookmarks into history 495 // We can't rely on UpdateBookmark() to insert the bookmarks into history
486 // database as the raw_url will be lost. 496 // database as the raw_url will be lost.
487 if (!InsertHistoryAndBookmark(*i, notifications, false)) 497 if (!InsertHistoryAndBookmark(
498 *i, notifications, favicon_notifications, false))
488 return false; 499 return false;
489 } 500 }
490 return true; 501 return true;
491 } 502 }
492 503
493 AndroidStatement* AndroidProviderBackend::QuerySearchTerms( 504 AndroidStatement* AndroidProviderBackend::QuerySearchTerms(
494 const std::vector<SearchRow::ColumnID>& projections, 505 const std::vector<SearchRow::ColumnID>& projections,
495 const std::string& selection, 506 const std::string& selection,
496 const std::vector<string16>& selection_args, 507 const std::vector<string16>& selection_args,
497 const std::string& sort_order) { 508 const std::string& sort_order) {
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 979
969 HistoryAndBookmarkRow new_row; 980 HistoryAndBookmarkRow new_row;
970 new_row.set_last_visit_time(FromDatabaseTime( 981 new_row.set_last_visit_time(FromDatabaseTime(
971 statement->statement()->ColumnInt64(0))); 982 statement->statement()->ColumnInt64(0)));
972 new_row.set_created(FromDatabaseTime( 983 new_row.set_created(FromDatabaseTime(
973 statement->statement()->ColumnInt64(1))); 984 statement->statement()->ColumnInt64(1)));
974 new_row.set_visit_count(statement->statement()->ColumnInt(2)); 985 new_row.set_visit_count(statement->statement()->ColumnInt(2));
975 new_row.set_title(statement->statement()->ColumnString16(3)); 986 new_row.set_title(statement->statement()->ColumnString16(3));
976 987
977 scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails); 988 scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails);
978 scoped_ptr<FaviconChangeDetails> favicon_details(new FaviconChangeDetails); 989 scoped_ptr<chrome::FaviconChangedDetails> favicon_details(
990 new chrome::FaviconChangedDetails);
979 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails); 991 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
980 URLRow old_url_row; 992 URLRow old_url_row;
981 if (!history_db_->GetURLRow(ids[0].url_id, &old_url_row)) 993 if (!history_db_->GetURLRow(ids[0].url_id, &old_url_row))
982 return false; 994 return false;
983 deleted_details->rows.push_back(old_url_row); 995 deleted_details->rows.push_back(old_url_row);
984 996
985 chrome::FaviconID favicon_id = statement->statement()->ColumnInt64(4); 997 chrome::FaviconID favicon_id = statement->statement()->ColumnInt64(4);
986 if (favicon_id) { 998 if (favicon_id) {
987 std::vector<FaviconBitmap> favicon_bitmaps; 999 std::vector<FaviconBitmap> favicon_bitmaps;
988 if (!thumbnail_db_ || 1000 if (!thumbnail_db_ ||
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 URLRow new_url_row; 1062 URLRow new_url_row;
1051 if (!history_db_->GetURLRow(new_row.url_id(), &new_url_row)) 1063 if (!history_db_->GetURLRow(new_row.url_id(), &new_url_row))
1052 return false; 1064 return false;
1053 1065
1054 modified->changed_urls.push_back(new_url_row); 1066 modified->changed_urls.push_back(new_url_row);
1055 1067
1056 notifications->push_back(HistoryNotification( 1068 notifications->push_back(HistoryNotification(
1057 chrome::NOTIFICATION_HISTORY_URLS_DELETED, 1069 chrome::NOTIFICATION_HISTORY_URLS_DELETED,
1058 deleted_details.release())); 1070 deleted_details.release()));
1059 if (favicon_details.get() && !favicon_details->urls.empty()) 1071 if (favicon_details.get() && !favicon_details->urls.empty())
1060 notifications->push_back(HistoryNotification( 1072 favicon_notifications->push_back(favicon_details.release());
1061 chrome::NOTIFICATION_FAVICON_CHANGED, favicon_details.release()));
1062 notifications->push_back(HistoryNotification( 1073 notifications->push_back(HistoryNotification(
1063 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release())); 1074 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release()));
1064 1075
1065 return true; 1076 return true;
1066 } 1077 }
1067 1078
1068 AndroidStatement* AndroidProviderBackend::QueryHistoryAndBookmarksInternal( 1079 AndroidStatement* AndroidProviderBackend::QueryHistoryAndBookmarksInternal(
1069 const std::vector<HistoryAndBookmarkRow::ColumnID>& projections, 1080 const std::vector<HistoryAndBookmarkRow::ColumnID>& projections,
1070 const std::string& selection, 1081 const std::string& selection,
1071 const std::vector<string16>& selection_args, 1082 const std::vector<string16>& selection_args,
(...skipping 25 matching lines...) Expand all
1097 } 1108 }
1098 sql::Statement* result = statement.release(); 1109 sql::Statement* result = statement.release();
1099 return new AndroidStatement(result, replaced_index); 1110 return new AndroidStatement(result, replaced_index);
1100 } 1111 }
1101 1112
1102 bool AndroidProviderBackend::DeleteHistoryInternal( 1113 bool AndroidProviderBackend::DeleteHistoryInternal(
1103 const TableIDRows& urls, 1114 const TableIDRows& urls,
1104 bool delete_bookmarks, 1115 bool delete_bookmarks,
1105 HistoryNotifications* notifications) { 1116 HistoryNotifications* notifications) {
1106 scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails); 1117 scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails);
1107 scoped_ptr<FaviconChangeDetails> favicon(new FaviconChangeDetails); 1118 scoped_ptr<chrome::FaviconChangedDetails> favicon(
1119 new chrome::FaviconChangedDetails);
1108 for (TableIDRows::const_iterator i = urls.begin(); i != urls.end(); ++i) { 1120 for (TableIDRows::const_iterator i = urls.begin(); i != urls.end(); ++i) {
1109 URLRow url_row; 1121 URLRow url_row;
1110 if (!history_db_->GetURLRow(i->url_id, &url_row)) 1122 if (!history_db_->GetURLRow(i->url_id, &url_row))
1111 return false; 1123 return false;
1112 deleted_details->rows.push_back(url_row); 1124 deleted_details->rows.push_back(url_row);
1113 if (thumbnail_db_ && 1125 if (thumbnail_db_ &&
1114 thumbnail_db_->GetIconMappingsForPageURL(url_row.url(), NULL)) 1126 thumbnail_db_->GetIconMappingsForPageURL(url_row.url(), NULL))
1115 favicon->urls.insert(url_row.url()); 1127 favicon->urls.insert(url_row.url());
1116 } 1128 }
1117 1129
1118 // Only invoke Delete on the BookmarkModelHandler if we need 1130 // Only invoke Delete on the BookmarkModelHandler if we need
1119 // to delete bookmarks. 1131 // to delete bookmarks.
1120 for (std::vector<SQLHandler*>::iterator i = 1132 for (std::vector<SQLHandler*>::iterator i =
1121 sql_handlers_.begin(); i != sql_handlers_.end(); ++i) { 1133 sql_handlers_.begin(); i != sql_handlers_.end(); ++i) {
1122 if ((*i) != bookmark_model_handler_.get() || delete_bookmarks) 1134 if ((*i) != bookmark_model_handler_.get() || delete_bookmarks)
1123 if (!(*i)->Delete(urls)) 1135 if (!(*i)->Delete(urls))
1124 return false; 1136 return false;
1125 } 1137 }
1126 1138
1127 notifications->push_back(HistoryNotification( 1139 notifications->push_back(HistoryNotification(
1128 chrome::NOTIFICATION_HISTORY_URLS_DELETED, 1140 chrome::NOTIFICATION_HISTORY_URLS_DELETED,
1129 deleted_details.release())); 1141 deleted_details.release()));
1130 if (favicon.get() && !favicon->urls.empty()) 1142 if (favicon.get() && !favicon->urls.empty())
1131 notifications->push_back(HistoryNotification( 1143 favicon_notifications->push_back(favicon.release());
1132 chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release()));
1133 return true; 1144 return true;
1134 } 1145 }
1135 1146
1147 void AndroidProviderBackend::SendFaviconChangedNotifications(
1148 const FaviconNotifications& favicon_notifications) {
1149 for (size_t i = 0; i < favicon_notifications.size(); ++i)
1150 delegate_->SendFaviconChangedNotification(favicon_notifications[i]);
1151 }
1152
1136 void AndroidProviderBackend::BroadcastNotifications( 1153 void AndroidProviderBackend::BroadcastNotifications(
1137 const HistoryNotifications& notifications) { 1154 const HistoryNotifications& notifications) {
1138 for (HistoryNotifications::const_iterator i = notifications.begin(); 1155 for (HistoryNotifications::const_iterator i = notifications.begin();
1139 i != notifications.end(); ++i) { 1156 i != notifications.end(); ++i) {
1140 delegate_->BroadcastNotifications(i->type, i->detail); 1157 delegate_->BroadcastNotifications(i->type, i->detail);
1141 } 1158 }
1142 } 1159 }
1143 1160
1144 bool AndroidProviderBackend::AddSearchTerm(const SearchRow& values) { 1161 bool AndroidProviderBackend::AddSearchTerm(const SearchRow& values) {
1145 DCHECK(values.is_value_set_explicitly(SearchRow::SEARCH_TERM)); 1162 DCHECK(values.is_value_set_explicitly(SearchRow::SEARCH_TERM));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 return false; 1203 return false;
1187 1204
1188 if (!history_db_->SetKeywordSearchTermsForURL(bookmark_row.url_id(), 1205 if (!history_db_->SetKeywordSearchTermsForURL(bookmark_row.url_id(),
1189 values.template_url_id(), values.search_term())) 1206 values.template_url_id(), values.search_term()))
1190 return false; 1207 return false;
1191 } 1208 }
1192 return true; 1209 return true;
1193 } 1210 }
1194 1211
1195 } // namespace history 1212 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698