| Index: chrome/browser/history/url_database.cc
|
| diff --git a/chrome/browser/history/url_database.cc b/chrome/browser/history/url_database.cc
|
| index 4f5a72dbb2b41adf661bb2f1be28ade66072f6a0..5af273492e5be5b8417e64c4004f8f5ae7dbcb33 100644
|
| --- a/chrome/browser/history/url_database.cc
|
| +++ b/chrome/browser/history/url_database.cc
|
| @@ -11,6 +11,7 @@
|
|
|
| #include "base/i18n/case_conversion.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/browser/history/url_database_observer.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "sql/statement.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| @@ -127,6 +128,10 @@ URLID URLDatabase::GetRowForURL(const GURL& url, history::URLRow* info) {
|
|
|
| bool URLDatabase::UpdateURLRow(URLID url_id,
|
| const history::URLRow& info) {
|
| + URLRow old;
|
| + if (!GetURLRow(url_id, &old))
|
| + return false;
|
| +
|
| sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
|
| "UPDATE urls SET title=?,visit_count=?,typed_count=?,last_visit_time=?,"
|
| "hidden=?"
|
| @@ -138,7 +143,16 @@ bool URLDatabase::UpdateURLRow(URLID url_id,
|
| statement.BindInt(4, info.hidden() ? 1 : 0);
|
| statement.BindInt64(5, url_id);
|
|
|
| - return statement.Run();
|
| + if(!statement.Run())
|
| + return false;
|
| +
|
| + URLRow cur;
|
| + if (!GetURLRow(url_id, &cur))
|
| + return false;
|
| +
|
| + FOR_EACH_OBSERVER(URLDatabaseObserver, observers_, URLChanged(old, cur));
|
| +
|
| + return true;
|
| }
|
|
|
| URLID URLDatabase::AddURLInternal(const history::URLRow& info,
|
| @@ -176,10 +190,18 @@ URLID URLDatabase::AddURLInternal(const history::URLRow& info,
|
| << " to table history.urls.";
|
| return 0;
|
| }
|
| +
|
| + if (!is_temporary)
|
| + FOR_EACH_OBSERVER(URLDatabaseObserver, observers_, URLAdded(info));
|
| +
|
| return GetDB().GetLastInsertRowId();
|
| }
|
|
|
| bool URLDatabase::DeleteURLRow(URLID id) {
|
| + URLRow info;
|
| + if (!GetURLRow(id, &info))
|
| + return false;
|
| +
|
| sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
|
| "DELETE FROM urls WHERE id = ?"));
|
| statement.BindInt64(0, id);
|
| @@ -187,6 +209,8 @@ bool URLDatabase::DeleteURLRow(URLID id) {
|
| if (!statement.Run())
|
| return false;
|
|
|
| + FOR_EACH_OBSERVER(URLDatabaseObserver, observers_, URLDeleted(info));
|
| +
|
| // And delete any keyword visits.
|
| if (!has_keyword_search_terms_)
|
| return true;
|
| @@ -601,4 +625,12 @@ bool URLDatabase::CreateMainURLIndex() {
|
| "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)");
|
| }
|
|
|
| +void URLDatabase::AddObserver(URLDatabaseObserver* observer) {
|
| + observers_.AddObserver(observer);
|
| +}
|
| +
|
| +void URLDatabase::RemoveObserver(URLDatabaseObserver* observer) {
|
| + observers_.RemoveObserver(observer);
|
| +}
|
| +
|
| } // namespace history
|
|
|