Chromium Code Reviews| Index: chrome/browser/extensions/activity_log/fullstream_ui_policy.cc |
| diff --git a/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc b/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc |
| index 94f637131f4c934702ac46d7c9ba937595761a23..047c8b9c9b52bd9364e405819d6bb23dbc600995 100644 |
| --- a/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc |
| +++ b/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc |
| @@ -97,9 +97,9 @@ bool FullStreamUIPolicy::FlushDatabase(sql::Connection* db) { |
| if (!action.page_title().empty()) { |
| statement.BindString(6, action.page_title()); |
| } |
| - std::string arg_url_string = action.SerializePageUrl(); |
| + std::string arg_url_string = action.SerializeArgUrl(); |
| if (!arg_url_string.empty()) { |
| - statement.BindString(5, arg_url_string); |
| + statement.BindString(7, arg_url_string); |
| } |
| if (action.other()) { |
| statement.BindString(8, Util::Serialize(action.other())); |
| @@ -187,6 +187,53 @@ scoped_ptr<Action::ActionVector> FullStreamUIPolicy::DoReadData( |
| return actions.Pass(); |
| } |
| +void FullStreamUIPolicy::DoRemoveURLs(const std::vector<GURL>& restrict_urls) { |
| + sql::Connection* db = GetDatabaseConnection(); |
| + if (!db) { |
| + LOG(ERROR) << "Unable to connect to database"; |
| + return; |
| + } |
| + |
|
mvrable
2013/08/26 18:22:42
Add a
activity_database()->AdviseFlush(ActivityD
karenlees
2013/08/26 22:58:36
Done.
|
| + // If no restrictions then then all URLs need to be removed. |
| + if (restrict_urls.empty()) { |
| + sql::Statement statement; |
| + std::string sql_str = base::StringPrintf( |
| + "UPDATE %s SET page_url=NULL,page_title=NULL,arg_url=NULL", |
| + kTableName); |
| + statement.Assign(db->GetCachedStatement( |
| + sql::StatementID(SQL_FROM_HERE), sql_str.c_str())); |
| + |
| + if (!statement.Run()) { |
| + LOG(ERROR) << "Removing URLs from database failed: " |
| + << statement.GetSQLStatement(); |
| + } |
| + return; |
| + } |
| + |
| + // If URLs are specified then restrict to only those URLs. |
| + for (uint32_t i = 0; i < restrict_urls.size(); ++i) { |
|
mvrable
2013/08/26 20:38:50
size_t
karenlees
2013/08/26 22:58:36
Done.
|
| + if (!restrict_urls[i].is_valid()) { |
| + continue; |
| + } |
| + DLOG(INFO) << "Removing URL " << restrict_urls[i].spec(); |
| + |
| + sql::Statement statement; |
| + std::string sql_str = base::StringPrintf( |
| + "UPDATE %s SET page_url=NULL,page_title=NULL,arg_url=NULL " |
| + "WHERE page_url=? OR arg_url=?", |
| + kTableName); |
| + statement.Assign(db->GetCachedStatement( |
| + sql::StatementID(SQL_FROM_HERE), sql_str.c_str())); |
| + statement.BindString(0, restrict_urls[i].spec()); |
| + statement.BindString(1, restrict_urls[i].spec()); |
| + |
| + if (!statement.Run()) { |
| + LOG(ERROR) << "Removing URL from database failed: " |
| + << statement.GetSQLStatement(); |
| + } |
| + } |
| +} |
| + |
| void FullStreamUIPolicy::OnDatabaseFailure() { |
| queued_actions_.clear(); |
| } |
| @@ -216,6 +263,15 @@ void FullStreamUIPolicy::ReadData( |
| callback); |
| } |
| +void FullStreamUIPolicy::RemoveURLs(const std::vector<GURL>& restrict_urls) { |
| + BrowserThread::PostTask( |
|
mvrable
2013/08/26 20:38:50
ScheduleAndForget should be able to do the same as
|
| + BrowserThread::DB, |
| + FROM_HERE, |
| + base::Bind(&FullStreamUIPolicy::DoRemoveURLs, |
| + base::Unretained(this), |
| + restrict_urls)); |
| +} |
| + |
| scoped_refptr<Action> FullStreamUIPolicy::ProcessArguments( |
| scoped_refptr<Action> action) const { |
| return action; |