OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/api/activity_log_private/activity_log_privat
e_api.h" | 5 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 // Populate the return object. | 168 // Populate the return object. |
169 scoped_ptr<ActivityResultSet> result_set(new ActivityResultSet); | 169 scoped_ptr<ActivityResultSet> result_set(new ActivityResultSet); |
170 result_set->activities = result_arr; | 170 result_set->activities = result_arr; |
171 results_ = activity_log_private::GetExtensionActivities::Results::Create( | 171 results_ = activity_log_private::GetExtensionActivities::Results::Create( |
172 *result_set); | 172 *result_set); |
173 | 173 |
174 SendResponse(true); | 174 SendResponse(true); |
175 } | 175 } |
176 | 176 |
| 177 bool ActivityLogPrivateDeleteActivitiesFunction::RunImpl() { |
| 178 scoped_ptr<activity_log_private::DeleteActivities::Params> params( |
| 179 activity_log_private::DeleteActivities::Params::Create(*args_)); |
| 180 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 181 |
| 182 // Put the arguments in the right format. |
| 183 std::vector<int64> action_ids; |
| 184 int64 value; |
| 185 for (size_t i = 0; i < params->activity_ids.size(); i++) { |
| 186 if (base::StringToInt64(params->activity_ids[i], &value)) |
| 187 action_ids.push_back(value); |
| 188 } |
| 189 |
| 190 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); |
| 191 DCHECK(activity_log); |
| 192 activity_log->RemoveActions(action_ids); |
| 193 return true; |
| 194 } |
| 195 |
177 bool ActivityLogPrivateDeleteDatabaseFunction::RunImpl() { | 196 bool ActivityLogPrivateDeleteDatabaseFunction::RunImpl() { |
178 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); | 197 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); |
179 DCHECK(activity_log); | 198 DCHECK(activity_log); |
180 activity_log->DeleteDatabase(); | 199 activity_log->DeleteDatabase(); |
181 return true; | 200 return true; |
182 } | 201 } |
183 | 202 |
184 bool ActivityLogPrivateDeleteUrlsFunction::RunImpl() { | 203 bool ActivityLogPrivateDeleteUrlsFunction::RunImpl() { |
185 scoped_ptr<activity_log_private::DeleteUrls::Params> params( | 204 scoped_ptr<activity_log_private::DeleteUrls::Params> params( |
186 activity_log_private::DeleteUrls::Params::Create(*args_)); | 205 activity_log_private::DeleteUrls::Params::Create(*args_)); |
187 EXTENSION_FUNCTION_VALIDATE(params.get()); | 206 EXTENSION_FUNCTION_VALIDATE(params.get()); |
188 | 207 |
189 // Put the arguments in the right format. | 208 // Put the arguments in the right format. |
190 std::vector<GURL> gurls; | 209 std::vector<GURL> gurls; |
191 std::vector<std::string> urls = *params->urls.get(); | 210 std::vector<std::string> urls = *params->urls.get(); |
192 for (std::vector<std::string>::iterator it = urls.begin(); | 211 for (std::vector<std::string>::iterator it = urls.begin(); |
193 it != urls.end(); | 212 it != urls.end(); |
194 ++it) { | 213 ++it) { |
195 gurls.push_back(GURL(*it)); | 214 gurls.push_back(GURL(*it)); |
196 } | 215 } |
197 | 216 |
198 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); | 217 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); |
199 DCHECK(activity_log); | 218 DCHECK(activity_log); |
200 activity_log->RemoveURLs(gurls); | 219 activity_log->RemoveURLs(gurls); |
201 return true; | 220 return true; |
202 } | 221 } |
203 | 222 |
204 } // namespace extensions | 223 } // namespace extensions |
OLD | NEW |