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

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: add files back 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 for (std::vector<SQLHandler*>::iterator i = 328 for (std::vector<SQLHandler*>::iterator i =
328 sql_handlers_.begin(); i != sql_handlers_.end(); ++i) { 329 sql_handlers_.begin(); i != sql_handlers_.end(); ++i) {
329 if ((*i)->HasColumnIn(row)) { 330 if ((*i)->HasColumnIn(row)) {
330 if (!(*i)->Update(row, ids_set)) 331 if (!(*i)->Update(row, ids_set))
331 return false; 332 return false;
332 } 333 }
333 } 334 }
334 *updated_count = ids_set.size(); 335 *updated_count = ids_set.size();
335 336
336 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails); 337 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
337 scoped_ptr<FaviconChangeDetails> favicon(new FaviconChangeDetails); 338 scoped_ptr<FaviconChangedDetails> favicon(new FaviconChangedDetails);
338 339
339 for (TableIDRows::const_iterator i = ids_set.begin(); i != ids_set.end(); 340 for (TableIDRows::const_iterator i = ids_set.begin(); i != ids_set.end();
340 ++i) { 341 ++i) {
341 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::TITLE) || 342 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::TITLE) ||
342 row.is_value_set_explicitly(HistoryAndBookmarkRow::VISIT_COUNT) || 343 row.is_value_set_explicitly(HistoryAndBookmarkRow::VISIT_COUNT) ||
343 row.is_value_set_explicitly(HistoryAndBookmarkRow::LAST_VISIT_TIME)) { 344 row.is_value_set_explicitly(HistoryAndBookmarkRow::LAST_VISIT_TIME)) {
344 URLRow url_row; 345 URLRow url_row;
345 if (!history_db_->GetURLRow(i->url_id, &url_row)) 346 if (!history_db_->GetURLRow(i->url_id, &url_row))
346 return false; 347 return false;
347 modified->changed_urls.push_back(url_row); 348 modified->changed_urls.push_back(url_row);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 384
384 URLRow url_row; 385 URLRow url_row;
385 if (!history_db_->GetURLRow(row.url_id(), &url_row)) 386 if (!history_db_->GetURLRow(row.url_id(), &url_row))
386 return false; 387 return false;
387 388
388 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails); 389 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
389 if (!modified.get()) 390 if (!modified.get())
390 return false; 391 return false;
391 modified->changed_urls.push_back(url_row); 392 modified->changed_urls.push_back(url_row);
392 393
393 scoped_ptr<FaviconChangeDetails> favicon; 394 scoped_ptr<FaviconChangedDetails> favicon;
394 // No favicon should be changed if the thumbnail_db_ is not available. 395 // No favicon should be changed if the thumbnail_db_ is not available.
395 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) && 396 if (row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) &&
396 row.favicon_valid() && thumbnail_db_) { 397 row.favicon_valid() && thumbnail_db_) {
397 favicon.reset(new FaviconChangeDetails); 398 favicon.reset(new FaviconChangedDetails);
398 if (!favicon.get()) 399 if (!favicon.get())
399 return false; 400 return false;
400 favicon->urls.insert(url_row.url()); 401 favicon->urls.insert(url_row.url());
401 } 402 }
402 403
403 notifications->push_back(HistoryNotification( 404 notifications->push_back(HistoryNotification(
404 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release())); 405 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, modified.release()));
405 if (favicon.get()) 406 if (favicon.get())
406 notifications->push_back(HistoryNotification( 407 notifications->push_back(HistoryNotification(
407 chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release())); 408 chrome::NOTIFICATION_FAVICON_CHANGED, favicon.release()));
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 969
969 HistoryAndBookmarkRow new_row; 970 HistoryAndBookmarkRow new_row;
970 new_row.set_last_visit_time(FromDatabaseTime( 971 new_row.set_last_visit_time(FromDatabaseTime(
971 statement->statement()->ColumnInt64(0))); 972 statement->statement()->ColumnInt64(0)));
972 new_row.set_created(FromDatabaseTime( 973 new_row.set_created(FromDatabaseTime(
973 statement->statement()->ColumnInt64(1))); 974 statement->statement()->ColumnInt64(1)));
974 new_row.set_visit_count(statement->statement()->ColumnInt(2)); 975 new_row.set_visit_count(statement->statement()->ColumnInt(2));
975 new_row.set_title(statement->statement()->ColumnString16(3)); 976 new_row.set_title(statement->statement()->ColumnString16(3));
976 977
977 scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails); 978 scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails);
978 scoped_ptr<FaviconChangeDetails> favicon_details(new FaviconChangeDetails); 979 scoped_ptr<FaviconChangedDetails> favicon_details(new FaviconChangedDetails);
979 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails); 980 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
980 URLRow old_url_row; 981 URLRow old_url_row;
981 if (!history_db_->GetURLRow(ids[0].url_id, &old_url_row)) 982 if (!history_db_->GetURLRow(ids[0].url_id, &old_url_row))
982 return false; 983 return false;
983 deleted_details->rows.push_back(old_url_row); 984 deleted_details->rows.push_back(old_url_row);
984 985
985 chrome::FaviconID favicon_id = statement->statement()->ColumnInt64(4); 986 chrome::FaviconID favicon_id = statement->statement()->ColumnInt64(4);
986 if (favicon_id) { 987 if (favicon_id) {
987 std::vector<FaviconBitmap> favicon_bitmaps; 988 std::vector<FaviconBitmap> favicon_bitmaps;
988 if (!thumbnail_db_ || 989 if (!thumbnail_db_ ||
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 } 1098 }
1098 sql::Statement* result = statement.release(); 1099 sql::Statement* result = statement.release();
1099 return new AndroidStatement(result, replaced_index); 1100 return new AndroidStatement(result, replaced_index);
1100 } 1101 }
1101 1102
1102 bool AndroidProviderBackend::DeleteHistoryInternal( 1103 bool AndroidProviderBackend::DeleteHistoryInternal(
1103 const TableIDRows& urls, 1104 const TableIDRows& urls,
1104 bool delete_bookmarks, 1105 bool delete_bookmarks,
1105 HistoryNotifications* notifications) { 1106 HistoryNotifications* notifications) {
1106 scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails); 1107 scoped_ptr<URLsDeletedDetails> deleted_details(new URLsDeletedDetails);
1107 scoped_ptr<FaviconChangeDetails> favicon(new FaviconChangeDetails); 1108 scoped_ptr<FaviconChangedDetails> favicon(new FaviconChangedDetails);
1108 for (TableIDRows::const_iterator i = urls.begin(); i != urls.end(); ++i) { 1109 for (TableIDRows::const_iterator i = urls.begin(); i != urls.end(); ++i) {
1109 URLRow url_row; 1110 URLRow url_row;
1110 if (!history_db_->GetURLRow(i->url_id, &url_row)) 1111 if (!history_db_->GetURLRow(i->url_id, &url_row))
1111 return false; 1112 return false;
1112 deleted_details->rows.push_back(url_row); 1113 deleted_details->rows.push_back(url_row);
1113 if (thumbnail_db_ && 1114 if (thumbnail_db_ &&
1114 thumbnail_db_->GetIconMappingsForPageURL(url_row.url(), NULL)) 1115 thumbnail_db_->GetIconMappingsForPageURL(url_row.url(), NULL))
1115 favicon->urls.insert(url_row.url()); 1116 favicon->urls.insert(url_row.url());
1116 } 1117 }
1117 1118
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 return false; 1187 return false;
1187 1188
1188 if (!history_db_->SetKeywordSearchTermsForURL(bookmark_row.url_id(), 1189 if (!history_db_->SetKeywordSearchTermsForURL(bookmark_row.url_id(),
1189 values.template_url_id(), values.search_term())) 1190 values.template_url_id(), values.search_term()))
1190 return false; 1191 return false;
1191 } 1192 }
1192 return true; 1193 return true;
1193 } 1194 }
1194 1195
1195 } // namespace history 1196 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_changed_details.cc ('k') | chrome/browser/history/android/android_provider_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698